UNPKG

@studyportals/cypress-slicer

Version:

Cypress plugin to slice the specPattern list of tests into subsets

62 lines (45 loc) 1.53 kB
# @studyportals/cypress-slicer > Slices the Cypress tests resolved by the `specPattern` config property into multiple chunks and runs them in parallel. ```shell # runs only the first third (natural sorting) of the tests npx cypress run --env workers=3,worker=1 # runs only the the last third (natural sorting) of the tests npx cypress run --env workers=3,worker=3 # runs only all the tests npx cypress run --env workers=1,worker=1 npx cypress run ``` ## Install Assuming you have Cypress installed, add this module as a dev dependency. ```shell # using NPM npm i -D @studyportals/cypress-slicer # using Yarn yarn add -D @studyportals/cypress-slicer ``` **Note**: @studyportals/cypress-slicer only works with Cypress version >= 10. ### Config file **optional:** load and register this module from the [config file](https://docs.cypress.io/guides/references/configuration#setupNodeEvents): ```js // cypress.config.js { e2e: { setupNodeEvents(on, config) { require('@studyportals/cypress-slicer/plugin')(config); return config; }, } } ``` ## Usage Overview The number of chunks is determined by the `workers` environment variable. The `worker` environment variable determines which chunk to run. You can configure the number of `workers` and the `worker` index through the `env` property of the configuration defined in the `cypress.config.js` file: ```js { env: { workers: process.env.WORKERS, worker: process.env.WORKER, } } ``` > ⚠ The `worker` index is 1-based, not 0-based.