Skip to content

Commit

Permalink
fix: prefix coverage environment variable with storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jun 13, 2022
1 parent 902dd7d commit 01a9e79
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ jobs:

## Setting up code coverage

The test runner supports code coverage with the `--coverage` flag or `COLLECT_COVERAGE` environment variable. The pre-requisite is that your components are instrumented using [istanbul](https://istanbul.js.org/).
The test runner supports code coverage with the `--coverage` flag or `STORYBOOK_COLLECT_COVERAGE` environment variable. The pre-requisite is that your components are instrumented using [istanbul](https://istanbul.js.org/).

### Instrument the code

Expand Down
4 changes: 2 additions & 2 deletions bin/test-storybook.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const main = async () => {
process.env.TARGET_URL = targetURL;

if (runnerOptions.coverage) {
process.env.COLLECT_COVERAGE = 'true';
process.env.STORYBOOK_COLLECT_COVERAGE = 'true';
}

if (process.env.REFERENCE_URL) {
Expand Down Expand Up @@ -212,7 +212,7 @@ const main = async () => {

await executeJestPlaywright(jestOptions);

if (process.env.COLLECT_COVERAGE === 'true') {
if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true') {
printCoverageReport();
}
};
Expand Down
2 changes: 1 addition & 1 deletion playwright/jest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if (testRunnerConfig) {
}
}

global.__sbCollectCoverage = process.env.COLLECT_COVERAGE === 'true'
global.__sbCollectCoverage = process.env.STORYBOOK_COLLECT_COVERAGE === 'true'
11 changes: 8 additions & 3 deletions src/config/jest-playwright.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
export const getJestConfig = () => {
const { TEST_ROOT, TEST_MATCH, STORYBOOK_STORIES_PATTERN, TEST_BROWSERS, COLLECT_COVERAGE } =
process.env;
const {
TEST_ROOT,
TEST_MATCH,
STORYBOOK_STORIES_PATTERN,
TEST_BROWSERS,
STORYBOOK_COLLECT_COVERAGE,
} = process.env;

let config = {
rootDir: process.cwd(),
Expand All @@ -21,7 +26,7 @@ export const getJestConfig = () => {
browsers: TEST_BROWSERS.split(',')
.map((p) => p.trim().toLowerCase())
.filter(Boolean),
collectCoverage: COLLECT_COVERAGE === 'true',
collectCoverage: STORYBOOK_COLLECT_COVERAGE === 'true',
},
},
watchPlugins: [
Expand Down

0 comments on commit 01a9e79

Please sign in to comment.