Repository navigation
Expand file tree
/
Copy pathvitest.config.packages.ts
More file actions
67 lines (53 loc) · 1.95 KB
/
Copy pathvitest.config.packages.ts
File metadata and controls
67 lines (53 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import path from 'node:path';
import { defineConfig } from 'vitest/config';
const monorepoRoot = import.meta.dirname;
/**
* This configuration is extended by the `vitest.config.ts` configuration in
* each package.
*
* For a detailed explanation of each option, visit:
* https://vitest.dev/config/
*/
export default defineConfig({
resolve: {
// Apply the `paths` option from the package's `tsconfig.json`, which
// resolves `@metamask/*` imports to the uncompiled source of packages that
// live in this repo. Tests therefore need no build step, and the mapping
// lives in one place instead of two.
tsconfigPaths: true,
},
test: {
// Vitest enables watch mode by default. We disable it here, so it can be
// explicitly enabled with `yarn test:watch`.
watch: false,
// The files to include in the test run.
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],
// The setup files shared by every package.
setupFiles: [
path.join(monorepoRoot, 'tests/vitest/setup.ts'),
path.join(monorepoRoot, 'tests/vitest/setup-after-env.ts'),
],
// Reset mocks between tests, so a mocked implementation cannot leak from
// one test into the next.
mockReset: true,
restoreMocks: true,
unstubGlobals: true,
typecheck: {
enabled: true,
},
coverage: {
enabled: true,
// Configure the coverage provider. We use `istanbul` here, because it is
// more stable than `v8`.
provider: 'istanbul',
// The files to include in the coverage report.
include: ['src/**/*.ts'],
// The files to exclude from the coverage report. An index file only
// re-exports, so it has nothing to cover.
exclude: ['src/**/index.ts', 'src/**/*.d.ts'],
// `lcovonly` rather than `lcov`, which also writes a second HTML report.
reporter: ['text', 'html', 'json-summary', 'lcovonly'],
// Each package configures its own thresholds.
},
},
});