diff --git a/docusaurus/docs/jest/cookbook.md b/docusaurus/docs/jest/cookbook.md index f207a496..9279061a 100644 --- a/docusaurus/docs/jest/cookbook.md +++ b/docusaurus/docs/jest/cookbook.md @@ -44,13 +44,49 @@ npx knapsack-pro-jest --config=jest.config.e2e.js ## Generate code coverage reports +Each CI node executes multiple batches of tests in Knapsack Pro [Queue Mode](../overview/index.mdx#queue-mode-dynamic-split), and each batch starts a new Jest process. By default, a coverage report generated by each batch overwrites the previous one, which can lead to incomplete coverage data. + +To avoid this, you can configure Knapsack Pro to generate a separate coverage report for each batch by setting the following environment variable: + ```bash export KNAPSACK_PRO_COVERAGE_DIRECTORY=coverage npx knapsack-pro-jest --coverage ``` -Knapsack Pro generates one coverage report for each batch of tests executed on the CI node. To merge the reports you may consider [this script](https://github.com/jestjs/jest/issues/2418#issuecomment-478932514). +This ensures each batch creates a unique subfolder for its coverage report, preventing overwrites: + +``` +coverage + ├── 04c9ea40-4477-11ea-8397-c539e4406df8 + │   ├── clover.xml + │   ├── coverage-final.json + │   ├── lcov-report + │   │   ├── a.js.html + │   │   ├── base.css + │   │   ├── block-navigation.js + │   │   ├── index.html + │   │   ├── prettify.css + │   │   ├── prettify.js + │   │   ├── sort-arrow-sprite.png + │   │   └── sorter.js + │   └── lcov.info + └── 0c584590-4477-11ea-8397-c539e4406df8 + ├── clover.xml + ├── coverage-final.json + ├── lcov-report + │   ├── b.js.html + │   ├── base.css + │   ├── block-navigation.js + │   ├── index.html + │   ├── prettify.css + │   ├── prettify.js + │   ├── sort-arrow-sprite.png + │   └── sorter.js + └── lcov.info +``` + +You can merge the reports with [this script](https://github.com/jestjs/jest/issues/2418#issuecomment-478932514). ## Generate XML reports diff --git a/docusaurus/docs/jest/troubleshooting.md b/docusaurus/docs/jest/troubleshooting.md index 07832dd0..2f13da8d 100644 --- a/docusaurus/docs/jest/troubleshooting.md +++ b/docusaurus/docs/jest/troubleshooting.md @@ -48,3 +48,7 @@ npx knapsack-pro-jest --runInBand ## No tests are executed (or `test_files: [ 'parameter is required' ]`) Make sure [`KNAPSACK_PRO_TEST_FILE_PATTERN`](reference.md#knapsack_pro_test_file_pattern) is correct. + +## Missing Jest coverage data + +See [how to configure Jest code coverage](cookbook.md#generate-code-coverage-reports).