Small script to run each Cypress spec file one by one
If you separate Cypress E2E tests into multiple spec files, you soon end up with lots of files. This script allows you to run all of them one after another from the command line.
This little shell script finds all
and runs them one by one using
cypress run command.
npm install -g run-each-cypress-specrun-specs
If you need environment variables (like urls, passwords), you can easily inject them using as-a
as-a cy run-specs
If a single test fails, the loop will exit with error right away.
Videos and screenshots
To prevent Cypress from deleting videos from the first spec when starting
the second spec, the videos and screenshots will be placed into
subfolders. For example videos for spec
foo-spec.js will be saved into
Sometimes, if your CI is not guaranteed to have a clean slate (I am looking at you, Jenkins!) the workspace might have "old" spec files that have not been properly deleted. You can clean the spec folder yourself by running the git clean command.
$ git clean -f cypress
Deletes all non-tracked files in folder
cypress and its subfolders.
Running tests twice
Sometimes tests fail for unknown reason. You can run a test a second time
automatically by setting
DOUBLE=1 npm run ... environment variable.
- Cypress tips and tricks
- cypress-failed-log - Gets you the Cypress test command log as JSON on failure
Author: Gleb Bahmutov <firstname.lastname@example.org> © 2017
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github
Copyright (c) 2017 Gleb Bahmutov <email@example.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.