Skip to content

Commit 317a7cb

Browse files
committed
Reduce duplication between vitest and rollup-tests config files
1 parent 4cd957e commit 317a7cb

File tree

4 files changed

+21
-34
lines changed

4 files changed

+21
-34
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@babel/preset-react": "^7.0.0",
1212
"@babel/preset-typescript": "^7.18.6",
1313
"@hypothesis/frontend-build": "^4.0.0",
14-
"@hypothesis/frontend-testing": "^1.6.0",
14+
"@hypothesis/frontend-testing": "^1.7.1",
1515
"@rollup/plugin-babel": "^6.0.0",
1616
"@rollup/plugin-commonjs": "^28.0.0",
1717
"@rollup/plugin-dynamic-import-vars": "^2.1.2",

rollup-tests.config.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import { vitestCoverageOptions } from '@hypothesis/frontend-testing/vitest';
12
import { babel } from '@rollup/plugin-babel';
23
import commonjs from '@rollup/plugin-commonjs';
34
import { nodeResolve } from '@rollup/plugin-node-resolve';
45
import virtual from '@rollup/plugin-virtual';
56
import { string } from 'rollup-plugin-string';
67

8+
export const excludeFromCoverage = [
9+
'**/node_modules/**',
10+
'**/test/**/*.js',
11+
'**/test-util/**',
12+
'src/components/icons/**/*.ts*',
13+
'src/pattern-library/**/*.js',
14+
'src/pattern-library/**/*.ts*',
15+
];
16+
717
export default {
818
input: 'build/scripts/test-inputs.js', // Input file generated by gulp task
919
output: {
@@ -66,23 +76,8 @@ export default {
6676
[
6777
'babel-plugin-istanbul',
6878
{
69-
// This needs to match the value set in coverage.exclude in vitest.config.js
70-
exclude: [
71-
'**/node_modules/**',
72-
'**/test/**/*.js',
73-
'**/test-util/**',
74-
'src/components/icons/**/*.ts*',
75-
'src/pattern-library/**/*.js',
76-
'src/pattern-library/**/*.ts*',
77-
],
78-
79-
// These two configuration options needed to match the values that
80-
// vitest sets internally, so that they pick the coverage
81-
// instrumentation generated by babel-plugin-istanbul instead of
82-
// trying to generate their own.
83-
// See https://github.com/vitest-dev/vitest/discussions/7841#discussioncomment-12855608
84-
coverageGlobalScope: 'globalThis',
85-
coverageVariable: '__VITEST_COVERAGE__',
79+
...vitestCoverageOptions,
80+
exclude: excludeFromCoverage,
8681
},
8782
],
8883
],

vitest.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { SummaryReporter } from '@hypothesis/frontend-testing/vitest';
22
import { defineConfig } from 'vitest/config';
33

4+
import { excludeFromCoverage } from './rollup-tests.config.js';
5+
46
export default defineConfig({
57
test: {
68
globals: true,
@@ -28,14 +30,7 @@ export default defineConfig({
2830
reportsDirectory: './coverage',
2931
reporter: ['json', 'html'],
3032
include: ['src/**/*.{ts,tsx}'],
31-
exclude: [
32-
'**/node_modules/**',
33-
'**/test/**/*.js',
34-
'**/test-util/**',
35-
'src/components/icons/**/*.ts*',
36-
'src/pattern-library/**/*.js',
37-
'src/pattern-library/**/*.ts*',
38-
],
33+
exclude: excludeFromCoverage,
3934
},
4035
},
4136
});

yarn.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ __metadata:
17921792
"@babel/preset-react": ^7.0.0
17931793
"@babel/preset-typescript": ^7.18.6
17941794
"@hypothesis/frontend-build": ^4.0.0
1795-
"@hypothesis/frontend-testing": ^1.6.0
1795+
"@hypothesis/frontend-testing": ^1.7.1
17961796
"@rollup/plugin-babel": ^6.0.0
17971797
"@rollup/plugin-commonjs": ^28.0.0
17981798
"@rollup/plugin-dynamic-import-vars": ^2.1.2
@@ -1843,19 +1843,16 @@ __metadata:
18431843
languageName: unknown
18441844
linkType: soft
18451845

1846-
"@hypothesis/frontend-testing@npm:^1.6.0":
1847-
version: 1.6.0
1848-
resolution: "@hypothesis/frontend-testing@npm:1.6.0"
1846+
"@hypothesis/frontend-testing@npm:^1.7.1":
1847+
version: 1.7.1
1848+
resolution: "@hypothesis/frontend-testing@npm:1.7.1"
18491849
dependencies:
18501850
axe-core: ^4.8.2
18511851
enzyme: ^3.11.0
18521852
preact: ^10.18.1
18531853
peerDependencies:
18541854
vitest: ^3.1.2
1855-
peerDependenciesMeta:
1856-
vitest:
1857-
optional: true
1858-
checksum: 1ac5404bc658bbf1c71548d39e4703ac65ec822794f0a654122b7c98767f3f5830449466ee4c46695a44bd03a65b35108dddc3d8d7b177eb738b11a34c4f38e7
1855+
checksum: 94c8232c1968797370716e68c922741d5dc301fc7c27980257b5f0662837c00ed9312f32439538d5417ed68e9410096979fab8dd196045668c0d662a843ca6df
18591856
languageName: node
18601857
linkType: hard
18611858

0 commit comments

Comments
 (0)