'Using a CSV file in API POST request in a cypress test
I am currently trying to use a CSV file in an api POST request and I am struggling with it! So the error I am getting is a webpack error
Module parse failed: Unexpected token (1:7) You may need an appropriate loader to handle this file type, currently, no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
What do I need to add or download to accept a CSV file?
Below is the code I am using:
const fileName = require ('file url')
cy.fixture('fileName').then((payload) =>{
cy.request({
url: 'requestUrl',
headers: {
method: 'POST',
'Authorization': 'Bearer access code',
body: payload
}
}).then((res) =>{
cy.log(JSON.stringify(res))
expect(res.status).to.eq(200)
});
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
