Cypress throws error cy.task('copyTestDir') failed with the following error: > EPERM: operation not permitted, copyfile 'C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\test\test-data-original' -> 'C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\test\test-data' #15925
Unanswered
nsrivastava645
asked this question in
Plugins
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to do a file system operation i.e., copy a directory which contains test data to another temporary directory. I am using fs-extra and doing that using cypress plugins mehod.
My plugin file looks like this
const fs = require('fs-extra'); const path = require('path'); import vAgent from '../../../vagent'; const source = path.join(__dirname, '..', '..', "test", "test-data-original"), destination = path.join(__dirname, '..', '..', "test", "test-data"); module.exports = (on, config) => { on('task', { copyTestDir() { return new Promise((resolve, reject) => { try { if (fs.existsSync(destination)) { fs.removeSync(destination); } fs.mkdirpSync(destination); fs.copyFileSync(source, destination); } catch (error) { reject(error); } resolve('files copied'); }) }, countFiles() { let files; try { files = fs.readdirSync(destination); } catch (err) { console.log(err); } return (destination); }, async readFileViaVagent(filePath) { let content = await vAgent.readFile(filePath, 'utf-8'); return content; } }) }
My testcase file looks like this:
describe('Test Suites Section', () => { it('Open Configuration tab', () => { u.openApp(cy, Cypress.env('isPro')); cy.task('copyTestDir'); cy.task('countFiles').then((fileCount) => { console.log(fileCount); }); u.addProject(cy); u.openConfigurationTab(cy); });
The error I am receiving is :
CypressError:
cy.task('copyTestDir')` failed with the following error:From Node.js Internals:
Error: EPERM: operation not permitted, copyfile 'C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\test\test-data-original' -> 'C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\test\test-data'
at Object.copyFileSync (fs.js:1991:3)
at Object.func [as copyFileSync] (electron/js2c/asar_bundle.js:5:1846)
at C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\cypress\plugins\index.js:15:14
at new Promise ()
at copyTestDir (C:\Work\Vrest repos\vrest-meta-bkup\vrest-ng-meta\packages\vrest_ui\cypress\plugins\index.js:9:14)
at invoke (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\child\task.js:47:14)
at C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\util.js:45:14
at tryCatcher (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
at Function.Promise.attempt.Promise.try (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
at Object.wrapChildPromise (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\util.js:44:23)
at Object.wrap (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\child\task.js:53:8)
at execute (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:127:19)
at EventEmitter. (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:202:5)
at EventEmitter.emit (events.js:315:20)
at process. (C:\Users\Neeraj\AppData\Local\Cypress\Cache\7.0.1\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
at process.emit (events.js:315:20)
logError @ cypress_runner.js:177186
(anonymous) @ cypress_runner.js:176714
emit @ cypress_runner.js:52783
(anonymous) @ cypress_runner.js:165828
emit @ cypress_runner.js:52783
emit @ cypress_runner.js:165883
onPrint @ cypress_runner.js:164701
_onPrintClick @ cypress_runner.js:164706
(anonymous) @ cypress_runner.js:166054
executeAction @ cypress_runner.js:50647
n @ cypress_runner.js:50647
ca @ cypress_runner.js:61255
ja @ cypress_runner.js:61256
ka @ cypress_runner.js:61256
wa @ cypress_runner.js:61258
Aa @ cypress_runner.js:61259
ya @ cypress_runner.js:61259
Da @ cypress_runner.js:61262
Ad @ cypress_runner.js:61325
Gi @ cypress_runner.js:61491
Kb @ cypress_runner.js:61280
Dd @ cypress_runner.js:61327
(anonymous) @ cypress_runner.js:61492
../../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority @ cypress_runner.js:61571
Ii @ cypress_runner.js:61492
Cd @ cypress_runner.js:61326`
Beta Was this translation helpful? Give feedback.
All reactions