bahmutov / cypress-repeat

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

Ability to force repeat the test suites n times even any spec passed or failed #33

Open MaxAllianov opened 2 years ago

MaxAllianov commented 2 years ago

I'm trying to use the cypress-repeat command to create a bulk of purchases at the online store for further tests. It happens that tests failed due to specific reasons, but I need to keep new test suites repeats moving forward.

It would be wonderful to have a feature like this

MaxAllianov commented 2 years ago

Hello @bahmutov, could you please take a look?

I appreciate your time

bahmutov commented 2 years ago

I would like to see more explanation of what you want to see vs what happens now. And a pull request if possible

Sent from my iPhone

On Feb 15, 2022, at 05:03, MaxAllianov @.***> wrote:

 Hello @bahmutov, could you please take a look?

I appreciate your time

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

MaxAllianov commented 2 years ago

Thank you for your answer!

Currently, cypress-repeat has 3 options: 1) only n argument 2) Until passes 3) Rerun only failed Specs

"n" — stops repeating the tests on first spec failure "Until passes" — stops repeating the spec on first success "Rerun only failed Specs" — stops repeating the spec on the first success (or when there are no failed specs, but its the same in case there is only 1 spec)

The issue is that there is no way to just repeat the test N times. I guess it would be right if only n argument would just repeat the spec n times.

For example, this command should repeat the spec 5 times despite its failure or success: npx cypress-repeat --spec "**/myTest.spec.js" -n 5

This feature would be useful to have to make some sort of stability tests. In my case, this feature would be useful to make n purchases at an online store for further tests

Thank you in advance!

WParlow commented 1 year ago

I know this is a tad outdated, but I solved your problem @MaxAllianov locally since I was needing the same thing. @bahmutov not sure if it's worth a PR since it's not entirely fleshed out as well as it could be. But I'm using something like this in the index.js.

const args = arg(
  {
    '-n': Number,
    '--until-passes': Boolean,
    '--rerun-failed-only': Boolean,
    '--force': Boolean,
  },
  { permissive: true },
)

const force = '--force' in args ? args['--force'] : false
    if (testResults.status === 'finished') {
      if (force) {
        if (isLastRun) {
          process.exit(0)
        }
      } else {
        if (untilPasses) {

finally npx cypress-repeat run -n 3 --force --reporter mochawesome --headless --config-file cypress.config.ts --spec 'cypress/e2e/platform/**/*'