https://github.com/tnicola/cypress-parallel
Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.
https://github.com/tnicola/cypress-parallel
cypress localhost parallel shard sharding
Last synced: 5 months ago
JSON representation
Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.
- Host: GitHub
- URL: https://github.com/tnicola/cypress-parallel
- Owner: tnicola
- License: mit
- Created: 2020-05-24T07:58:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-22T09:44:12.000Z (7 months ago)
- Last Synced: 2025-04-10T04:53:09.276Z (6 months ago)
- Topics: cypress, localhost, parallel, shard, sharding
- Language: JavaScript
- Size: 1.35 MB
- Stars: 593
- Watchers: 15
- Forks: 126
- Open Issues: 69
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/cypress-parallel)
# cypress-parallel
Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.
| cypress | cypress-parallel |
| :-----------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |
|  |  |# 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:
```typescript
"scripts" :{
...
"cy:run": "cypress run", // It can be any cypress command with any argument
"cy:parallel" : "cypress-parallel -s cy:run -t 2 -d '' -a '\"\"'"
...
}
```### 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 '' -a '""'
```## Passing Specs
```
cypress-parallel -s cy:run -t 2 -a '\"\"' --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:
```typescript
"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.
```typescript
"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.
```javascript
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](LICENSE).