From d6660eab9ed56015d4a061329b7fb6c4fb0938e0 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Thu, 5 Jun 2025 11:10:55 -0600 Subject: [PATCH 1/3] fix(Cypress10+): default suites dir --- lib/settings.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/settings.js b/lib/settings.js index c3e5954..f4bd3f5 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -83,9 +83,13 @@ const COLORS = [ '\x1b[40m' ]; +const cypressVersion = require('cypress/package.json').version; +const cypressMajorVersion = parseInt(cypressVersion.split('.')[0], 10); + const settings = { threadCount: argv.threads ? argv.threads : 2, - testSuitesPath: argv.specsDir ? argv.specsDir : 'cypress/integration', + testSuitesPath: argv.specsDir ? argv.specsDir : + cypressMajorVersion >= 10 ? 'cypress/e2e' : 'cypress/integration', testSuitesPaths: argv.spec ? argv.spec : undefined, shouldBail: argv.bail ? argv.bail : false, isVerbose: argv.verbose ? argv.verbose : false, From e7d673cb81fecf77258fd8c4908339dda1870c04 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Thu, 5 Jun 2025 11:28:40 -0600 Subject: [PATCH 2/3] style: use parser defaults --- README.md | 32 +++++++++++++-------------- lib/README.md | 58 ++++++++++++++++++++++++++++++++----------------- lib/settings.js | 33 +++++++++++++++------------- 3 files changed, 72 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 60f59a6..35165d3 100644 --- a/README.md +++ b/README.md @@ -75,22 +75,22 @@ cypress-parallel -s cy:run -t 2 -a '\"\"' --spec path/to/ ### 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 | +| Option | Alias | Description | Type | Default | +| -------------------- | ----- | ------------------------------------------- | ------- | ------------------------------------------------------------------------ | +| --help | | Show help | | +| --version | | Show version number | | +| --script | -s | Your npm Cypress command (required) | string | +| --args | -a | Your npm Cypress command arguments | string | +| --threads | -t | Number of threads | number | 2 | +| --specsDir | -d | Cypress specs directory | string | 'cypress/e2e' (cy version 10+) or 'cypress/integration' (cy version <10) | +| --spec | | Cypress spec file paths | string | +| --weightsJson | -w | Parallel weights json file | string | 'cypress/parallel-weights.json' | +| --reporter | -r | Reporter to pass to Cypress. | string | +| --reporterOptions | -o | Reporter options | string | +| --reporterModulePath | -n | Specify the reporter module path | string | 'cypress-multi-reporters' | +| --bail | -b | Exit on first failing thread | string | false | +| --verbose | -v | Some additional logging | string | false | +| --strictMode | -m | Add stricter checks after running the tests | boolean | true | **NB**: If you use *cypress-cucumber-preprocesor*, please **disable** the *strictMode* to avoid possible errors: diff --git a/lib/README.md b/lib/README.md index 823a107..35165d3 100644 --- a/lib/README.md +++ b/lib/README.md @@ -23,13 +23,13 @@ Reduce up to 40% your Cypress suite execution time parallelizing the test run on ## Install ``` -npm i cypress-parallel +npm i cypress-parallel -D ``` or ``` -yarn add cypress-parallel +yarn add cypress-parallel -D ``` ## Add a new script @@ -40,7 +40,7 @@ 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 -a '\"\"'" + "cy:parallel" : "cypress-parallel -s cy:run -t 2 -d '' -a '\"\"'" ... } ``` @@ -64,26 +64,33 @@ or Run with npx (no package installation needed) ``` -npx cy:parallel -s cy:run -t 2 -d -a '\"\"' +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 | -| --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 | +| Option | Alias | Description | Type | Default | +| -------------------- | ----- | ------------------------------------------- | ------- | ------------------------------------------------------------------------ | +| --help | | Show help | | +| --version | | Show version number | | +| --script | -s | Your npm Cypress command (required) | string | +| --args | -a | Your npm Cypress command arguments | string | +| --threads | -t | Number of threads | number | 2 | +| --specsDir | -d | Cypress specs directory | string | 'cypress/e2e' (cy version 10+) or 'cypress/integration' (cy version <10) | +| --spec | | Cypress spec file paths | string | +| --weightsJson | -w | Parallel weights json file | string | 'cypress/parallel-weights.json' | +| --reporter | -r | Reporter to pass to Cypress. | string | +| --reporterOptions | -o | Reporter options | string | +| --reporterModulePath | -n | Specify the reporter module path | string | 'cypress-multi-reporters' | +| --bail | -b | Exit on first failing thread | string | false | +| --verbose | -v | Some additional logging | string | false | +| --strictMode | -m | Add stricter checks after running the tests | boolean | true | **NB**: If you use *cypress-cucumber-preprocesor*, please **disable** the *strictMode* to avoid possible errors: @@ -105,10 +112,21 @@ npx cy:parallel -s cy:run -t 2 -d -a '\"= 10 ? 'cypress/e2e' : 'cypress/integration', description: 'Cypress specs directory' }) .option('spec', { type: 'array', + default: undefined, description: 'List of Cypress spec paths' }) .option('args', { @@ -44,6 +53,7 @@ const argv = yargs .option('reporterModulePath', { alias: 'n', type: 'string', + default: 'cypress-multi-reporters', description: 'Reporter module path' }) .option('reporterOptions', { @@ -65,6 +75,7 @@ const argv = yargs .option('weightsJson', { alias: 'w', type: 'string', + default: 'cypress/parallel-weights.json', description: 'Parallel weights json file' }).argv; @@ -83,24 +94,16 @@ const COLORS = [ '\x1b[40m' ]; -const cypressVersion = require('cypress/package.json').version; -const cypressMajorVersion = parseInt(cypressVersion.split('.')[0], 10); - const settings = { - threadCount: argv.threads ? argv.threads : 2, - testSuitesPath: argv.specsDir ? argv.specsDir : - cypressMajorVersion >= 10 ? 'cypress/e2e' : 'cypress/integration', - testSuitesPaths: argv.spec ? argv.spec : undefined, - shouldBail: argv.bail ? argv.bail : false, - isVerbose: argv.verbose ? argv.verbose : false, - weightsJSON: argv.weightsJson - ? argv.weightsJson - : 'cypress/parallel-weights.json', + threadCount: argv.threads, + testSuitesPath: argv.specsDir, + testSuitesPaths: argv.spec, + shouldBail: argv.bail, + isVerbose: argv.verbose, + weightsJSON: argv.weightsJson, defaultWeight: 1, reporter: argv.reporter, - reporterModulePath: argv.reporterModulePath - ? argv.reporterModulePath - : 'cypress-multi-reporters', + reporterModulePath: argv.reporterModulePath, reporterOptions: argv.reporterOptions, reporterOptionsPath: argv.reporterOptionsPath, script: argv.script, From ac65bac858d0b355df153187f0932b1f65d3472c Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Thu, 5 Jun 2025 12:40:02 -0600 Subject: [PATCH 3/3] style: type comment --- lib/settings.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/settings.js b/lib/settings.js index 2ebf49d..b649f54 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -94,6 +94,21 @@ const COLORS = [ '\x1b[40m' ]; +/** @type {{ + threadCount: number + testSuitesPaths: string[] + shouldBail: boolean + isVerbose: boolean + weightsJSON: string + defaultWeight: number + reporter?: string + reporterModulePath: string + reporterOptions?: string + reporterOptionsPath?: string + script: string + strictMode: boolean + scriptArguments: string[] + }} */ const settings = { threadCount: argv.threads, testSuitesPath: argv.specsDir,