0.3.0 ā€¢ Published 6 months ago

cypress-parallel-extended-filtering v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

npm version

cypress-parallel

Fork of cypress-parallel:

  • Allows to disable included reporter when using mochawesome report generator, multi reporter and mochawesome-merge.
  • Adds spliting tests by text included in test file -S=@test,@second (grep tag, name...)

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

cypresscypress-parallel
cy-serial-smallcy-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>"'

Scripts options

OptionAliasDescriptionType
--helpShow help
--versionShow version number
--script-sYour npm Cypress commandstring
--args-aYour npm Cypress command argumentsstring
--threads-tNumber of threadsnumber
--specsDir-dCypress specs directorystring
--weightsJson-wParallel weights json filestring
--reporter-rReporter to pass to Cypress.string
--reporterOptions-oReporter optionsstring
--reporterModulePath-nSpecify the reporter module pathstring
--disableParallelReporter-fDisable included reporterboolean
--bail-bExit on first failing threadstring
--verbose-vSome additional loggingstring
--strictMode-mAdd stricter checks after running the testsboolean
--splitByText-SSplit test by text included in the filestring[]

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"
  ...
}

NB: If you disbaled included reporter, then use following config and actions after getting results in json from mochawesome reporter.

 reporterOptions: {
  ...
  saveJson: true
  saveHtml: false
  ...
}
"scripts" :{
  ...
  "cy:merge-json": "mocahwsome-merge <jsonsPath/*.json> -o <output>"
  "cy:generate-html": "marge <jsonPath> -o=<outputHTMLPath> -i" 
  ...
}

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.