Git Product home page Git Product logo

cypress-parallel's Introduction

npm version

cypress-parallel

Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.

cypress cypress-parallel
cy-serial-small cy-parallel_small

Run your Cypress tests in parallel (locally)

How it works

๐Ÿ” - Search for existing Cypress tests
๐Ÿ“„ - Read (if exists) a weight file
โš–๏ธ - Split spec files into different threads
โš™๏ธ - For each thread it runs the Cypress command you've passed as argument
๐Ÿ“ˆ - Wait for all threads to finish and collects the result in a single report

How to use

Install

npm i cypress-parallel -D

or

yarn add cypress-parallel -D

Add a new script

In your package.json add a new script:

"scripts" :{
  ...
  "cy:run": "cypress run", // It can be any cypress command with any argument
  "cy:parallel" : "cypress-parallel -s cy:run -t 2 -d '<your-cypress-specs-folder>' -a '\"<your-cypress-cmd-args>\"'"
  ...
}

With Arguments

Sample:

-a '\"--config baseUrl=http://localhost:3000\"'

Launch the new script

npm run cy:parallel

or

Run with npx (no package installation needed)

npx cy:parallel -s cy:run -t 2 -d '<your-cypress-specs-folder>' -a '"<your-cypress-cmd-args>"'

Passing Specs

cypress-parallel -s cy:run -t 2 -a '\"<your-cypress-cmd-args>\"' --spec path/to/spec1.spec.js path/to/spec2.spec.js

Scripts options

Option Alias Description Type
--help Show help
--version Show version number
--script -s Your npm Cypress command string
--args -a Your npm Cypress command arguments string
--threads -t Number of threads number
--specsDir -d Cypress specs directory string
--spec Cypress spec file paths string
--weightsJson -w Parallel weights json file string
--reporter -r Reporter to pass to Cypress. string
--reporterOptions -o Reporter options string
--reporterModulePath -n Specify the reporter module path string
--bail -b Exit on first failing thread string
--verbose -v Some additional logging string
--strictMode -m Add stricter checks after running the tests boolean

NB: If you use cypress-cucumber-preprocesor, please disable the strictMode to avoid possible errors:

"scripts" :{
  ...
  "cy:parallel" : "cypress-parallel -s cy:run -t 4 -m false"
  ...
}

NB: If your cypress-multi-reporters module is not found on the same level as your Cypress suite (e.g. in a mono-repo) then you can specify the module directory for Cypress to search within.

"scripts" :{
  ...
  "cy:parallel" : "cypress-parallel -s cy:run -t 4 -n .../../../node_modules/cypress-multi-reporters"
  ...
}

Env variables

CYPRESS_THREAD

You can get the current thread index by reading the CYPRESS_THREAD variable.

 const threadIndex = process.env.CYPRESS_THREAD;
 // return 1, 2, 3, 4, ...

Contributors

Looking for contributors.

License

This project is licensed under the MIT license. See LICENSE.

cypress-parallel's People

Contributors

tnicola avatar dependabot[bot] avatar kristofferlind avatar giorgiapitteri avatar jayc13 avatar jbarbede avatar ypresto avatar brady727 avatar kj-brown avatar mribichich avatar rebeccaalpert avatar joshuajtward avatar anderscarling avatar bendaspur avatar krisell avatar ryanolson-aumni avatar stepn1k avatar tlehwalder avatar hatseh avatar unlocomqx avatar nolij avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.