@depup/vitest 4.0.18-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +691 -0
- package/README.md +7 -0
- package/browser/context.d.ts +7 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13657 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +20 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +224 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
2
|
+
import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
3
|
+
import { SnapshotUpdateState, SnapshotEnvironment } from '@vitest/snapshot';
|
|
4
|
+
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Names of clock methods that may be faked by install.
|
|
8
|
+
*/
|
|
9
|
+
type FakeMethod =
|
|
10
|
+
| "setTimeout"
|
|
11
|
+
| "clearTimeout"
|
|
12
|
+
| "setImmediate"
|
|
13
|
+
| "clearImmediate"
|
|
14
|
+
| "setInterval"
|
|
15
|
+
| "clearInterval"
|
|
16
|
+
| "Date"
|
|
17
|
+
| "nextTick"
|
|
18
|
+
| "hrtime"
|
|
19
|
+
| "requestAnimationFrame"
|
|
20
|
+
| "cancelAnimationFrame"
|
|
21
|
+
| "requestIdleCallback"
|
|
22
|
+
| "cancelIdleCallback"
|
|
23
|
+
| "performance"
|
|
24
|
+
| "queueMicrotask";
|
|
25
|
+
|
|
26
|
+
interface FakeTimerInstallOpts {
|
|
27
|
+
/**
|
|
28
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
29
|
+
*/
|
|
30
|
+
now?: number | Date | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An array with names of global methods and APIs to fake.
|
|
34
|
+
* For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
|
|
35
|
+
* @default everything available globally except `nextTick`
|
|
36
|
+
*/
|
|
37
|
+
toFake?: FakeMethod[] | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The maximum number of timers that will be run when calling runAll()
|
|
41
|
+
* @default 10000
|
|
42
|
+
*/
|
|
43
|
+
loopLimit?: number | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
|
47
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
48
|
+
*/
|
|
49
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
53
|
+
* in the real system time (default: 20)
|
|
54
|
+
*/
|
|
55
|
+
advanceTimeDelta?: number | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Don't throw error when asked to fake timers that are not present.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
ignoreMissingTimers?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Config that tests have access to.
|
|
72
|
+
*/
|
|
73
|
+
interface SerializedConfig {
|
|
74
|
+
name: string | undefined;
|
|
75
|
+
globals: boolean;
|
|
76
|
+
base: string | undefined;
|
|
77
|
+
snapshotEnvironment?: string;
|
|
78
|
+
disableConsoleIntercept: boolean | undefined;
|
|
79
|
+
runner: string | undefined;
|
|
80
|
+
isolate: boolean;
|
|
81
|
+
maxWorkers: number;
|
|
82
|
+
mode: "test" | "benchmark";
|
|
83
|
+
bail: number | undefined;
|
|
84
|
+
environmentOptions?: Record<string, any>;
|
|
85
|
+
root: string;
|
|
86
|
+
setupFiles: string[];
|
|
87
|
+
passWithNoTests: boolean;
|
|
88
|
+
testNamePattern: RegExp | undefined;
|
|
89
|
+
allowOnly: boolean;
|
|
90
|
+
testTimeout: number;
|
|
91
|
+
hookTimeout: number;
|
|
92
|
+
clearMocks: boolean;
|
|
93
|
+
mockReset: boolean;
|
|
94
|
+
restoreMocks: boolean;
|
|
95
|
+
unstubGlobals: boolean;
|
|
96
|
+
unstubEnvs: boolean;
|
|
97
|
+
fakeTimers: FakeTimerInstallOpts;
|
|
98
|
+
maxConcurrency: number;
|
|
99
|
+
defines: Record<string, any>;
|
|
100
|
+
expect: {
|
|
101
|
+
requireAssertions?: boolean;
|
|
102
|
+
poll?: {
|
|
103
|
+
timeout?: number;
|
|
104
|
+
interval?: number;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
printConsoleTrace: boolean | undefined;
|
|
108
|
+
sequence: {
|
|
109
|
+
shuffle?: boolean;
|
|
110
|
+
concurrent?: boolean;
|
|
111
|
+
seed: number;
|
|
112
|
+
hooks: SequenceHooks;
|
|
113
|
+
setupFiles: SequenceSetupFiles;
|
|
114
|
+
};
|
|
115
|
+
deps: {
|
|
116
|
+
web: {
|
|
117
|
+
transformAssets?: boolean;
|
|
118
|
+
transformCss?: boolean;
|
|
119
|
+
transformGlobPattern?: RegExp | RegExp[];
|
|
120
|
+
};
|
|
121
|
+
optimizer: Record<string, {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
}>;
|
|
124
|
+
interopDefault: boolean | undefined;
|
|
125
|
+
moduleDirectories: string[] | undefined;
|
|
126
|
+
};
|
|
127
|
+
snapshotOptions: {
|
|
128
|
+
updateSnapshot: SnapshotUpdateState;
|
|
129
|
+
expand: boolean | undefined;
|
|
130
|
+
snapshotFormat: PrettyFormatOptions | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* only exists for tests, not available in the main process
|
|
133
|
+
*/
|
|
134
|
+
snapshotEnvironment: SnapshotEnvironment;
|
|
135
|
+
};
|
|
136
|
+
pool: string;
|
|
137
|
+
snapshotSerializers: string[];
|
|
138
|
+
chaiConfig: {
|
|
139
|
+
includeStack?: boolean;
|
|
140
|
+
showDiff?: boolean;
|
|
141
|
+
truncateThreshold?: number;
|
|
142
|
+
} | undefined;
|
|
143
|
+
diff: string | SerializedDiffOptions | undefined;
|
|
144
|
+
retry: number;
|
|
145
|
+
includeTaskLocation: boolean | undefined;
|
|
146
|
+
inspect: boolean | string | undefined;
|
|
147
|
+
inspectBrk: boolean | string | undefined;
|
|
148
|
+
inspector: {
|
|
149
|
+
enabled?: boolean;
|
|
150
|
+
port?: number;
|
|
151
|
+
host?: string;
|
|
152
|
+
waitForDebugger?: boolean;
|
|
153
|
+
};
|
|
154
|
+
watch: boolean;
|
|
155
|
+
env: Record<string, any>;
|
|
156
|
+
browser: {
|
|
157
|
+
name: string;
|
|
158
|
+
headless: boolean;
|
|
159
|
+
isolate: boolean;
|
|
160
|
+
fileParallelism: boolean;
|
|
161
|
+
ui: boolean;
|
|
162
|
+
viewport: {
|
|
163
|
+
width: number;
|
|
164
|
+
height: number;
|
|
165
|
+
};
|
|
166
|
+
locators: {
|
|
167
|
+
testIdAttribute: string;
|
|
168
|
+
};
|
|
169
|
+
screenshotFailures: boolean;
|
|
170
|
+
providerOptions: {
|
|
171
|
+
actionTimeout?: number;
|
|
172
|
+
};
|
|
173
|
+
trace: BrowserTraceViewMode;
|
|
174
|
+
trackUnhandledErrors: boolean;
|
|
175
|
+
};
|
|
176
|
+
standalone: boolean;
|
|
177
|
+
logHeapUsage: boolean | undefined;
|
|
178
|
+
coverage: SerializedCoverageConfig;
|
|
179
|
+
benchmark: {
|
|
180
|
+
includeSamples: boolean;
|
|
181
|
+
} | undefined;
|
|
182
|
+
serializedDefines: string;
|
|
183
|
+
experimental: {
|
|
184
|
+
fsModuleCache: boolean;
|
|
185
|
+
printImportBreakdown: boolean | undefined;
|
|
186
|
+
openTelemetry: {
|
|
187
|
+
enabled: boolean;
|
|
188
|
+
sdkPath?: string;
|
|
189
|
+
browserSdkPath?: string;
|
|
190
|
+
} | undefined;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
interface SerializedCoverageConfig {
|
|
194
|
+
provider: "istanbul" | "v8" | "custom" | undefined;
|
|
195
|
+
reportsDirectory: string;
|
|
196
|
+
htmlReporter: {
|
|
197
|
+
subdir: string | undefined;
|
|
198
|
+
} | undefined;
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
customProviderModule: string | undefined;
|
|
201
|
+
}
|
|
202
|
+
type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookTimeout" | "clearMocks" | "mockReset" | "restoreMocks" | "fakeTimers" | "maxConcurrency" | "expect" | "printConsoleTrace"> & {
|
|
203
|
+
sequence?: {
|
|
204
|
+
hooks?: SequenceHooks;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
208
|
+
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
209
|
+
|
|
210
|
+
export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedConfig as S, SerializedCoverageConfig as a, RuntimeConfig as b };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Console } from 'node:console';
|
|
2
|
+
import { relative } from 'node:path';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
4
|
+
import { getSafeTimers } from '@vitest/utils/timers';
|
|
5
|
+
import c from 'tinyrainbow';
|
|
6
|
+
import { R as RealDate } from './date.Bq6ZW5rf.js';
|
|
7
|
+
import { g as getWorkerState } from './utils.DvEY5TfP.js';
|
|
8
|
+
|
|
9
|
+
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
10
|
+
function getTaskIdByStack(root) {
|
|
11
|
+
const stack = (/* @__PURE__ */ new Error("STACK_TRACE_ERROR")).stack?.split("\n");
|
|
12
|
+
if (!stack) return UNKNOWN_TEST_ID;
|
|
13
|
+
const index = stack.findIndex((line) => line.includes("at Console.value"));
|
|
14
|
+
const line = index === -1 ? null : stack[index + 2];
|
|
15
|
+
if (!line) return UNKNOWN_TEST_ID;
|
|
16
|
+
const filepath = line.match(/at\s(.*)\s?/)?.[1];
|
|
17
|
+
if (filepath) return relative(root, filepath);
|
|
18
|
+
return UNKNOWN_TEST_ID;
|
|
19
|
+
}
|
|
20
|
+
function createCustomConsole(defaultState) {
|
|
21
|
+
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
22
|
+
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
23
|
+
const timers = /* @__PURE__ */ new Map();
|
|
24
|
+
const { queueMicrotask } = getSafeTimers();
|
|
25
|
+
function queueCancelableMicrotask(callback) {
|
|
26
|
+
let canceled = false;
|
|
27
|
+
queueMicrotask(() => {
|
|
28
|
+
if (!canceled) callback();
|
|
29
|
+
});
|
|
30
|
+
return () => {
|
|
31
|
+
canceled = true;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const state = () => defaultState || getWorkerState();
|
|
35
|
+
// group sync console.log calls with micro task
|
|
36
|
+
function schedule(taskId) {
|
|
37
|
+
const timer = timers.get(taskId);
|
|
38
|
+
const { stdoutTime, stderrTime } = timer;
|
|
39
|
+
timer.cancel?.();
|
|
40
|
+
timer.cancel = queueCancelableMicrotask(() => {
|
|
41
|
+
if (stderrTime < stdoutTime) {
|
|
42
|
+
sendStderr(taskId);
|
|
43
|
+
sendStdout(taskId);
|
|
44
|
+
} else {
|
|
45
|
+
sendStdout(taskId);
|
|
46
|
+
sendStderr(taskId);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function sendStdout(taskId) {
|
|
51
|
+
sendBuffer("stdout", taskId);
|
|
52
|
+
}
|
|
53
|
+
function sendStderr(taskId) {
|
|
54
|
+
sendBuffer("stderr", taskId);
|
|
55
|
+
}
|
|
56
|
+
function sendBuffer(type, taskId) {
|
|
57
|
+
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer;
|
|
58
|
+
const buffer = buffers.get(taskId);
|
|
59
|
+
if (!buffer) return;
|
|
60
|
+
if (state().config.printConsoleTrace) buffer.forEach(([buffer, origin]) => {
|
|
61
|
+
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
|
62
|
+
});
|
|
63
|
+
else sendLog(type, taskId, buffer.map((i) => String(i[0])).join(""), buffer.length);
|
|
64
|
+
const timer = timers.get(taskId);
|
|
65
|
+
buffers.delete(taskId);
|
|
66
|
+
if (type === "stderr") timer.stderrTime = 0;
|
|
67
|
+
else timer.stdoutTime = 0;
|
|
68
|
+
}
|
|
69
|
+
function sendLog(type, taskId, content, size, origin) {
|
|
70
|
+
const timer = timers.get(taskId);
|
|
71
|
+
const time = type === "stderr" ? timer.stderrTime : timer.stdoutTime;
|
|
72
|
+
state().rpc.onUserConsoleLog({
|
|
73
|
+
type,
|
|
74
|
+
content: content || "<empty line>",
|
|
75
|
+
taskId,
|
|
76
|
+
time: time || RealDate.now(),
|
|
77
|
+
size,
|
|
78
|
+
origin
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return new Console({
|
|
82
|
+
stdout: new Writable({ write(data, encoding, callback) {
|
|
83
|
+
const s = state();
|
|
84
|
+
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
85
|
+
let timer = timers.get(id);
|
|
86
|
+
if (timer) timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
87
|
+
else {
|
|
88
|
+
timer = {
|
|
89
|
+
stdoutTime: RealDate.now(),
|
|
90
|
+
stderrTime: RealDate.now()
|
|
91
|
+
};
|
|
92
|
+
timers.set(id, timer);
|
|
93
|
+
}
|
|
94
|
+
let buffer = stdoutBuffer.get(id);
|
|
95
|
+
if (!buffer) {
|
|
96
|
+
buffer = [];
|
|
97
|
+
stdoutBuffer.set(id, buffer);
|
|
98
|
+
}
|
|
99
|
+
if (state().config.printConsoleTrace) {
|
|
100
|
+
const limit = Error.stackTraceLimit;
|
|
101
|
+
Error.stackTraceLimit = limit + 6;
|
|
102
|
+
const trace = (/* @__PURE__ */ new Error("STACK_TRACE")).stack?.split("\n").slice(7).join("\n");
|
|
103
|
+
Error.stackTraceLimit = limit;
|
|
104
|
+
buffer.push([data, trace]);
|
|
105
|
+
} else buffer.push([data, void 0]);
|
|
106
|
+
schedule(id);
|
|
107
|
+
callback();
|
|
108
|
+
} }),
|
|
109
|
+
stderr: new Writable({ write(data, encoding, callback) {
|
|
110
|
+
const s = state();
|
|
111
|
+
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
112
|
+
let timer = timers.get(id);
|
|
113
|
+
if (timer) timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
114
|
+
else {
|
|
115
|
+
timer = {
|
|
116
|
+
stderrTime: RealDate.now(),
|
|
117
|
+
stdoutTime: RealDate.now()
|
|
118
|
+
};
|
|
119
|
+
timers.set(id, timer);
|
|
120
|
+
}
|
|
121
|
+
let buffer = stderrBuffer.get(id);
|
|
122
|
+
if (!buffer) {
|
|
123
|
+
buffer = [];
|
|
124
|
+
stderrBuffer.set(id, buffer);
|
|
125
|
+
}
|
|
126
|
+
if (state().config.printConsoleTrace) {
|
|
127
|
+
const limit = Error.stackTraceLimit;
|
|
128
|
+
Error.stackTraceLimit = limit + 6;
|
|
129
|
+
const stack = (/* @__PURE__ */ new Error("STACK_TRACE")).stack?.split("\n");
|
|
130
|
+
Error.stackTraceLimit = limit;
|
|
131
|
+
if (stack?.some((line) => line.includes("at Console.trace"))) buffer.push([data, void 0]);
|
|
132
|
+
else {
|
|
133
|
+
const trace = stack?.slice(7).join("\n");
|
|
134
|
+
Error.stackTraceLimit = limit;
|
|
135
|
+
buffer.push([data, trace]);
|
|
136
|
+
}
|
|
137
|
+
} else buffer.push([data, void 0]);
|
|
138
|
+
schedule(id);
|
|
139
|
+
callback();
|
|
140
|
+
} }),
|
|
141
|
+
colorMode: c.isColorSupported,
|
|
142
|
+
groupIndentation: 2
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { UNKNOWN_TEST_ID, createCustomConsole };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// if changed, update also jsdocs and docs
|
|
2
|
+
const defaultPort = 51204;
|
|
3
|
+
const defaultBrowserPort = 63315;
|
|
4
|
+
const defaultInspectPort = 9229;
|
|
5
|
+
const API_PATH = "/__vitest_api__";
|
|
6
|
+
const CONFIG_NAMES = ["vitest.config", "vite.config"];
|
|
7
|
+
const CONFIG_EXTENSIONS = [
|
|
8
|
+
".ts",
|
|
9
|
+
".mts",
|
|
10
|
+
".cts",
|
|
11
|
+
".js",
|
|
12
|
+
".mjs",
|
|
13
|
+
".cjs"
|
|
14
|
+
];
|
|
15
|
+
const configFiles = CONFIG_NAMES.flatMap((name) => CONFIG_EXTENSIONS.map((ext) => name + ext));
|
|
16
|
+
const globalApis = [
|
|
17
|
+
"suite",
|
|
18
|
+
"test",
|
|
19
|
+
"describe",
|
|
20
|
+
"it",
|
|
21
|
+
"chai",
|
|
22
|
+
"expect",
|
|
23
|
+
"assert",
|
|
24
|
+
"expectTypeOf",
|
|
25
|
+
"assertType",
|
|
26
|
+
"vitest",
|
|
27
|
+
"vi",
|
|
28
|
+
"beforeAll",
|
|
29
|
+
"afterAll",
|
|
30
|
+
"beforeEach",
|
|
31
|
+
"afterEach",
|
|
32
|
+
"onTestFinished",
|
|
33
|
+
"onTestFailed"
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export { API_PATH as A, defaultPort as a, defaultInspectPort as b, configFiles as c, defaultBrowserPort as d, globalApis as g };
|