From 2171307e5ae2e010464eecda0af4b7bb3678bb41 Mon Sep 17 00:00:00 2001 From: Bryan Thomas <49354825+bryanjtc@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:31:05 -0500 Subject: [PATCH 1/3] Fix for #313 --- src/test-storybook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test-storybook.ts b/src/test-storybook.ts index b68566db..cbeebcfb 100644 --- a/src/test-storybook.ts +++ b/src/test-storybook.ts @@ -80,7 +80,7 @@ async function reportCoverage() { const onProcessEnd = () => { cleanup(); - if (process.env.STORYBOOK_COLLECT_COVERAGE !== 'true') { + if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true' && process.env.JEST_SHARD !== 'true') { reportCoverage(); } }; From f7ad6957ea1a0d9962cdbfc3f59dafa1c9226a98 Mon Sep 17 00:00:00 2001 From: Bryan Thomas <49354825+bryanjtc@users.noreply.github.com> Date: Wed, 5 Jul 2023 08:27:00 -0500 Subject: [PATCH 2/3] Refactor: condition for collecting coverage in storybook Move the condition for collecting coverage to only allow it when the environment variable STORYBOOK_COLLECT_COVERAGE is true and JEST_SHARD is not true. --- src/test-storybook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test-storybook.ts b/src/test-storybook.ts index cbeebcfb..529c4525 100644 --- a/src/test-storybook.ts +++ b/src/test-storybook.ts @@ -71,7 +71,7 @@ async function reportCoverage() { // --skip-full in case we only want to show not fully covered code // --check-coverage if we want to break if coverage reaches certain threshold // .nycrc will be respected for thresholds etc. https://www.npmjs.com/package/nyc#coverage-thresholds - if (process.env.JEST_SHARD !== 'true') { + if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true' && process.env.JEST_SHARD !== 'true') { execSync(`npx nyc report --reporter=text -t ${coverageFolder} --report-dir ${coverageFolder}`, { stdio: 'inherit', }); From e7f9b287752bd4e111061ffb46e30b93c8c5659f Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 13 Jul 2023 17:47:26 +0200 Subject: [PATCH 3/3] fix coverage + shard logic --- src/test-storybook.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test-storybook.ts b/src/test-storybook.ts index 529c4525..43bd6e2f 100644 --- a/src/test-storybook.ts +++ b/src/test-storybook.ts @@ -71,7 +71,7 @@ async function reportCoverage() { // --skip-full in case we only want to show not fully covered code // --check-coverage if we want to break if coverage reaches certain threshold // .nycrc will be respected for thresholds etc. https://www.npmjs.com/package/nyc#coverage-thresholds - if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true' && process.env.JEST_SHARD !== 'true') { + if (process.env.JEST_SHARD !== 'true') { execSync(`npx nyc report --reporter=text -t ${coverageFolder} --report-dir ${coverageFolder}`, { stdio: 'inherit', }); @@ -80,7 +80,7 @@ async function reportCoverage() { const onProcessEnd = () => { cleanup(); - if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true' && process.env.JEST_SHARD !== 'true') { + if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true') { reportCoverage(); } };