vitest 4.0.16 → 4.1.0-beta.1
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/dist/browser.d.ts +2 -1
- package/dist/browser.js +2 -1
- package/dist/chunks/{base.Bin-9uYm.js → base.CBRNZa3k.js} +8 -7
- package/dist/chunks/{browser.d.Bz3lxTX-.d.ts → browser.d.8hOapKZr.d.ts} +5 -1
- package/dist/chunks/{cac.BGonGPac.js → cac.B1v3xxoC.js} +26 -8
- package/dist/chunks/{cli-api.BKg19Fvw.js → cli-api.B4CqEpI6.js} +225 -110
- package/dist/chunks/{config.d.CzIjkicf.d.ts → config.d.idH22YSr.d.ts} +13 -11
- package/dist/chunks/{console.Cf-YriPC.js → console.uGgdMhyZ.js} +2 -1
- package/dist/chunks/{coverage.BuJUwVtg.js → coverage.BMlOMIWl.js} +18 -4
- package/dist/chunks/{creator.DAmOKTvJ.js → creator.C7WwjkuR.js} +32 -1
- package/dist/chunks/{globals.DOayXfHP.js → globals.DjuGMoMc.js} +10 -9
- package/dist/chunks/{index.Z5E_ObnR.js → index.BEFi2-_3.js} +3 -1
- package/dist/chunks/{index.6Qv1eEA6.js → index.BiOAd_ki.js} +16 -4
- package/dist/chunks/{index.BspFP3mn.js → index.CyBMJtT7.js} +1 -1
- package/dist/chunks/{index.456_DGfR.js → index.Dm4xqZ0s.js} +28 -4
- package/dist/chunks/{index.Drsj_6e7.js → index.DyBZXrH3.js} +1 -1
- package/dist/chunks/{init-forks.v9UONQS6.js → init-forks.CHeQ9Moq.js} +1 -1
- package/dist/chunks/{init-threads.DqYg3Trk.js → init-threads.uZiNAuPk.js} +1 -1
- package/dist/chunks/{init.KmQZdqFg.js → init.DVtKdFty.js} +24 -11
- package/dist/chunks/{plugin.d.v1sC_bv1.d.ts → plugin.d.D8KU2PY_.d.ts} +1 -1
- package/dist/chunks/{reporters.d.Rsi0PyxX.d.ts → reporters.d.Db3MiIWX.d.ts} +51 -22
- package/dist/chunks/rpc.HLmECnw_.js +148 -0
- package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.BcqLPsn5.js} +1 -1
- package/dist/chunks/{startModuleRunner.DpqpB8k3.js → startModuleRunner.C5CcWyXW.js} +23 -23
- package/dist/chunks/{vi.2VT5v0um.js → test.prxIahgM.js} +500 -119
- package/dist/chunks/{traces.U4xDYhzZ.js → traces.CCmnQaNT.js} +46 -1
- package/dist/chunks/{vm.qFl6P1nF.js → vm.CrifS09m.js} +5 -8
- package/dist/chunks/{worker.d.5JNaocaN.d.ts → worker.d.Bji1eq5g.d.ts} +2 -1
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +9 -9
- package/dist/coverage.d.ts +8 -8
- package/dist/coverage.js +3 -1
- package/dist/environments.js +3 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.js +8 -7
- package/dist/module-evaluator.js +2 -6
- package/dist/node.d.ts +14 -11
- package/dist/node.js +20 -20
- package/dist/reporters.d.ts +7 -7
- package/dist/reporters.js +4 -2
- package/dist/runners.d.ts +23 -4
- package/dist/runners.js +4 -4
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +36 -0
- package/dist/snapshot.js +2 -0
- package/dist/suite.js +2 -0
- package/dist/worker.d.ts +4 -3
- package/dist/worker.js +10 -12
- package/dist/workers/forks.js +11 -13
- package/dist/workers/runVmTests.js +10 -12
- package/dist/workers/threads.js +11 -13
- package/dist/workers/vmForks.js +8 -9
- package/dist/workers/vmThreads.js +8 -9
- package/package.json +23 -27
- package/dist/chunks/date.Bq6ZW5rf.js +0 -73
- package/dist/chunks/rpc.BoxB0q7B.js +0 -76
- package/dist/chunks/test.B8ej_ZHS.js +0 -254
- package/dist/mocker.d.ts +0 -1
- package/dist/mocker.js +0 -1
- package/dist/module-runner.js +0 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
2
|
-
import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
2
|
+
import { SequenceHooks, SequenceSetupFiles, SerializableRetry } from '@vitest/runner';
|
|
3
3
|
import { SnapshotUpdateState, SnapshotEnvironment } from '@vitest/snapshot';
|
|
4
4
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
5
5
|
|
|
@@ -30,15 +30,13 @@ interface FakeTimerInstallOpts {
|
|
|
30
30
|
now?: number | Date | undefined;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* An array with names of global methods and APIs to fake.
|
|
34
|
-
* For instance, `
|
|
35
|
-
* @default everything available globally except `nextTick`
|
|
33
|
+
* An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
|
|
34
|
+
* For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
|
|
36
35
|
*/
|
|
37
36
|
toFake?: FakeMethod[] | undefined;
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
|
-
* The maximum number of timers that will be run when calling runAll()
|
|
41
|
-
* @default 10000
|
|
39
|
+
* The maximum number of timers that will be run when calling runAll() (default: 1000)
|
|
42
40
|
*/
|
|
43
41
|
loopLimit?: number | undefined;
|
|
44
42
|
|
|
@@ -55,14 +53,13 @@ interface FakeTimerInstallOpts {
|
|
|
55
53
|
advanceTimeDelta?: number | undefined;
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
|
-
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
|
59
|
-
*
|
|
56
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
|
|
57
|
+
* default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
|
|
60
58
|
*/
|
|
61
59
|
shouldClearNativeTimers?: boolean | undefined;
|
|
62
60
|
|
|
63
61
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @default false
|
|
62
|
+
* Tells FakeTimers to not throw an error when faking a timer that does not exist in the global object. (default: false)
|
|
66
63
|
*/
|
|
67
64
|
ignoreMissingTimers?: boolean | undefined;
|
|
68
65
|
}
|
|
@@ -141,7 +138,7 @@ interface SerializedConfig {
|
|
|
141
138
|
truncateThreshold?: number;
|
|
142
139
|
} | undefined;
|
|
143
140
|
diff: string | SerializedDiffOptions | undefined;
|
|
144
|
-
retry:
|
|
141
|
+
retry: SerializableRetry;
|
|
145
142
|
includeTaskLocation: boolean | undefined;
|
|
146
143
|
inspect: boolean | string | undefined;
|
|
147
144
|
inspectBrk: boolean | string | undefined;
|
|
@@ -183,6 +180,11 @@ interface SerializedConfig {
|
|
|
183
180
|
experimental: {
|
|
184
181
|
fsModuleCache: boolean;
|
|
185
182
|
printImportBreakdown: boolean | undefined;
|
|
183
|
+
openTelemetry: {
|
|
184
|
+
enabled: boolean;
|
|
185
|
+
sdkPath?: string;
|
|
186
|
+
browserSdkPath?: string;
|
|
187
|
+
} | undefined;
|
|
186
188
|
};
|
|
187
189
|
}
|
|
188
190
|
interface SerializedCoverageConfig {
|
|
@@ -3,8 +3,9 @@ import { relative } from 'node:path';
|
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
4
|
import { getSafeTimers } from '@vitest/utils/timers';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { R as RealDate } from './
|
|
6
|
+
import { R as RealDate } from './rpc.HLmECnw_.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.DvEY5TfP.js';
|
|
8
|
+
import './index.Chj8NDwU.js';
|
|
8
9
|
|
|
9
10
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
10
11
|
function getTaskIdByStack(root) {
|
|
@@ -2470,6 +2470,13 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
2470
2470
|
root: viteConfig.root,
|
|
2471
2471
|
mode
|
|
2472
2472
|
};
|
|
2473
|
+
if (resolved.retry && typeof resolved.retry === "object" && typeof resolved.retry.condition === "function") {
|
|
2474
|
+
logger.console.warn(c.yellow("Warning: retry.condition function cannot be used inside a config file. Use a RegExp pattern instead, or define the function in your test file."));
|
|
2475
|
+
resolved.retry = {
|
|
2476
|
+
...resolved.retry,
|
|
2477
|
+
condition: void 0
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2473
2480
|
if (options.pool && typeof options.pool !== "string") {
|
|
2474
2481
|
resolved.pool = options.pool.name;
|
|
2475
2482
|
resolved.poolRunner = options.pool;
|
|
@@ -2798,6 +2805,10 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
2798
2805
|
const sdkPath = resolve(resolved.root, resolved.experimental.openTelemetry.sdkPath);
|
|
2799
2806
|
resolved.experimental.openTelemetry.sdkPath = pathToFileURL$1(sdkPath).toString();
|
|
2800
2807
|
}
|
|
2808
|
+
if (resolved.experimental.openTelemetry?.browserSdkPath) {
|
|
2809
|
+
const browserSdkPath = resolve(resolved.root, resolved.experimental.openTelemetry.browserSdkPath);
|
|
2810
|
+
resolved.experimental.openTelemetry.browserSdkPath = browserSdkPath;
|
|
2811
|
+
}
|
|
2801
2812
|
if (resolved.experimental.fsModuleCachePath) resolved.experimental.fsModuleCachePath = resolve(resolved.root, resolved.experimental.fsModuleCachePath);
|
|
2802
2813
|
return resolved;
|
|
2803
2814
|
}
|
|
@@ -3190,17 +3201,19 @@ Update your dependencies and make sure the versions match.`));
|
|
|
3190
3201
|
const servers = [...ctx.projects.map((project) => ({
|
|
3191
3202
|
root: project.config.root,
|
|
3192
3203
|
isBrowserEnabled: project.isBrowserEnabled(),
|
|
3193
|
-
vite: project.vite
|
|
3204
|
+
vite: project.vite,
|
|
3205
|
+
environment: project.config.environment
|
|
3194
3206
|
})), (
|
|
3195
3207
|
// Check core last as it will match all files anyway
|
|
3196
3208
|
{
|
|
3197
3209
|
root: ctx.config.root,
|
|
3198
3210
|
vite: ctx.vite,
|
|
3199
|
-
isBrowserEnabled: ctx.getRootProject().isBrowserEnabled()
|
|
3211
|
+
isBrowserEnabled: ctx.getRootProject().isBrowserEnabled(),
|
|
3212
|
+
environment: ctx.config.environment
|
|
3200
3213
|
})];
|
|
3201
3214
|
return async function transformFile(filename) {
|
|
3202
3215
|
let lastError;
|
|
3203
|
-
for (const { root, vite, isBrowserEnabled } of servers) {
|
|
3216
|
+
for (const { root, vite, isBrowserEnabled, environment } of servers) {
|
|
3204
3217
|
// On Windows root doesn't start with "/" while filenames do
|
|
3205
3218
|
if (!filename.startsWith(root) && !filename.startsWith(`/${root}`)) continue;
|
|
3206
3219
|
if (isBrowserEnabled) {
|
|
@@ -3208,12 +3221,13 @@ Update your dependencies and make sure the versions match.`));
|
|
|
3208
3221
|
if (result) return result;
|
|
3209
3222
|
}
|
|
3210
3223
|
try {
|
|
3224
|
+
if (environment === "jsdom" || environment === "happy-dom") return await vite.environments.client.transformRequest(filename);
|
|
3211
3225
|
return await vite.environments.ssr.transformRequest(filename);
|
|
3212
3226
|
} catch (error) {
|
|
3213
3227
|
lastError = error;
|
|
3214
3228
|
}
|
|
3215
3229
|
}
|
|
3216
|
-
// All vite
|
|
3230
|
+
// All vite servers failed to transform the file
|
|
3217
3231
|
throw lastError;
|
|
3218
3232
|
};
|
|
3219
3233
|
}
|
|
@@ -226,6 +226,37 @@ import { expect, test } from 'vitest'
|
|
|
226
226
|
import { render } from 'vitest-browser-qwik'
|
|
227
227
|
import HelloWorld from './HelloWorld.tsx'
|
|
228
228
|
|
|
229
|
+
test('renders name', async () => {
|
|
230
|
+
const { getByText } = render(<HelloWorld name="Vitest" />)
|
|
231
|
+
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
|
232
|
+
})
|
|
233
|
+
`
|
|
234
|
+
};
|
|
235
|
+
const preactExample = {
|
|
236
|
+
name: "HelloWorld.jsx",
|
|
237
|
+
js: `
|
|
238
|
+
export default function HelloWorld({ name }) {
|
|
239
|
+
return (
|
|
240
|
+
<div>
|
|
241
|
+
<h1>Hello {name}!</h1>
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
`,
|
|
246
|
+
ts: `
|
|
247
|
+
export default function HelloWorld({ name }: { name: string }) {
|
|
248
|
+
return (
|
|
249
|
+
<div>
|
|
250
|
+
<h1>Hello {name}!</h1>
|
|
251
|
+
</div>
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
`,
|
|
255
|
+
test: `
|
|
256
|
+
import { expect, test } from 'vitest'
|
|
257
|
+
import { render } from 'vitest-browser-preact'
|
|
258
|
+
import HelloWorld from './HelloWorld.<EXT>x'
|
|
259
|
+
|
|
229
260
|
test('renders name', async () => {
|
|
230
261
|
const { getByText } = render(<HelloWorld name="Vitest" />)
|
|
231
262
|
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
|
@@ -276,7 +307,7 @@ function getExampleTest(framework) {
|
|
|
276
307
|
...jsxExample,
|
|
277
308
|
test: jsxExample.test.replace("@testing-library/jsx", `@testing-library/${framework}`)
|
|
278
309
|
};
|
|
279
|
-
case "preact":
|
|
310
|
+
case "preact": return preactExample;
|
|
280
311
|
case "react": return {
|
|
281
312
|
...jsxExample,
|
|
282
313
|
test: jsxExample.test.replace("@testing-library/jsx", `vitest-browser-${framework}`)
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.D_Q9UYh-.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './
|
|
4
|
-
import '@vitest/expect';
|
|
2
|
+
import { i as index } from './index.BEFi2-_3.js';
|
|
3
|
+
import './test.prxIahgM.js';
|
|
5
4
|
import '@vitest/runner';
|
|
6
|
-
import '
|
|
5
|
+
import '@vitest/utils/helpers';
|
|
7
6
|
import '@vitest/utils/timers';
|
|
7
|
+
import './benchmark.B3N2zMcH.js';
|
|
8
8
|
import '@vitest/runner/utils';
|
|
9
|
-
import '
|
|
9
|
+
import './utils.DvEY5TfP.js';
|
|
10
|
+
import '@vitest/expect';
|
|
10
11
|
import '@vitest/utils/error';
|
|
11
|
-
import '
|
|
12
|
+
import 'pathe';
|
|
13
|
+
import '@vitest/snapshot';
|
|
12
14
|
import '@vitest/spy';
|
|
13
15
|
import '@vitest/utils/offset';
|
|
14
16
|
import '@vitest/utils/source-map';
|
|
15
17
|
import './_commonjsHelpers.D26ty3Ew.js';
|
|
16
|
-
import './
|
|
17
|
-
import './
|
|
18
|
+
import './rpc.HLmECnw_.js';
|
|
19
|
+
import './index.Chj8NDwU.js';
|
|
18
20
|
import './evaluatedModules.Dg1zASAC.js';
|
|
19
|
-
import 'pathe';
|
|
20
21
|
import 'vite/module-runner';
|
|
21
22
|
import 'expect-type';
|
|
22
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as NodeBenchmarkRunner, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, b as vitest } from './test.prxIahgM.js';
|
|
2
2
|
import { b as bench } from './benchmark.B3N2zMcH.js';
|
|
3
3
|
import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
|
@@ -9,7 +9,9 @@ const assertType = function assertType() {};
|
|
|
9
9
|
|
|
10
10
|
var index = /*#__PURE__*/Object.freeze({
|
|
11
11
|
__proto__: null,
|
|
12
|
+
BenchmarkRunner: NodeBenchmarkRunner,
|
|
12
13
|
EvaluatedModules: VitestEvaluatedModules,
|
|
14
|
+
TestRunner: TestRunner,
|
|
13
15
|
afterAll: afterAll,
|
|
14
16
|
afterEach: afterEach,
|
|
15
17
|
assert: assert,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { chai } from '@vitest/expect';
|
|
2
|
-
import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.
|
|
3
|
-
import { r as rpc } from './rpc.
|
|
2
|
+
import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.BcqLPsn5.js';
|
|
3
|
+
import { r as rpc } from './rpc.HLmECnw_.js';
|
|
4
4
|
import { g as getWorkerState } from './utils.DvEY5TfP.js';
|
|
5
|
-
import {
|
|
5
|
+
import { T as TestRunner, N as NodeBenchmarkRunner } from './test.prxIahgM.js';
|
|
6
6
|
|
|
7
7
|
function setupChaiConfig(config) {
|
|
8
8
|
Object.assign(chai.config, config);
|
|
@@ -19,7 +19,7 @@ async function resolveSnapshotEnvironment(config, executor) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async function getTestRunnerConstructor(config, moduleRunner) {
|
|
22
|
-
if (!config.runner) return config.mode === "test" ?
|
|
22
|
+
if (!config.runner) return config.mode === "test" ? TestRunner : NodeBenchmarkRunner;
|
|
23
23
|
const mod = await moduleRunner.import(config.runner);
|
|
24
24
|
if (!mod.default && typeof mod.default !== "function") throw new Error(`Runner must export a default function, but got ${typeof mod.default} imported from ${config.runner}`);
|
|
25
25
|
return mod.default;
|
|
@@ -78,6 +78,18 @@ async function resolveTestRunner(config, moduleRunner, traces) {
|
|
|
78
78
|
state.durations.prepare = 0;
|
|
79
79
|
state.durations.environment = 0;
|
|
80
80
|
});
|
|
81
|
+
// Strip function conditions from retry config before sending via RPC
|
|
82
|
+
// Functions cannot be cloned by structured clone algorithm
|
|
83
|
+
const sanitizeRetryConditions = (task) => {
|
|
84
|
+
if (task.retry && typeof task.retry === "object" && typeof task.retry.condition === "function")
|
|
85
|
+
// Remove function condition - it can't be serialized
|
|
86
|
+
task.retry = {
|
|
87
|
+
...task.retry,
|
|
88
|
+
condition: void 0
|
|
89
|
+
};
|
|
90
|
+
if (task.tasks) task.tasks.forEach(sanitizeRetryConditions);
|
|
91
|
+
};
|
|
92
|
+
files.forEach(sanitizeRetryConditions);
|
|
81
93
|
rpc().onCollected(files);
|
|
82
94
|
await originalOnCollected?.call(testRunner, files);
|
|
83
95
|
};
|
|
@@ -603,7 +603,7 @@ function patchAddEventListener(window) {
|
|
|
603
603
|
return abortControllers.get(signal);
|
|
604
604
|
}
|
|
605
605
|
window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
|
|
606
|
-
if (typeof options === "object" && options
|
|
606
|
+
if (typeof options === "object" && options?.signal != null) {
|
|
607
607
|
const { signal, ...otherOptions } = options;
|
|
608
608
|
// - this happens because AbortSignal is provided by Node.js,
|
|
609
609
|
// but jsdom APIs require jsdom's AbortSignal, while Node APIs
|
|
@@ -2599,7 +2599,7 @@ async function collectTests(ctx, filepath) {
|
|
|
2599
2599
|
});
|
|
2600
2600
|
calculateSuiteHash(file);
|
|
2601
2601
|
const hasOnly = someTasksAreOnly(file);
|
|
2602
|
-
interpretTaskModes(file, ctx.config.testNamePattern, void 0, hasOnly, false, ctx.config.allowOnly);
|
|
2602
|
+
interpretTaskModes(file, ctx.config.testNamePattern, void 0, void 0, hasOnly, false, ctx.config.allowOnly);
|
|
2603
2603
|
return {
|
|
2604
2604
|
file,
|
|
2605
2605
|
parsed: request.code,
|
|
@@ -2714,6 +2714,17 @@ class Typechecker {
|
|
|
2714
2714
|
markTasks(file.tasks);
|
|
2715
2715
|
}
|
|
2716
2716
|
async prepareResults(output) {
|
|
2717
|
+
// Detect if tsc output is help text instead of error output
|
|
2718
|
+
// This happens when tsconfig.json is missing and tsc can't find any config
|
|
2719
|
+
if (output.includes("The TypeScript Compiler - Version") || output.includes("COMMON COMMANDS")) {
|
|
2720
|
+
const { typecheck } = this.project.config;
|
|
2721
|
+
const msg = `TypeScript compiler returned help text instead of type checking results.
|
|
2722
|
+
This usually means the tsconfig file was not found.
|
|
2723
|
+
|
|
2724
|
+
Possible solutions:
|
|
2725
|
+
1. Ensure '${typecheck.tsconfig || "tsconfig.json"}' exists in your project root\n 2. If using a custom tsconfig, verify the path in your Vitest config:\n test: { typecheck: { tsconfig: 'path/to/tsconfig.json' } }\n 3. Check that the tsconfig file is valid JSON`;
|
|
2726
|
+
throw new Error(msg);
|
|
2727
|
+
}
|
|
2717
2728
|
const typeErrors = await this.parseTscLikeOutput(output);
|
|
2718
2729
|
const testFiles = new Set(this.getFiles());
|
|
2719
2730
|
if (!this._tests) this._tests = await this.collectTests();
|
|
@@ -2847,6 +2858,7 @@ class Typechecker {
|
|
|
2847
2858
|
reject(/* @__PURE__ */ new Error(`Failed to initialize ${typecheck.checker}. This is a bug in Vitest - please, open an issue with reproduction.`));
|
|
2848
2859
|
return;
|
|
2849
2860
|
}
|
|
2861
|
+
let resolved = false;
|
|
2850
2862
|
child.process.stdout.on("data", (chunk) => {
|
|
2851
2863
|
dataReceived = true;
|
|
2852
2864
|
this._output += chunk;
|
|
@@ -2868,9 +2880,17 @@ class Typechecker {
|
|
|
2868
2880
|
this._output = "";
|
|
2869
2881
|
}
|
|
2870
2882
|
});
|
|
2883
|
+
// Also capture stderr for configuration errors like missing tsconfig
|
|
2884
|
+
child.process.stderr?.on("data", (chunk) => {
|
|
2885
|
+
this._output += chunk;
|
|
2886
|
+
});
|
|
2871
2887
|
const timeout = setTimeout(() => reject(/* @__PURE__ */ new Error(`${typecheck.checker} spawn timed out`)), this.project.config.typecheck.spawnTimeout);
|
|
2888
|
+
let winTimeout;
|
|
2872
2889
|
function onError(cause) {
|
|
2890
|
+
if (resolved) return;
|
|
2873
2891
|
clearTimeout(timeout);
|
|
2892
|
+
clearTimeout(winTimeout);
|
|
2893
|
+
resolved = true;
|
|
2874
2894
|
reject(new Error("Spawning typechecker failed - is typescript installed?", { cause }));
|
|
2875
2895
|
}
|
|
2876
2896
|
child.process.once("spawn", () => {
|
|
@@ -2881,10 +2901,14 @@ class Typechecker {
|
|
|
2881
2901
|
// on Windows, the process might be spawned but fail to start
|
|
2882
2902
|
// we wait for a potential error here. if "close" event didn't trigger,
|
|
2883
2903
|
// we resolve the promise
|
|
2884
|
-
setTimeout(() => {
|
|
2904
|
+
winTimeout = setTimeout(() => {
|
|
2905
|
+
resolved = true;
|
|
2885
2906
|
resolve({ result: child });
|
|
2886
2907
|
}, 200);
|
|
2887
|
-
else
|
|
2908
|
+
else {
|
|
2909
|
+
resolved = true;
|
|
2910
|
+
resolve({ result: child });
|
|
2911
|
+
}
|
|
2888
2912
|
});
|
|
2889
2913
|
if (process.platform === "win32") child.process.once("close", (code) => {
|
|
2890
2914
|
if (code != null && code !== 0 && !dataReceived) onError(/* @__PURE__ */ new Error(`The ${typecheck.checker} command exited with code ${code}.`));
|
|
@@ -3653,7 +3677,7 @@ class JUnitReporter {
|
|
|
3653
3677
|
await this.writeElement("testsuite", {
|
|
3654
3678
|
name: filename,
|
|
3655
3679
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3656
|
-
hostname: hostname(),
|
|
3680
|
+
hostname: this.options.hostname || hostname(),
|
|
3657
3681
|
tests: file.tasks.length,
|
|
3658
3682
|
failures: file.stats.failures,
|
|
3659
3683
|
errors: 0,
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.
|
|
5
|
+
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.Dm4xqZ0s.js';
|
|
6
6
|
import { stripVTControlCharacters } from 'node:util';
|
|
7
7
|
import { notNullish } from '@vitest/utils/helpers';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isMainThread, parentPort } from 'node:worker_threads';
|
|
2
|
-
import { i as init } from './init.
|
|
2
|
+
import { i as init } from './init.DVtKdFty.js';
|
|
3
3
|
|
|
4
4
|
if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
|
|
5
5
|
function workerInit(options) {
|
|
@@ -3,11 +3,11 @@ import { isBuiltin } from 'node:module';
|
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { resolve } from 'pathe';
|
|
5
5
|
import { ModuleRunner } from 'vite/module-runner';
|
|
6
|
-
import { b as VitestTransport } from './startModuleRunner.
|
|
7
|
-
import { e as environments } from './index.
|
|
6
|
+
import { b as VitestTransport } from './startModuleRunner.C5CcWyXW.js';
|
|
7
|
+
import { e as environments } from './index.CyBMJtT7.js';
|
|
8
8
|
import { serializeError } from '@vitest/utils/error';
|
|
9
|
-
import { T as Traces } from './traces.
|
|
10
|
-
import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.
|
|
9
|
+
import { T as Traces } from './traces.CCmnQaNT.js';
|
|
10
|
+
import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.HLmECnw_.js';
|
|
11
11
|
import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
|
|
12
12
|
import { s as setupInspect } from './inspector.CvyFGlXm.js';
|
|
13
13
|
import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
@@ -65,8 +65,22 @@ async function loadEnvironment(name, root, rpc, traces) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
const cleanupListeners = /* @__PURE__ */ new Set();
|
|
69
|
+
const moduleRunnerListeners = /* @__PURE__ */ new Set();
|
|
70
|
+
function onCleanup(cb) {
|
|
71
|
+
cleanupListeners.add(cb);
|
|
72
|
+
}
|
|
73
|
+
async function cleanup() {
|
|
74
|
+
await Promise.all([...cleanupListeners].map((l) => l()));
|
|
75
|
+
}
|
|
76
|
+
function onModuleRunner(cb) {
|
|
77
|
+
moduleRunnerListeners.add(cb);
|
|
78
|
+
}
|
|
79
|
+
function emitModuleRunner(moduleRunner) {
|
|
80
|
+
moduleRunnerListeners.forEach((l) => l(moduleRunner));
|
|
81
|
+
}
|
|
82
|
+
|
|
68
83
|
const resolvingModules = /* @__PURE__ */ new Set();
|
|
69
|
-
const globalListeners = /* @__PURE__ */ new Set();
|
|
70
84
|
async function execute(method, ctx, worker, traces) {
|
|
71
85
|
const prepareStart = performance.now();
|
|
72
86
|
const cleanups = [setupInspect(ctx)];
|
|
@@ -92,7 +106,7 @@ async function execute(method, ctx, worker, traces) {
|
|
|
92
106
|
},
|
|
93
107
|
rpc,
|
|
94
108
|
onCancel,
|
|
95
|
-
onCleanup:
|
|
109
|
+
onCleanup: onCleanup,
|
|
96
110
|
providedContext: ctx.providedContext,
|
|
97
111
|
onFilterStackTrace(stack) {
|
|
98
112
|
return createStackString(parseStacktrace(stack));
|
|
@@ -114,7 +128,7 @@ function collect(ctx, worker, traces) {
|
|
|
114
128
|
return execute("collect", ctx, worker, traces);
|
|
115
129
|
}
|
|
116
130
|
async function teardown() {
|
|
117
|
-
await
|
|
131
|
+
await cleanup();
|
|
118
132
|
}
|
|
119
133
|
const env = process.env;
|
|
120
134
|
function createImportMetaEnvProxy() {
|
|
@@ -146,6 +160,7 @@ let traces;
|
|
|
146
160
|
/** @experimental */
|
|
147
161
|
function init(worker) {
|
|
148
162
|
worker.on(onMessage);
|
|
163
|
+
if (worker.onModuleRunner) onModuleRunner(worker.onModuleRunner);
|
|
149
164
|
let runPromise;
|
|
150
165
|
let isRunning = false;
|
|
151
166
|
let workerTeardown;
|
|
@@ -161,16 +176,14 @@ function init(worker) {
|
|
|
161
176
|
process.env.VITEST_POOL_ID = String(message.poolId);
|
|
162
177
|
process.env.VITEST_WORKER_ID = String(message.workerId);
|
|
163
178
|
reportMemory = message.options.reportMemory;
|
|
164
|
-
const tracesStart = performance.now();
|
|
165
179
|
traces ??= await new Traces({
|
|
166
180
|
enabled: message.traces.enabled,
|
|
167
181
|
sdkPath: message.traces.sdkPath
|
|
168
182
|
}).waitInit();
|
|
169
|
-
const tracesEnd = performance.now();
|
|
170
183
|
const { environment, config, pool } = message.context;
|
|
171
184
|
const context = traces.getContextFromCarrier(message.traces.otelCarrier);
|
|
172
185
|
// record telemetry as part of "start"
|
|
173
|
-
traces.
|
|
186
|
+
traces.recordInitSpan(context);
|
|
174
187
|
try {
|
|
175
188
|
setupContext = {
|
|
176
189
|
environment,
|
|
@@ -318,4 +331,4 @@ function getFilesWithLocations(files) {
|
|
|
318
331
|
});
|
|
319
332
|
}
|
|
320
333
|
|
|
321
|
-
export { init as i, loadEnvironment as l };
|
|
334
|
+
export { emitModuleRunner as e, init as i, loadEnvironment as l };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DevEnvironment } from 'vite';
|
|
2
|
-
import { V as Vitest, T as TestProject,
|
|
2
|
+
import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.Db3MiIWX.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Generate a unique cache identifier.
|