Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PBIIBP opened this issue Sep 14, 2021 · 14 comments · Fixed by #135
Closed

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

PBIIBP opened this issue Sep 14, 2021 · 14 comments · Fixed by #135

Comments

@PBIIBP
Copy link

PBIIBP commented Sep 14, 2021

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.

@nikodamnCH
Copy link

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?

@kronwalled
Copy link

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); }); } }); } }

@ISanjeevKumar
Copy link

ISanjeevKumar commented Mar 2, 2022

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

@nils-hoyer
Copy link

nils-hoyer commented Mar 9, 2022

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'
}

@ISanjeevKumar
Copy link

ISanjeevKumar commented Mar 11, 2022

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.

@nils-hoyer
Copy link

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
Copy link

nils-hoyer commented Mar 30, 2022

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.

@tobiasgrossmann
Copy link

@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

@nils-hoyer
Copy link

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.

@tobiasgrossmann
Copy link

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)

@nils-hoyer
Copy link

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

@turso
Copy link

turso commented Jun 16, 2022

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

@gethari
Copy link

gethari commented Sep 2, 2022

I am facing the same problem

@hiroyone hiroyone mentioned this issue Nov 5, 2022
@aaron-qa
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants