How to run the same test or spec files again and again by launching it from GitHub Actions page.
Imagine you are doubting if a test works consistently. You could run it using cypress-grep locally. But what if someone working on the backend API comes in and asks if they could launch the tests too? You could give them the command line utility run-cy-on-ci to launch the tests from the terminal. Or you could let them launch the tests from the GitHub Actions page and it is much much simpler procedure.
Using the plugin cypress-grep you can select the test to run using a part of its title and skip all other tests and specs. In our GitHub Actions workflow repeat-test.yml we can pass the grep and burn parameters connecting the user interface to the test run.
All the user needs to do is to enter a part of the test's title and pick the number of times to run the test.
The same test selected by its title is repeated five times in a row
Run all tests tagged X N times
In my repo, I organize the tests using tags, see How To Tag And Run End-to-End Tests. If I want to run all tests tagged @editing, I need a different workflow repeat-tag.yml to pass the tag value using grepTag variable to the cypress-grep plugin.
Let's launch the @editing tests and run them 3 times each.
Run a test file N times
Finally, let's imagine we want to run a particular test file (spec) several times. We can install the plugin cypress-repeat that uses Cypress NPM module API to run the test runner N times. For example, we can run the spec cypress/integration/item-spec.js twice using the terminal command
1
$ npx cypress-repeat run --spec cypress/integration/item-spec.js -n 2 ...
In the workflow repeat-spec.yml we will use cypress-repeat as a custom command option:
Tip: you can run multiple spec files by giving a common parent folder name. For example, to run all integration specs in the folder cypress/integration enter the "integration" as the spec name. It will invoke Cypress with parameter --spec **/integration which will match all specs.