
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@badeball/cypress-parallel
Advanced tools
Divides your test files into equal buckets and runs a single bucket. This is ideal for parallizing Cypress tests in a CI environment, without relying on Cypress' paid Dashboard Service.
Divides your test files into equal buckets and runs a single bucket. This is ideal for parallizing Cypress tests in a CI environment, without relying on Cypress' paid Dashboard Service.
$ npm install @badeball/cypress-parallel
knapsack.json
)--spec
to Cypress with said bucket of filesN and I is determined either by a flag --node
or by environment variables for some CI providers.
The overwritten knapsack can then be comitted back into VCS. This will allow the library to always divide your tests somewhat evenly among the nodes.
Below are all the configuration options and some extended explanation for some of them.
$ npx cypress-parallel --help
Usage: cypress-parallel [options]
Options:
-v, --version output the version number
--cypress-run-command <cmd> specifies the command to run cypress (in non-interactive mode), defaults
to 'npx cypress run' or 'yarn cypress run' depending on how invoked
--node <index>:<count> specifies number of buckets and which to run
--knapsack <path> specifies the path to the knapsack file (default: "knapsack.json")
--disable-knapsack-output disabled knapsack output (default: false)
--unweighed-strategy <strategy> strategy to utilize for unweighed test files ('estimate' (default) |
'distribute') (default: "estimate")
-h, --help display help for command
Unrecognized arguments are passed along to Cypress, so arguments such as -e / --env
can be used
as shown below
$ npx cypress-parallel --env foo=bar
The utility will automatically pick up node configuration for some CI providers. Otherwise you can
specify node index and total node count using --node
, as shown below.
$ npx cypress-parallel --node 1:5
Specifies the location of the knapsack file. Defaults to knapsack.json
.
Disables outputting knapsack data to the file system. This is always disabled when you specify
--reporter
or --reporter-options
to Cypress. If you require custom options and still want to
obtain the knapsack output, you need to configure cypress-multi-reporters
with
@badeball/mocha-knapsack-reporter
yourself.
What strategy to utilize if encountering a test file that isn't contained in the knapsack. The "estimate" strategy will estimate expected execution time based off of file length (line numbers). The "distribute" strategy will merely distribute unknown files evenly amongst the nodes.
Custom stragies can be implemented using cusmiconfig, as shown below.
module.export = {
/** @type {import("@badeball/cypress-parallel").UnweighedStrategy} */
unweighedStrategy(weighedFiles, unweighedFiles, nodeCount) {
// Implement me.
},
};
Below is an example of how to configure Gitlab CI to parallelize Cypress tests. Contributions of similar examples for other providers are welcome.
This example illustrate two things, 1) running tests in parallel and 2) combining knapsack data into a single, downloadable artifact. The latter is completely optional and you need to decide for yourself how you want to handle this.
test:
stage: Test (1)
parallel: 5
artifacts:
when: always
paths:
- knapsack-$CI_NODE_INDEX.json
expire_in: 1 day
script:
- npx cypress-parallel --knapsack "knapsack-$CI_NODE_INDEX.json
knapsack:
stage: Test (2)
script:
- cat knapsack-*.json | jq -sS add | tee knapsack.json
artifacts:
when: always
paths:
- knapsack.json
expire_in: 1 day
If your provider does to provide a keyword such as Gitlab's parallel
, then you can always simply
just create N explicit jobs, similar to that shown below.
test_1:
stage: Test
script:
- npx cypress-parallel --node 1:5
test_2:
stage: Test
script:
- npx cypress-parallel --node 2:5
test_3:
stage: Test
script:
- npx cypress-parallel --node 3:5
test_4:
stage: Test
script:
- npx cypress-parallel --node 4:5
test_5:
stage: Test
script:
- npx cypress-parallel --node 5:5
FAQs
[](https://github.com/badeball/cypress-parallel/actions/workflows/build.yml) [![Npm package weekly downloads](https://badgen.net/npm/dw/@badeball/cypress-pa
The npm package @badeball/cypress-parallel receives a total of 2,085 weekly downloads. As such, @badeball/cypress-parallel popularity was classified as popular.
We found that @badeball/cypress-parallel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.