Skip to content

Commit 7d334c7

Browse files
authored
test(wtr): add coverage reports (#5580)
* test(wtr): add coverage reports * chore(ci): always upload coverage * chore(wtr): lower coverage thresholds * chore(wtr): lower hydration coverage thresholds
1 parent c53bfaf commit 7d334c7

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.github/workflows/web-test-runner.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# - DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE=1
3636
- DISABLE_STATIC_CONTENT_OPTIMIZATION=1
3737
- ENABLE_ARIA_REFLECTION_GLOBAL_POLYFILL=1
38-
- NODE_ENV_FOR_TEST=1
38+
- NODE_ENV_FOR_TEST=production
3939
- API_VERSION=58
4040
- API_VERSION=59
4141
- API_VERSION=60
@@ -95,6 +95,12 @@ jobs:
9595
- name: Run integration tests
9696
run: yarn test
9797

98+
- name: Upload coverage report
99+
# Upload coverage even if the test step failed
100+
if: always()
101+
run: |
102+
[ -f coverage/index.html ] && awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"
103+
98104
hydration-tests:
99105
name: Hydration tests (${{ matrix.engine_server && 'engine-server' || 'SSR v2' }}; ${{ matrix.env || 'default env' }})
100106
runs-on: ubuntu-22.04
@@ -149,3 +155,9 @@ jobs:
149155
150156
- name: Run hydration tests
151157
run: yarn test:hydration
158+
159+
- name: Upload coverage report
160+
# Upload coverage even if the test step failed
161+
if: always()
162+
run: |
163+
[ -f coverage/index.html ] && awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"

packages/@lwc/integration-not-karma/configs/hydration.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ export default {
1414
...baseConfig,
1515
files: ['test-hydration/**/*.spec.js', '!test-hydration/synthetic-shadow/index.spec.js'],
1616
plugins: [...baseConfig.plugins, hydrationTestPlugin],
17+
coverageConfig: {
18+
...baseConfig.coverageConfig,
19+
threshold: {
20+
lines: 60,
21+
statements: 60,
22+
branches: 70,
23+
functions: 55,
24+
},
25+
},
1726
};

packages/@lwc/integration-not-karma/configs/integration.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@ export default {
2020
importMapsPlugin({ inject: { importMap: { imports: { lwc: './mocks/lwc.js' } } } }),
2121
testPlugin,
2222
],
23+
coverageConfig: {
24+
...baseConfig.coverageConfig,
25+
threshold: {
26+
lines: 70,
27+
statements: 70,
28+
branches: 80,
29+
functions: 70,
30+
},
31+
},
2332
};

packages/@lwc/integration-not-karma/configs/shared/base-config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export default (options) => {
4747
// Potential workaround: https://github.com/modernweb-dev/web/issues/2588
4848
concurrency: 1,
4949
concurrentBrowsers: browsers.length,
50+
coverage: options.COVERAGE,
51+
coverageConfig: {
52+
// This is a "magic" path that ultimately points to the lwc packages
53+
include: ['__wds-outside-root__/**'],
54+
// Coverage fails for this file, but it's just the barrel package so we can skip it
55+
exclude: ['__wds-outside-root__/2/lwc/index.js'],
56+
reporters: ['html', 'text'],
57+
},
5058
nodeResolve: true,
5159
rootDir: join(import.meta.dirname, '../..'),
5260
plugins: [

0 commit comments

Comments
 (0)