vitest 4.0.0-beta.1 → 4.0.0-beta.10
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 +2 -2
- package/dist/browser.d.ts +13 -14
- package/dist/browser.js +6 -5
- package/dist/chunks/base.Cjha6usc.js +129 -0
- package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CJUa-Hsa.js} +6 -8
- package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
- package/dist/chunks/{browser.d.q8Z0P0q1.d.ts → browser.d.yFAklsD1.d.ts} +5 -5
- package/dist/chunks/{cac.D3EzDDZd.js → cac.DCxo_nSu.js} +70 -152
- package/dist/chunks/{cli-api.Dn5gKePv.js → cli-api.BJJXh9BV.js} +1330 -1677
- package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.B_LthbQq.d.ts} +58 -63
- package/dist/chunks/{console.CtFJOzRO.js → console.7h5kHUIf.js} +34 -70
- package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
- package/dist/chunks/{coverage.Cwa-XhJt.js → coverage.BCU-r2QL.js} +515 -781
- package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
- package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
- package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
- package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
- package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.BsToaxti.d.ts} +27 -6
- package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
- package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.BK3X7FW1.d.ts} +2 -5
- package/dist/chunks/{globals.Cxal6MLI.js → globals.DG-S3xFe.js} +8 -8
- package/dist/chunks/{index.CZI_8rVt.js → index.BIP7prJq.js} +289 -608
- package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
- package/dist/chunks/{index.TfbsX-3I.js → index.BjKEiSn0.js} +14 -24
- package/dist/chunks/{index.BWf_gE5n.js → index.CMfqw92x.js} +7 -6
- package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
- package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
- package/dist/chunks/moduleRunner.d.D9nBoC4p.d.ts +201 -0
- package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
- package/dist/chunks/{node.fjCdwEIl.js → node.CyipiPvJ.js} +1 -1
- package/dist/chunks/{plugin.d.C2EcJUjo.d.ts → plugin.d.BMVSnsGV.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DxZg19fy.d.ts → reporters.d.BUWjmRYq.d.ts} +1226 -1291
- package/dist/chunks/resolveSnapshotEnvironment.Bkht6Yor.js +81 -0
- package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
- package/dist/chunks/rpc.BKr6mtxz.js +65 -0
- package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.uiMcU3cv.js} +17 -29
- package/dist/chunks/startModuleRunner.p67gbNo9.js +665 -0
- package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
- package/dist/chunks/test.BiqSKISg.js +214 -0
- package/dist/chunks/{typechecker.CVytUJuF.js → typechecker.DB-fIMaH.js} +144 -213
- package/dist/chunks/{utils.CAioKnHs.js → utils.C2YI6McM.js} +5 -14
- package/dist/chunks/{utils.XdZDrNZV.js → utils.D2R2NiOH.js} +8 -27
- package/dist/chunks/{vi.bdSIJ99Y.js → vi.ZPgvtBao.js} +156 -305
- package/dist/chunks/{vm.BThCzidc.js → vm.Ca0Y0W5f.js} +116 -226
- package/dist/chunks/{worker.d.DoNjFAiv.d.ts → worker.d.BDsXGkwh.d.ts} +28 -22
- package/dist/chunks/{worker.d.CmvJfRGs.d.ts → worker.d.BNcX_2mH.d.ts} +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +3 -9
- package/dist/config.d.ts +49 -54
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +27 -26
- package/dist/coverage.js +6 -7
- package/dist/environments.d.ts +9 -13
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +38 -45
- package/dist/index.js +7 -9
- package/dist/module-evaluator.d.ts +13 -0
- package/dist/module-evaluator.js +276 -0
- package/dist/module-runner.js +15 -0
- package/dist/node.d.ts +40 -41
- package/dist/node.js +23 -33
- package/dist/reporters.d.ts +12 -13
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +13 -232
- package/dist/snapshot.js +2 -2
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +90 -47
- package/dist/workers/forks.js +34 -10
- package/dist/workers/runVmTests.js +36 -56
- package/dist/workers/threads.js +34 -10
- package/dist/workers/vmForks.js +11 -10
- package/dist/workers/vmThreads.js +11 -10
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +35 -17
- package/globals.d.ts +17 -17
- package/package.json +32 -31
- package/dist/chunks/base.Bj3pWTr1.js +0 -38
- package/dist/chunks/execute.B7h3T_Hc.js +0 -708
- package/dist/chunks/index.D-VkfKhf.js +0 -105
- package/dist/chunks/rpc.CsFtxqeq.js +0 -83
- package/dist/chunks/runBaseTests.BC7ZIH5L.js +0 -129
- package/dist/execute.d.ts +0 -148
- package/dist/execute.js +0 -13
package/LICENSE.md
CHANGED
|
@@ -3,7 +3,7 @@ Vitest is released under the MIT license:
|
|
|
3
3
|
|
|
4
4
|
MIT License
|
|
5
5
|
|
|
6
|
-
Copyright (c) 2021-Present Vitest
|
|
6
|
+
Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
|
|
7
7
|
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
9
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -329,7 +329,7 @@ Repository: lukeed/kleur
|
|
|
329
329
|
## local-pkg
|
|
330
330
|
License: MIT
|
|
331
331
|
By: Anthony Fu
|
|
332
|
-
Repository: git+https://github.com/antfu/local-pkg.git
|
|
332
|
+
Repository: git+https://github.com/antfu-collective/local-pkg.git
|
|
333
333
|
|
|
334
334
|
> MIT License
|
|
335
335
|
>
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.
|
|
2
|
-
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.
|
|
1
|
+
import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.B_LthbQq.js';
|
|
2
|
+
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
|
-
import {
|
|
4
|
+
import { V as VitestModuleRunner } from './chunks/moduleRunner.d.D9nBoC4p.js';
|
|
5
5
|
export { collectTests, processError, startTests } from '@vitest/runner';
|
|
6
|
-
import * as
|
|
7
|
-
export {
|
|
8
|
-
export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, inspect, stringify } from '@vitest/utils';
|
|
6
|
+
import * as _vitest_spy from '@vitest/spy';
|
|
7
|
+
export { _vitest_spy as SpyModule };
|
|
8
|
+
export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, getType, inspect, stringify } from '@vitest/utils';
|
|
9
9
|
export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
|
|
10
10
|
import '@vitest/pretty-format';
|
|
11
11
|
import '@vitest/snapshot';
|
|
12
|
-
import 'vite-node/client';
|
|
13
|
-
import 'vite-node';
|
|
14
|
-
import './chunks/worker.d.DoNjFAiv.js';
|
|
15
|
-
import './chunks/environment.d.CUq4cUgQ.js';
|
|
16
12
|
import 'node:vm';
|
|
13
|
+
import 'vite/module-runner';
|
|
14
|
+
import './chunks/worker.d.BDsXGkwh.js';
|
|
15
|
+
import './chunks/environment.d.BsToaxti.js';
|
|
17
16
|
import '@vitest/mocker';
|
|
18
17
|
import './chunks/mocker.d.BE_2ls6u.js';
|
|
19
18
|
|
|
20
19
|
declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
|
|
21
|
-
isolate: boolean
|
|
20
|
+
isolate: boolean;
|
|
22
21
|
}): Promise<unknown>;
|
|
23
22
|
declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader): Promise<unknown>;
|
|
24
23
|
declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
|
|
25
|
-
isolate: boolean
|
|
24
|
+
isolate: boolean;
|
|
26
25
|
}): Promise<unknown>;
|
|
27
26
|
|
|
28
27
|
declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
|
|
29
|
-
declare function loadDiffConfig(config: SerializedConfig,
|
|
30
|
-
declare function loadSnapshotSerializers(config: SerializedConfig,
|
|
28
|
+
declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
|
|
29
|
+
declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
|
|
31
30
|
|
|
32
31
|
export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
package/dist/browser.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.
|
|
1
|
+
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.uiMcU3cv.js';
|
|
2
2
|
export { collectTests, processError, startTests } from '@vitest/runner';
|
|
3
|
-
import * as
|
|
4
|
-
export {
|
|
5
|
-
export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
|
|
3
|
+
import * as spyModule from '@vitest/spy';
|
|
4
|
+
export { spyModule as SpyModule };
|
|
5
|
+
export { format, getSafeTimers, getType, inspect, stringify } from '@vitest/utils';
|
|
6
6
|
export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
|
|
7
|
-
import './chunks/coverage.
|
|
7
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
8
8
|
import '@vitest/snapshot';
|
|
9
|
+
import './chunks/utils.D2R2NiOH.js';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { runInThisContext } from 'node:vm';
|
|
2
|
+
import * as spyModule from '@vitest/spy';
|
|
3
|
+
import { EvaluatedModules } from 'vite/module-runner';
|
|
4
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.p67gbNo9.js';
|
|
5
|
+
import { performance } from 'node:perf_hooks';
|
|
6
|
+
import { startTests, collectTests } from '@vitest/runner';
|
|
7
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './resolveSnapshotEnvironment.Bkht6Yor.js';
|
|
8
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.uiMcU3cv.js';
|
|
9
|
+
import { g as globalExpect, v as vi } from './vi.ZPgvtBao.js';
|
|
10
|
+
import { c as closeInspector } from './inspector.CvQD-Nie.js';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import timers from 'node:timers';
|
|
13
|
+
import timersPromises from 'node:timers/promises';
|
|
14
|
+
import util from 'node:util';
|
|
15
|
+
import { KNOWN_ASSET_TYPES, getSafeTimers } from '@vitest/utils';
|
|
16
|
+
import { i as index } from './index.CMfqw92x.js';
|
|
17
|
+
import { g as getWorkerState, r as resetModules, p as provideWorkerState } from './utils.D2R2NiOH.js';
|
|
18
|
+
|
|
19
|
+
// this should only be used in Node
|
|
20
|
+
let globalSetup = false;
|
|
21
|
+
async function setupGlobalEnv(config, { environment }, moduleRunner) {
|
|
22
|
+
await setupCommonEnv(config), Object.defineProperty(globalThis, "__vitest_index__", {
|
|
23
|
+
value: index,
|
|
24
|
+
enumerable: false
|
|
25
|
+
});
|
|
26
|
+
const state = getWorkerState();
|
|
27
|
+
if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, moduleRunner);
|
|
28
|
+
if (globalSetup) return;
|
|
29
|
+
globalSetup = true;
|
|
30
|
+
const viteEnvironment = environment.viteEnvironment || environment.name;
|
|
31
|
+
if (viteEnvironment === "client") {
|
|
32
|
+
const _require = createRequire(import.meta.url);
|
|
33
|
+
_require.extensions[".css"] = resolveCss, _require.extensions[".scss"] = resolveCss, _require.extensions[".sass"] = resolveCss, _require.extensions[".less"] = resolveCss, KNOWN_ASSET_TYPES.forEach((type) => {
|
|
34
|
+
_require.extensions[`.${type}`] = resolveAsset;
|
|
35
|
+
}), process.env.SSR = "";
|
|
36
|
+
} else process.env.SSR = "1";
|
|
37
|
+
if (globalThis.__vitest_required__ = {
|
|
38
|
+
util,
|
|
39
|
+
timers,
|
|
40
|
+
timersPromises
|
|
41
|
+
}, !config.disableConsoleIntercept) await setupConsoleLogSpy();
|
|
42
|
+
}
|
|
43
|
+
function resolveCss(mod) {
|
|
44
|
+
mod.exports = "";
|
|
45
|
+
}
|
|
46
|
+
function resolveAsset(mod, url) {
|
|
47
|
+
mod.exports = url;
|
|
48
|
+
}
|
|
49
|
+
async function setupConsoleLogSpy() {
|
|
50
|
+
const { createCustomConsole } = await import('./console.7h5kHUIf.js');
|
|
51
|
+
globalThis.console = createCustomConsole();
|
|
52
|
+
}
|
|
53
|
+
async function withEnv({ environment }, options, fn) {
|
|
54
|
+
globalThis.__vitest_environment__ = environment.name, globalExpect.setState({ environment: environment.name });
|
|
55
|
+
const env = await environment.setup(globalThis, options);
|
|
56
|
+
try {
|
|
57
|
+
await fn();
|
|
58
|
+
} finally {
|
|
59
|
+
// Run possible setTimeouts, e.g. the onces used by ConsoleLogSpy
|
|
60
|
+
const { setTimeout } = getSafeTimers();
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve)), await env.teardown(globalThis);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// browser shouldn't call this!
|
|
66
|
+
async function run(method, files, config, environment, moduleRunner) {
|
|
67
|
+
const workerState = getWorkerState(), isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true), isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true), isolate = isIsolatedThreads || isIsolatedForks;
|
|
68
|
+
if (await setupGlobalEnv(config, environment, moduleRunner), await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate }), config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
|
69
|
+
const runner = await resolveTestRunner(config, moduleRunner);
|
|
70
|
+
workerState.onCancel.then((reason) => {
|
|
71
|
+
closeInspector(config), runner.cancel?.(reason);
|
|
72
|
+
}), workerState.durations.prepare = performance.now() - workerState.durations.prepare, workerState.durations.environment = performance.now(), await withEnv(environment, environment.options || config.environmentOptions || {}, async () => {
|
|
73
|
+
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
if (isolate) moduleRunner.mocker.reset(), resetModules(workerState.evaluatedModules, true);
|
|
76
|
+
if (workerState.filepath = file.filepath, method === "run") await startTests([file], runner);
|
|
77
|
+
else await collectTests([file], runner);
|
|
78
|
+
// mocks should not affect different files
|
|
79
|
+
vi.resetConfig(), vi.restoreAllMocks();
|
|
80
|
+
}
|
|
81
|
+
await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate });
|
|
82
|
+
}), workerState.environmentTeardownRun = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let _moduleRunner;
|
|
86
|
+
const evaluatedModules = new EvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
|
|
87
|
+
function startModuleRunner(options) {
|
|
88
|
+
return _moduleRunner || (_moduleRunner = startVitestModuleRunner(options), _moduleRunner);
|
|
89
|
+
}
|
|
90
|
+
async function runBaseTests(method, state) {
|
|
91
|
+
const { ctx } = state;
|
|
92
|
+
if (state.evaluatedModules = evaluatedModules, state.moduleExecutionInfo = moduleExecutionInfo, provideWorkerState(globalThis, state), ctx.invalidates) ctx.invalidates.forEach((filepath) => {
|
|
93
|
+
const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
|
|
94
|
+
modules.forEach((module) => {
|
|
95
|
+
state.evaluatedModules.invalidateModule(module);
|
|
96
|
+
});
|
|
97
|
+
// evaluatedModules.delete(fsPath)
|
|
98
|
+
// evaluatedModules.delete(`mock:${fsPath}`)
|
|
99
|
+
});
|
|
100
|
+
ctx.files.forEach((i) => {
|
|
101
|
+
const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
|
|
102
|
+
modules.forEach((module) => {
|
|
103
|
+
state.evaluatedModules.invalidateModule(module);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
const executor = startModuleRunner({
|
|
107
|
+
state,
|
|
108
|
+
evaluatedModules: state.evaluatedModules,
|
|
109
|
+
spyModule,
|
|
110
|
+
createImportMeta: createNodeImportMeta
|
|
111
|
+
}), fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
|
112
|
+
filepath: f,
|
|
113
|
+
testLocations: void 0
|
|
114
|
+
} : f);
|
|
115
|
+
if (ctx.config.serializedDefines) try {
|
|
116
|
+
runInThisContext(`(() =>{\n${ctx.config.serializedDefines}})()`, {
|
|
117
|
+
lineOffset: 1,
|
|
118
|
+
filename: "virtual:load-defines.js"
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new Error(`Failed to load custom "defines": ${error.message}`);
|
|
122
|
+
}
|
|
123
|
+
await run(method, fileSpecs, ctx.config, {
|
|
124
|
+
environment: state.environment,
|
|
125
|
+
options: ctx.environment.options
|
|
126
|
+
}, executor);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { runBaseTests as r };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { getCurrentSuite } from '@vitest/runner';
|
|
2
2
|
import { createChainable } from '@vitest/runner/utils';
|
|
3
3
|
import { noop } from '@vitest/utils';
|
|
4
|
-
import { g as getWorkerState } from './utils.
|
|
4
|
+
import { g as getWorkerState } from './utils.D2R2NiOH.js';
|
|
5
5
|
|
|
6
|
-
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const benchFns = /* @__PURE__ */ new WeakMap(), benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
8
7
|
function getBenchOptions(key) {
|
|
9
8
|
return benchOptsMap.get(key);
|
|
10
9
|
}
|
|
@@ -17,8 +16,9 @@ const bench = createBenchmark(function(name, fn = noop, options = {}) {
|
|
|
17
16
|
...this,
|
|
18
17
|
meta: { benchmark: true }
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// vitest runner sets mode to `todo` if handler is not passed down
|
|
20
|
+
// but we store handler separetly
|
|
21
|
+
if (benchFns.set(task, fn), benchOptsMap.set(task, options), !this.todo && task.mode === "todo") task.mode = "run";
|
|
22
22
|
});
|
|
23
23
|
function createBenchmark(fn) {
|
|
24
24
|
const benchmark = createChainable([
|
|
@@ -26,9 +26,7 @@ function createBenchmark(fn) {
|
|
|
26
26
|
"only",
|
|
27
27
|
"todo"
|
|
28
28
|
], fn);
|
|
29
|
-
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|
|
30
|
-
benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
|
|
31
|
-
return benchmark;
|
|
29
|
+
return benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark, benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip, benchmark;
|
|
32
30
|
}
|
|
33
31
|
function formatName(name) {
|
|
34
32
|
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
|
@@ -4,8 +4,8 @@ import { TaskResult, Bench, Options } from 'tinybench';
|
|
|
4
4
|
|
|
5
5
|
interface Benchmark extends Test {
|
|
6
6
|
meta: {
|
|
7
|
-
benchmark: true
|
|
8
|
-
result?: TaskResult
|
|
7
|
+
benchmark: true;
|
|
8
|
+
result?: TaskResult;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
interface BenchmarkResult extends TaskResult {
|
|
@@ -17,8 +17,8 @@ interface BenchmarkResult extends TaskResult {
|
|
|
17
17
|
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
18
18
|
type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
|
|
19
19
|
type BenchmarkAPI = ChainableBenchmarkAPI & {
|
|
20
|
-
skipIf: (condition: any) => ChainableBenchmarkAPI
|
|
21
|
-
runIf: (condition: any) => ChainableBenchmarkAPI
|
|
20
|
+
skipIf: (condition: any) => ChainableBenchmarkAPI;
|
|
21
|
+
runIf: (condition: any) => ChainableBenchmarkAPI;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export type { BenchmarkResult as B, BenchFunction as a, Benchmark as b, BenchmarkAPI as c };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
1
|
+
import { T as TestExecutionMethod } from './worker.d.BDsXGkwh.js';
|
|
2
2
|
|
|
3
3
|
type SerializedTestSpecification = [project: {
|
|
4
|
-
name: string | undefined
|
|
5
|
-
root: string
|
|
4
|
+
name: string | undefined;
|
|
5
|
+
root: string;
|
|
6
6
|
}, file: string, options: {
|
|
7
|
-
pool: string
|
|
8
|
-
testLines?: number[] | undefined
|
|
7
|
+
pool: string;
|
|
8
|
+
testLines?: number[] | undefined;
|
|
9
9
|
}];
|
|
10
10
|
|
|
11
11
|
interface BrowserTesterOptions {
|