bahmutov / cypress-repeat

Run Cypress multiple times in a row
https://glebbahmutov.com/blog/wrap-cypress-using-npm/
37 stars 11 forks source link

post script not supported when spec fails in cypress-repeat #44

Open jjorgenson-globality opened 1 year ago

jjorgenson-globality commented 1 year ago

Hey there! I'm having some issues using the post script after cypress-repeat finishes and encounters a fail.

package.json

"cy:run:repeat": "cypress-repeat run -n ${npm_config_times:-5} --browser ${npm_config_test_browser:-chrome} --record false --env configFile=${npm_config_env:-test} --spec",

// Pre and Post scripts
"precy:run:repeat": "npm run report:clean",
"postcy:run:repeat": "npm run report:merge & npm run report:generate",

// Where the scripts point to
"report:clean": "rm -R -f cypress/reports",
"report:merge": "mochawesome-merge cypress/reports/*.json > cypress/reports/index.json",
"report:generate": "marge cypress/reports/index.json --reportDir cypress/reports/mochaReport --assetsDir cypress/reports/mochaReport/assets --charts true --autoOpen true --showHooks always",

When the repeats finish all successfully, the report opens, and the terminal looks like:

***** finished 5 run(s) successfully *****

> postcy:run:repeat
> npm run report:merge & npm run report:generate
... so on and so forth

When a fail occurs:

cypress-repeat: run 2 of 3 failed

and kicked out. No post script triggered.

I'm guessing it has something to do with process.exit(testResults.totalFailed) found here, but not totally sure.

TLDR It would be really nice to have the option of having failed tests without exiting altogether so we can still generate reports. Somewhat related to https://github.com/bahmutov/cypress-repeat/issues/33

Thank you!

bahmutov commented 1 year ago

I would not change this like this. You do want to fail if there are any failed tests, right? You could add an option to allow failures and only then exit with zero