-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
46 lines (44 loc) · 1.87 KB
/
vitest.config.ts
File metadata and controls
46 lines (44 loc) · 1.87 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
import { defineConfig, coverageConfigDefaults } from "vitest/config";
import GithubActionsReporter from "vitest-github-actions-reporter";
/* eslint-disable n/no-process-env -- `process` should be available for vite/vitest configs. */
const isCI = !!process.env.CI;
const isGitHubActionWorkflow = !!process.env.GITHUB_ACTIONS;
export default defineConfig({
test: {
/**
* `restoreMocks` accomplishes the following:
* - Removes any mocked implementations (same as mockReset:true).
* - Restores the original implementation so fns don't return undefined like with mockReset.
* - Clears mock-state for spies created "manually" via `vi.spyOn` (same as clearMocks:true).
* > Mock-state is NOT cleared for spies created via *automocking* (`mockReset` does this).
*
* `mockReset` accomplishes the following:
* - Resets mock-state (call counts, arguments, etc.) for all mocks, including automocks.
*/
restoreMocks: true,
mockReset: true,
globals: true,
silent: true,
passWithNoTests: true, // For test-related utils like `src/utils/characters.test.ts`
hideSkippedTests: true,
watch: false,
bail: isCI ? 1 : 0, // If in CI, bail on first test failure, else run all tests
environment: "node",
reporters: [
"default",
// GithubActionsReporter is used to format test results for GitHub Actions
...(isGitHubActionWorkflow ? [new GithubActionsReporter()] : []),
],
coverage: {
include: ["src/**/*.ts"],
exclude: [...coverageConfigDefaults.exclude, "**/index.ts"],
reporter: [
"text", // <-- for console output (even in CI, for logging/debugging purposes)
"lcov", // <-- for uploading coverage info to Codecov
...(isGitHubActionWorkflow
? ["json-summary"] // <-- for the vitest-coverage-report GitHub Action
: []),
],
},
},
});