-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.js
More file actions
82 lines (72 loc) · 2.59 KB
/
Copy pathvitest.config.js
File metadata and controls
82 lines (72 loc) · 2.59 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/// <reference types="vitest" />
import { defineConfig } from "vitest/config";
import { vitestSetupFilePath, getClarinetVitestsArgv } from "@hirosystems/clarinet-sdk/vitest";
/*
In this file, Vitest is configured so that it works seamlessly with Clarinet and the Simnet.
The `vitest-environment-clarinet` will initialise the clarinet-sdk
and make the `simnet` object available globally in the test files.
`vitestSetupFilePath` points to a file in the `@hirosystems/clarinet-sdk` package that does two things:
- run `before` hooks to initialize the simnet and `after` hooks to collect costs and coverage reports.
- load custom vitest matchers to work with Clarity values (such as `expect(...).toBeUint()`)
The `getClarinetVitestsArgv()` will parse options passed to the command `vitest run --`
- vitest run -- --manifest ./Clarinet.toml # pass a custom path
- vitest run -- --coverage --costs # collect coverage and cost reports
*/
// Centralized pool configuration to maximize worker stability.
// Using 'forks' instead of 'threads' prevents native module isolation issues
// that can lead to 'onTaskUpdate' timeouts during long-running contract tests.
const POOL_CONFIG = {
pool: "forks",
poolOptions: {
forks: {
singleFork: true, // Forces sequential execution to avoid simnet race conditions
isolate: false, // Prevents worker re-initialization overhead
},
},
maxWorkers: 1,
workerIdleTimeout: 60000,
};
// Generous timeout thresholds for heavy Clarity contract simulations.
const TIMEOUT_CONFIG = {
teardownTimeout: 60000,
testTimeout: 120000,
};
export default defineConfig({
test: {
...POOL_CONFIG,
...TIMEOUT_CONFIG,
include: ["tests/**/*.test.ts"],
slowTestThreshold: 5000, // Highlight tests taking longer than 5s
reporters: ['default'],
passWithNoTests: true,
globals: true,
retry: 1, // Add resilience against transient worker communication failures
diff: {
truncateThreshold: 0, // Show full diffs for complex contract responses
},
sequence: {
forceTracing: true, // Improves stack traces on worker hangs
shuffle: false, // Maintain consistent execution order
},
environment: "clarinet",
setupFiles: [
vitestSetupFilePath,
"./tests/setup.ts",
],
environmentOptions: {
clarinet: {
...getClarinetVitestsArgv(),
},
},
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/**',
'tests/**',
'**/*.test.ts',
'vitest.config.js',
],
},
},
});