vitest 4.0.17 → 4.1.0-beta.2
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 +36 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
- package/dist/chunks/{base.XJJQZiKB.js → base.DiopZV8F.js} +49 -14
- package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.BoqSLF53.js} +1 -1
- package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.BE4kbYok.d.ts} +4 -1
- package/dist/chunks/{cac.jRCLJDDc.js → cac.C4jjt2RX.js} +816 -14
- package/dist/chunks/{cli-api.Cx2DW4Bc.js → cli-api.ChbI1JU9.js} +412 -166
- package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.Cr1Ep39N.d.ts} +13 -11
- package/dist/chunks/{console.Cf-YriPC.js → console.CNlG1KsP.js} +3 -2
- package/dist/chunks/{constants.D_Q9UYh-.js → constants.B63TT-Bl.js} +1 -1
- package/dist/chunks/coverage.tyqbzn4W.js +1001 -0
- package/dist/chunks/{creator.DAmOKTvJ.js → creator.yyCHuw5R.js} +33 -2
- package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.JeWMqlOm.d.ts} +1 -1
- package/dist/chunks/{globals.DOayXfHP.js → globals.C6Ecf1TO.js} +11 -10
- package/dist/chunks/{index.M8mOzt4Y.js → index.B-iBE_Gx.js} +21 -5
- package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
- package/dist/chunks/{index.6Qv1eEA6.js → index.CAN630q3.js} +20 -8
- package/dist/chunks/{index.C5r1PdPD.js → index.CFulQRmC.js} +1 -1
- package/dist/chunks/{index.Z5E_ObnR.js → index.CouFDptX.js} +4 -2
- package/dist/chunks/{init-forks.BC6ZwHQN.js → init-forks.BnCXPazU.js} +1 -1
- package/dist/chunks/{init-threads.CxSxLC0N.js → init-threads.Cyh2PqXi.js} +1 -1
- package/dist/chunks/{init.C9kljSTm.js → init.B95Mm0Iz.js} +65 -12
- package/dist/chunks/native.mV0-490A.js +148 -0
- package/dist/chunks/nativeModuleMocker.D_q5sFv6.js +206 -0
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
- package/dist/chunks/{node.Ce0vMQM7.js → node.CrSEwhm4.js} +1 -1
- package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.C9o5bttz.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.7faYdkxy.d.ts} +146 -49
- package/dist/chunks/rpc.DcRWTy5G.js +148 -0
- package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.CM7x9-sm.d.ts} +1 -0
- package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.cvFp-ao9.js} +2 -2
- package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.BK-u7y4N.js} +182 -391
- package/dist/chunks/{vi.2VT5v0um.js → test.G82XYNFk.js} +505 -119
- package/dist/chunks/{utils.DvEY5TfP.js → utils.DT4VyRyl.js} +5 -1
- package/dist/chunks/{vm.CMjifoPa.js → vm.BdLtzhnj.js} +15 -11
- package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.CPzI2ZzJ.d.ts} +2 -2
- package/dist/cli.js +4 -3
- package/dist/config.d.ts +11 -11
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +7 -4
- package/dist/environments.js +2 -0
- package/dist/index.d.ts +30 -23
- package/dist/index.js +9 -8
- package/dist/module-evaluator.d.ts +10 -1
- package/dist/module-evaluator.js +1 -5
- package/dist/node.d.ts +13 -12
- package/dist/node.js +27 -25
- package/dist/nodejs-worker-loader.js +41 -0
- package/dist/reporters.d.ts +8 -8
- package/dist/reporters.js +4 -2
- package/dist/runners.d.ts +24 -4
- package/dist/runners.js +6 -6
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +35 -0
- package/dist/snapshot.js +4 -2
- package/dist/suite.js +4 -2
- package/dist/worker.d.ts +8 -7
- package/dist/worker.js +25 -20
- package/dist/workers/forks.js +21 -16
- package/dist/workers/runVmTests.js +11 -13
- package/dist/workers/threads.js +21 -16
- package/dist/workers/vmForks.js +14 -11
- package/dist/workers/vmThreads.js +14 -11
- package/package.json +28 -29
- package/suppress-warnings.cjs +1 -0
- 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
|
@@ -5,7 +5,7 @@ import { detectPackageManager, installPackage } from './index.D3XRDfWc.js';
|
|
|
5
5
|
import { p as prompt, a as any } from './index.D4KonVSU.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
8
|
-
import { c as configFiles } from './constants.
|
|
8
|
+
import { c as configFiles } from './constants.B63TT-Bl.js';
|
|
9
9
|
import 'node:process';
|
|
10
10
|
import 'node:module';
|
|
11
11
|
import 'node:url';
|
|
@@ -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}`)
|
|
@@ -2,7 +2,7 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
|
|
2
2
|
import { Plugin } from '@vitest/pretty-format';
|
|
3
3
|
import { SnapshotState } from '@vitest/snapshot';
|
|
4
4
|
import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
|
|
5
|
-
import { U as UserConsoleLog } from './rpc.d.
|
|
5
|
+
import { U as UserConsoleLog } from './rpc.d.CM7x9-sm.js';
|
|
6
6
|
|
|
7
7
|
interface SnapshotMatcher<T> {
|
|
8
8
|
<U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { g as globalApis } from './constants.
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './
|
|
4
|
-
import '@vitest/expect';
|
|
1
|
+
import { g as globalApis } from './constants.B63TT-Bl.js';
|
|
2
|
+
import { i as index } from './index.CouFDptX.js';
|
|
3
|
+
import './test.G82XYNFk.js';
|
|
5
4
|
import '@vitest/runner';
|
|
6
|
-
import '
|
|
5
|
+
import '@vitest/utils/helpers';
|
|
7
6
|
import '@vitest/utils/timers';
|
|
7
|
+
import './benchmark.BoqSLF53.js';
|
|
8
8
|
import '@vitest/runner/utils';
|
|
9
|
-
import '
|
|
9
|
+
import './utils.DT4VyRyl.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.DcRWTy5G.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
|
|
|
@@ -496,13 +496,23 @@ function countTestErrors(tasks) {
|
|
|
496
496
|
}
|
|
497
497
|
function getStateString$1(tasks, name = "tests", showTotal = true) {
|
|
498
498
|
if (tasks.length === 0) return c.dim(`no ${name}`);
|
|
499
|
-
const passed = tasks.reduce((acc, i) =>
|
|
499
|
+
const passed = tasks.reduce((acc, i) => {
|
|
500
|
+
// Exclude expected failures from passed count
|
|
501
|
+
if (i.result?.state === "pass" && i.type === "test" && i.fails) return acc;
|
|
502
|
+
return i.result?.state === "pass" ? acc + 1 : acc;
|
|
503
|
+
}, 0);
|
|
500
504
|
const failed = tasks.reduce((acc, i) => i.result?.state === "fail" ? acc + 1 : acc, 0);
|
|
501
505
|
const skipped = tasks.reduce((acc, i) => i.mode === "skip" ? acc + 1 : acc, 0);
|
|
502
506
|
const todo = tasks.reduce((acc, i) => i.mode === "todo" ? acc + 1 : acc, 0);
|
|
507
|
+
const expectedFail = tasks.reduce((acc, i) => {
|
|
508
|
+
// Count tests that are marked as .fails and passed (which means they failed as expected)
|
|
509
|
+
if (i.result?.state === "pass" && i.type === "test" && i.fails) return acc + 1;
|
|
510
|
+
return acc;
|
|
511
|
+
}, 0);
|
|
503
512
|
return [
|
|
504
513
|
failed ? c.bold(c.red(`${failed} failed`)) : null,
|
|
505
514
|
passed ? c.bold(c.green(`${passed} passed`)) : null,
|
|
515
|
+
expectedFail ? c.cyan(`${expectedFail} expected fail`) : null,
|
|
506
516
|
skipped ? c.yellow(`${skipped} skipped`) : null,
|
|
507
517
|
todo ? c.gray(`${todo} todo`) : null
|
|
508
518
|
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
@@ -1292,7 +1302,10 @@ class SummaryReporter {
|
|
|
1292
1302
|
stats.tests.delete(test.id);
|
|
1293
1303
|
stats.completed++;
|
|
1294
1304
|
const result = test.result();
|
|
1295
|
-
if (result?.state === "passed")
|
|
1305
|
+
if (result?.state === "passed")
|
|
1306
|
+
// Check if this is an expected failure (test.fails && passed)
|
|
1307
|
+
if (test.options.fails) this.tests.expectedFail++;
|
|
1308
|
+
else this.tests.passed++;
|
|
1296
1309
|
else if (result?.state === "failed") this.tests.failed++;
|
|
1297
1310
|
else if (!result?.state || result?.state === "skipped") this.tests.skipped++;
|
|
1298
1311
|
this.renderer.schedule();
|
|
@@ -1373,6 +1386,7 @@ function emptyCounters() {
|
|
|
1373
1386
|
failed: 0,
|
|
1374
1387
|
skipped: 0,
|
|
1375
1388
|
todo: 0,
|
|
1389
|
+
expectedFail: 0,
|
|
1376
1390
|
total: 0
|
|
1377
1391
|
};
|
|
1378
1392
|
}
|
|
@@ -1380,6 +1394,7 @@ function getStateString(entry) {
|
|
|
1380
1394
|
return [
|
|
1381
1395
|
entry.failed ? c.bold(c.red(`${entry.failed} failed`)) : null,
|
|
1382
1396
|
c.bold(c.green(`${entry.passed} passed`)),
|
|
1397
|
+
entry.expectedFail ? c.cyan(`${entry.expectedFail} expected fail`) : null,
|
|
1383
1398
|
entry.skipped ? c.yellow(`${entry.skipped} skipped`) : null,
|
|
1384
1399
|
entry.todo ? c.gray(`${entry.todo} todo`) : null
|
|
1385
1400
|
].filter(Boolean).join(c.dim(" | ")) + c.gray(` (${entry.total})`);
|
|
@@ -2599,7 +2614,7 @@ async function collectTests(ctx, filepath) {
|
|
|
2599
2614
|
});
|
|
2600
2615
|
calculateSuiteHash(file);
|
|
2601
2616
|
const hasOnly = someTasksAreOnly(file);
|
|
2602
|
-
interpretTaskModes(file, ctx.config.testNamePattern, void 0, hasOnly, false, ctx.config.allowOnly);
|
|
2617
|
+
interpretTaskModes(file, ctx.config.testNamePattern, void 0, void 0, void 0, hasOnly, false, ctx.config.allowOnly);
|
|
2603
2618
|
return {
|
|
2604
2619
|
file,
|
|
2605
2620
|
parsed: request.code,
|
|
@@ -3410,7 +3425,8 @@ class JsonReporter {
|
|
|
3410
3425
|
duration: t.result?.duration,
|
|
3411
3426
|
failureMessages: t.result?.errors?.map((e) => e.stack || e.message) || [],
|
|
3412
3427
|
location: t.location,
|
|
3413
|
-
meta: t.meta
|
|
3428
|
+
meta: t.meta,
|
|
3429
|
+
tags: t.tags || []
|
|
3414
3430
|
};
|
|
3415
3431
|
});
|
|
3416
3432
|
if (tests.some((t) => t.result?.state === "run" || t.result?.state === "queued")) this.ctx.logger.warn("WARNING: Some tests are still running when generating the JSON report.This is likely an internal bug in Vitest.Please report it to https://github.com/vitest-dev/vitest/issues");
|
|
@@ -3677,7 +3693,7 @@ class JUnitReporter {
|
|
|
3677
3693
|
await this.writeElement("testsuite", {
|
|
3678
3694
|
name: filename,
|
|
3679
3695
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3680
|
-
hostname: hostname(),
|
|
3696
|
+
hostname: this.options.hostname || hostname(),
|
|
3681
3697
|
tests: file.tasks.length,
|
|
3682
3698
|
failures: file.stats.failures,
|
|
3683
3699
|
errors: 0,
|