-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.config.ts
More file actions
76 lines (74 loc) 路 2.83 KB
/
Copy pathvitest.config.ts
File metadata and controls
76 lines (74 loc) 路 2.83 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
import { defineConfig } from 'vitest/config';
const targetFiles = [
'src/**/*.test.ts',
'test/shared-worker/**/*.test.ts',
'examples/shared-worker-lobby/src/**/*.test.ts',
];
const toolingFiles = ['scripts/**/*.test.ts'];
export default defineConfig({
test: {
// The application example has its own Node test runner. Keep these projects
// scoped to the existing Vitest suites.
// The dual run, as two projects of one config. `vitest` with no filter runs
// both, so running both is what the tool does rather than a convention a
// contributor has to know, and `--project` picks one when that is wanted.
//
// The target reaches `setup-server` through the environment, and each
// project names it rather than only the mock, so an ambient SMOCKET_TARGET
// in the caller's shell cannot make `--project=real` run the mock under a
// `real` label. Anything other than `mock` is real to the dispatcher, so
// the value here is the label and the switch at once.
projects: [
{
test: {
name: 'real',
include: targetFiles,
// Real-target files each own a live Socket.IO server and exercise teardown
// timing against the host network stack. Serializing files keeps those
// observations independent across slower hosted runners; the mock project
// remains parallel.
fileParallelism: false,
env: { SMOCKET_TARGET: 'real' },
},
},
{
test: {
name: 'mock',
// Tooling tests do not read SMOCKET_TARGET. Run them once instead of
// starting the same npm subprocess fixtures in both projects.
include: [...targetFiles, ...toolingFiles],
env: { SMOCKET_TARGET: 'mock' },
},
},
],
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
// Measure the shipped library only. The test files and the test-only
// helpers (contract, the setup-* files, test-events) are not part of
// smocket.
include: ['src/**/*.ts'],
exclude: [
'src/**/*.test.ts',
'src/**/*.typecheck.ts',
'src/contract.ts',
'src/setup-real-server.ts',
'src/setup-mock-server.ts',
'src/setup-server.ts',
'src/setup-server.browser.ts',
'src/test-events.ts',
],
// Gate on coverage of smocket's own code, which only the mock target
// exercises (the real target runs socket.io, not this source), so the
// `coverage` script runs the mock target. The floors sit a little under
// the current numbers so a normal change does not trip them, while a real
// drop still fails the run rather than only reporting it.
thresholds: {
statements: 90,
branches: 82,
functions: 82,
lines: 92,
},
},
},
});