I am using the cypress cy.task()
method/ function to copy a csv
file from one directory to another directory. Below is my cy.task('copycsvFile')
and relevant code written in support/index.js
file. While running it throws following error;
CypressError: cy.task('copycsvFile') failed with the following error:
The 'task' event has not been registered in the plugins file. You must register it before using cy.task()
Any idea why this is not recognised ?
Node version : v10.15.3, Cypress version : 3.1.5
//sample-spec.js file
cy.task('copycsvFile');
Below is my index.js
file
// support/index.js file
const fs = require('fs');
module.exports = (on) => {
on('task', {
copycsvFile: (Obj)=>{
var fs = require('fs');
fs.createReadStream('C:/Users/SomeName/Downloads/Export_Survey_CSV.csv').pipe(fs.createWriteStream('C:/User/Client/Client - Cypress Web UI Tests/cypress/fixtures/Export_Survey_CSV.csv'));
}
});
};