Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mono-repo support via reporterModulePath option #81

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ npx cy:parallel -s cy:run -t 2 -d <your-cypress-specs-folder> -a '\"<your-cypres

### 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 |
| --reporter | -r | Reporter to pass to Cypress. | string |
| --reporterOptions | -o | Reporter options | 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 |
| -------------------- | ----- | ---------------------------------- | ------ |
| --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 |
| --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:

Expand All @@ -93,6 +94,16 @@ npx cy:parallel -s cy:run -t 2 -d <your-cypress-specs-folder> -a '\"<your-cypres
}
```

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

# Contributors

Looking for contributors.
Expand Down
8 changes: 8 additions & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ const argv = yargs
type: 'string',
description: 'Reporter to pass to Cypress'
})
.option('reporterModulePath', {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the alias please

alias: 'n',
type: 'string',
description: 'Reporter module path'
})
.option('reporterOptions', {
alias: 'o',
type: 'string',
Expand Down Expand Up @@ -76,6 +81,9 @@ const settings = {
weightsJSON: 'cypress/parallel-weights.json',
defaultWeight: 1,
reporter: argv.reporter,
reporterModulePath: argv.reporterModulePath
? argv.reporterModulePath
: 'cypress-multi-reporters',
reporterOptions: argv.reporterOptions,
reporterOptionsPath: argv.reporterOptionsPath,
script: argv.script,
Expand Down
2 changes: 1 addition & 1 deletion lib/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function createCommandArguments(thread) {
createReporterConfigFile(reporterConfigPath);
}

childOptions.push('--reporter', 'cypress-multi-reporters');
childOptions.push('--reporter', settings.reporterModulePath);
childOptions.push('--reporter-options', `configFile=${reporterConfigPath}`);
childOptions.push(...settings.scriptArguments);

Expand Down