cypress-parallel icon indicating copy to clipboard operation
cypress-parallel copied to clipboard

Script failed when 'runner-results' folder not exist or if not empty

Open PBIIBP opened this issue 3 years ago • 13 comments

Hi,

in the start script, there is a line code that remove the 'runner-results' folder but the script throw an exception in 2 cases: -> when this folder not exist -> when this folder exist and it contains files

So before run the cmd, i must clean the folder or create a empty 'runner-results' folder. Could you handle this exception?

cypress-parallel -s cy:run -t 4 -d cypress/integration/ -p cypress-report-config.json

(node:30920) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rmdir 'C:\Personal_Unsaved\Projet\front-end\runner-results' at Object.rmdirSync (fs.js:684:3) at cleanResultsPath (C:\Personal_Unsaved\Projet\front-end\node_modules\cypress-parallel\cli.js:19:6) at start (C:\Personal_Unsaved\Projet\front-end\node_modules\cypress-parallel\cli.js:23:3) at Object. (C:\Personal_Unsaved\Projet\front-end\node_modules\cypress-parallel\cli.js:124:1) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) (node:30920) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:30920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

PBIIBP avatar Sep 14 '21 22:09 PBIIBP

Hey @PBIIBP . I'm having the same problem and actually even if I create the empty runner-results folder in the project's root dir, it's being deleted and then this error occurs.

Did you managed to overcome this issue somehow?

nikodamnCH avatar Sep 22 '21 08:09 nikodamnCH

changing the cleanResultsPath method in node_modules/cypress-parallel/cli.js to the following did the trick for me:

function cleanResultsPath() { if(!fs.existsSync(resultsPath)) { fs.mkdirSync(resultsPath, { recursive: true }) } else { fs.readdir(resultsPath, (err, files) => { if (err) console.log(err); for (const file of files) { fs.unlink(path.join('path here', file), err => { if (err) console.log(err); }); } }); } }

kronwalled avatar Nov 17 '21 11:11 kronwalled

@PBIIBP May be issue is with your cypress-report-config.json file. Can you share the json file ?

ISanjeevKumar avatar Mar 02 '22 17:03 ISanjeevKumar

I encountered the same issue with version cypress-parallel 0.9.0 and cypress 9.4.1 project structure: project/cypress/integration/folder/test.spec.ts command: npx cypress-parallel -s dev -t 2 -d **/user.spec.ts OS: Windows 10 / powershell

Would be great if you can have a look @ISanjeevKumar

node:fs:1390 handleErrorFromBinding(ctx); ^

Error: ENOENT: no such file or directory, scandir 'C:\Users\user\dev\project\runner-results' at Object.readdirSync (node:fs:1390:3) at collectResults (C:\Users\user\dev\project\node_modules\cypress-parallel\utility.js:35:26) at start (C:\Users\user\dev\project\node_modules\cypress-parallel\cli.js:32:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) { errno: -4058, syscall: 'scandir', code: 'ENOENT', path: 'C:\Users\user\dev\project\runner-results' }

nils-hoyer avatar Mar 09 '22 10:03 nils-hoyer

I understood the problem now. it is getting failed because :

When none of the test case has got executed then report folder will not get created by 'json-stream.reporter', Hence you are getting this error.

Command which you are using looks not correct to me. Please use something like this '"node_modules/.bin/cypress-parallel -s dev -t 2-d '**/user.spec.ts'.

Note: json-stream.reporter will create report folder 'runner-result' only when a test case gets executed.

ISanjeevKumar avatar Mar 11 '22 17:03 ISanjeevKumar

HI @ISanjeevKumar, sorry for the late response to your suggestion.

When none of the test case has got executed then report folder will not get created by 'json-stream.reporter', Hence you are getting this error.

I can confirm if none test cases are found this error will occour. In our case tests where executed but still the error will occour.

Command which you are using looks not correct to me. Please use something like this '"node_modules/.bin/cypress-parallel -s dev -t 2-d '**/user.spec.ts'.

This is exactly what npx does from my understanding. https://www.npmjs.com/package/npx I also double checked and with both execution ways the error occours.

nils-hoyer avatar Mar 30 '22 11:03 nils-hoyer

I did some investigation today and can give the following result in return which lead to the error in our case.

  1. cypress-extends plugin in combination with our own cypress-multi-reporters configuration seems to colidate. from cypress.json: "reporter": "cypress-multi-reporters", "reporterOptions": { "configFile": "reporter-config.json" }, from cypress-env-dev.json: "extends": "./cypress.json", ... from reporter-config.json: "reporterEnabled": "mochawesome, mocha-junit-reporter", "mochawesomeReporterOptions": { "reportDir": "cypress/reports/mochawesome/json", "reportFilename": "spec", "overwrite": false, "html": false }, "mochaJunitReporterReporterOptions": { "mochaFile": "cypress/reports/mocha-junit-reporter/spec_[hash].xml", "includePending": true, "jenkinsMode": true }
    plugins/index.js module.exports = (on, config) => { return require('@bahmutov/cypress-extends')(config.configFile); } solution 1: as soon as the cypress-extends plugin is disabled in plugins/index.js and config files will not be merged. Additionally I have to configure the cypress-multi-reporters via cli. the configuration for cypress-multi-reporters from cypress-env-dev.json seems to be ignored. -r cypress-multi-reporters -o 'configFile=reporter-config.json solution 2: delete your own cypress-multi-reporters config from cypress.json and it will also work like expected.

My question here is if it is intended that cypress-multi-reporters config from cypress.json will be ignored by default? Its at least not documented.

nils-hoyer avatar Mar 30 '22 12:03 nils-hoyer

@nils-hoyer nils-hoyer you only copy'n'pasted the runner config to a new file? { "reporterOptions": { "mochaFile": "tests/junitresults_integration-[hash].xml", "toConsole": true, "attachments": true } } i tried but no luck. thats the script in package.json: cypress-parallel -s cy:run -t 2 -d cypress/e2e/one/* -a '\"--browser electron --headed --reporter junit --config video=false\"' -r cypress-multi-reporters -o 'configFile=reporter-config.json

tobiasgrossmann avatar Jun 10 '22 11:06 tobiasgrossmann

yes, I addressed the reporter-config.json from the cypress-parallel cli. two suggestions: make sure, you are not using cypress-extends plugin and not refer to report-config file from cypress config.

nils-hoyer avatar Jun 13 '22 12:06 nils-hoyer

Sorry, doesn't seems to work for me. Even if I remove the reporter config complete. ENOENT: no such file or directory, scandir ClientApp\node_modules\cypress-parallel\utility.js:35:26)

tobiasgrossmann avatar Jun 14 '22 11:06 tobiasgrossmann

if you upload an example repo reproducing the error I can have a quick look on it.

nils-hoyer avatar Jun 14 '22 12:06 nils-hoyer

I have this somewhat similar issue. Unfortunately i cannot share the repo is a customer project, but i run the build without parallel it works all fine on jenkins but everytime i try it out with parallel i get this error.

node:fs:1405
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, scandir '/home/jenkins/slave/workspace/some-project-folder/runner-results'
    at Object.readdirSync (node:fs:1405:3)
    at collectResults (/home/jenkins/slave/workspace/some-project-folder/node_modules/cypress-parallel/utility.js:35:26)
    at start (/home/jenkins/slave/workspace/some-project-folder/node_modules/cypress-parallel/cli.js:32:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',

this started to happen after cypress 10 upgrade, but works well with cypress 9

turso avatar Jun 16 '22 06:06 turso

I am facing the same problem

gethari avatar Sep 02 '22 10:09 gethari

Same problem. Will check up on the PR linked above.

aaron-qa avatar Nov 15 '22 11:11 aaron-qa