Have ideas to improve npm?Join in the discussion! »

run-each-cypress-spec

1.5.0 • Public • Published

run-each-cypress-spec

Small script to run each Cypress spec file one by one

NPM

Build status semantic-release

Problem

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 cypress/integration/*-spec.js files and runs them one by one using cypress run command.

npm install -g run-each-cypress-spec
run-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 the folder cypress/videos/foo.

Old specs

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.

Related

Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 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

MIT License

Copyright (c) 2017 Gleb Bahmutov <gleb.bahmutov@gmail.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.

Install

npm i run-each-cypress-spec

DownloadsWeekly Downloads

3

Version

1.5.0

License

MIT

Last publish

Collaborators

  • avatar