vitest 0.20.3 → 0.22.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 +61 -4
- package/dist/browser.d.ts +8 -1902
- package/dist/browser.mjs +8 -9
- package/dist/{chunk-api-setup.9bff74bb.mjs → chunk-api-setup.ecd02c18.mjs} +8 -7
- package/dist/{chunk-constants.16825f0c.mjs → chunk-constants.d3f8437b.mjs} +4 -4
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
- package/dist/{chunk-defaults.6698a2d3.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
- package/dist/{chunk-integrations-globals.c5b78414.mjs → chunk-integrations-globals.e81d2091.mjs} +7 -6
- package/dist/{chunk-mock-date.9160e13b.mjs → chunk-mock-date.debe9954.mjs} +16 -74
- package/dist/chunk-node-git.71b74da4.mjs +80 -0
- package/dist/{chunk-runtime-chain.b6c2cdbc.mjs → chunk-runtime-chain.6e363ba2.mjs} +31 -21
- package/dist/{chunk-runtime-error.034e03ba.mjs → chunk-runtime-error.975bd80a.mjs} +14 -12
- package/dist/{chunk-runtime-hooks.a8401528.mjs → chunk-runtime-hooks.4789e99d.mjs} +3 -3
- package/dist/{chunk-runtime-mocker.653847b2.mjs → chunk-runtime-mocker.c91d29ce.mjs} +34 -12
- package/dist/{chunk-runtime-rpc.dbf0b31d.mjs → chunk-runtime-rpc.29488183.mjs} +1 -1
- package/dist/{chunk-utils-source-map.8198ebd9.mjs → chunk-utils-source-map.2a082ffd.mjs} +2 -1
- package/dist/{chunk-vite-node-client.115caed2.mjs → chunk-vite-node-client.d1ead698.mjs} +7 -3
- package/dist/{chunk-vite-node-debug.c5887932.mjs → chunk-vite-node-debug.ff1d2a9f.mjs} +3 -2
- package/dist/{chunk-vite-node-externalize.91ae6e85.mjs → chunk-vite-node-externalize.3a38c8af.mjs} +167 -39
- package/dist/chunk-vite-node-utils.d8e5ff7b.mjs +6921 -0
- package/dist/cli-wrapper.mjs +107 -0
- package/dist/cli.mjs +16 -14
- package/dist/config.cjs +3 -0
- package/dist/config.d.ts +7 -69
- package/dist/config.mjs +2 -1
- package/dist/entry.mjs +8 -9
- package/dist/global-74489cc9.d.ts +2098 -0
- package/dist/index-9eded9ec.d.ts +116 -0
- package/dist/index.d.ts +9 -1928
- package/dist/index.mjs +6 -5
- package/dist/loader.mjs +74 -17
- package/dist/node.d.ts +7 -1682
- package/dist/node.mjs +15 -13
- package/dist/suite.mjs +5 -4
- package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
- package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
- package/dist/vendor-index.9d9196cc.mjs +61 -0
- package/dist/{vendor-index.de788b6a.mjs → vendor-index.ae96af6e.mjs} +14 -14
- package/dist/{chunk-node-git.43dbdd42.mjs → vendor-index.fbec8a81.mjs} +5 -73
- package/dist/vendor-picocolors.807856aa.mjs +64 -0
- package/dist/worker.mjs +7 -6
- package/package.json +8 -12
- package/vitest.mjs +1 -1
- package/dist/chunk-vite-node-utils.7e46948f.mjs +0 -1114
package/dist/browser.mjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.
|
|
3
|
-
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.
|
|
1
|
+
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.4789e99d.mjs';
|
|
3
|
+
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.975bd80a.mjs';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
|
7
7
|
import 'util';
|
|
8
|
-
import './chunk-mock-date.
|
|
8
|
+
import './chunk-mock-date.debe9954.mjs';
|
|
9
9
|
import 'path';
|
|
10
|
+
import './vendor-picocolors.807856aa.mjs';
|
|
10
11
|
import 'tty';
|
|
11
12
|
import 'local-pkg';
|
|
12
13
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
13
|
-
import './chunk-runtime-rpc.
|
|
14
|
+
import './chunk-runtime-rpc.29488183.mjs';
|
|
14
15
|
import './chunk-utils-global.fa20c2f6.mjs';
|
|
15
16
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
16
17
|
import 'fs';
|
|
17
|
-
import './chunk-utils-source-map.
|
|
18
|
+
import './chunk-utils-source-map.2a082ffd.mjs';
|
|
18
19
|
import './spy.mjs';
|
|
19
20
|
import 'tinyspy';
|
|
20
|
-
import './chunk-
|
|
21
|
-
import 'module';
|
|
22
|
-
import 'url';
|
|
21
|
+
import './chunk-integrations-coverage.d205bd87.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-client.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-client.d1ead698.mjs';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -8,16 +8,17 @@ import require$$5 from 'crypto';
|
|
|
8
8
|
import require$$2 from 'events';
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
|
-
import
|
|
12
|
-
import { A as API_PATH } from './chunk-constants.
|
|
13
|
-
import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.
|
|
11
|
+
import url from 'url';
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.d3f8437b.mjs';
|
|
13
|
+
import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.2a082ffd.mjs';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-mock-date.
|
|
16
|
+
import './chunk-mock-date.debe9954.mjs';
|
|
17
17
|
import 'path';
|
|
18
|
+
import './vendor-picocolors.807856aa.mjs';
|
|
18
19
|
import 'tty';
|
|
19
20
|
import 'local-pkg';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
21
|
+
import './chunk-vite-node-utils.d8e5ff7b.mjs';
|
|
21
22
|
import 'assert';
|
|
22
23
|
import 'util';
|
|
23
24
|
import 'debug';
|
|
@@ -2514,7 +2515,7 @@ const http$1 = require$$2$1;
|
|
|
2514
2515
|
const net = require$$3;
|
|
2515
2516
|
const tls = require$$4;
|
|
2516
2517
|
const { randomBytes, createHash: createHash$1 } = require$$5;
|
|
2517
|
-
const { URL: URL$1 } =
|
|
2518
|
+
const { URL: URL$1 } = url;
|
|
2518
2519
|
|
|
2519
2520
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
2520
2521
|
const Receiver = receiver;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import url from 'url';
|
|
2
|
+
import { x as resolve } from './chunk-mock-date.debe9954.mjs';
|
|
3
3
|
|
|
4
|
-
const rootDir = resolve(
|
|
5
|
-
const distDir = resolve(
|
|
4
|
+
const rootDir = resolve(url.fileURLToPath(import.meta.url), "../../");
|
|
5
|
+
const distDir = resolve(url.fileURLToPath(import.meta.url), "../../dist");
|
|
6
6
|
const defaultPort = 51204;
|
|
7
7
|
const API_PATH = "/__vitest_api__";
|
|
8
8
|
const configFiles = [
|
|
@@ -2,9 +2,10 @@ import path$2 from 'path';
|
|
|
2
2
|
import fs$2 from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
4
|
import childProcess$1 from 'child_process';
|
|
5
|
-
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.
|
|
6
|
-
import {
|
|
5
|
+
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.2ae8040a.mjs';
|
|
6
|
+
import { o as onetime$1 } from './vendor-index.9d9196cc.mjs';
|
|
7
7
|
import require$$0 from 'os';
|
|
8
|
+
import { s as signalExit } from './vendor-index.29636037.mjs';
|
|
8
9
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
9
10
|
import 'buffer';
|
|
10
11
|
import 'stream';
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { existsSync, promises } from 'fs';
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
|
-
import _url from 'url';
|
|
4
|
-
import { t as toArray, y as resolve } from './chunk-mock-date.9160e13b.mjs';
|
|
5
1
|
import { importModule } from 'local-pkg';
|
|
6
2
|
|
|
7
3
|
/*
|
|
@@ -139,156 +135,31 @@ function pLimit(concurrency) {
|
|
|
139
135
|
return generator;
|
|
140
136
|
}
|
|
141
137
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"coverage/**",
|
|
146
|
-
"dist/**",
|
|
147
|
-
"packages/*/test{,s}/**",
|
|
148
|
-
"**/*.d.ts",
|
|
149
|
-
"cypress/**",
|
|
150
|
-
"test{,s}/**",
|
|
151
|
-
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
|
|
152
|
-
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
|
|
153
|
-
"**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
|
|
154
|
-
"**/__tests__/**",
|
|
155
|
-
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
|
|
156
|
-
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
157
|
-
];
|
|
158
|
-
const coverageConfigDefaults = {
|
|
159
|
-
enabled: false,
|
|
160
|
-
clean: true,
|
|
161
|
-
cleanOnRerun: false,
|
|
162
|
-
reportsDirectory: "./coverage",
|
|
163
|
-
excludeNodeModules: true,
|
|
164
|
-
exclude: defaultCoverageExcludes,
|
|
165
|
-
reporter: ["text", "html", "clover"],
|
|
166
|
-
allowExternal: false,
|
|
167
|
-
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
168
|
-
};
|
|
169
|
-
const fakeTimersDefaults = {
|
|
170
|
-
loopLimit: 1e4,
|
|
171
|
-
shouldClearNativeTimers: true,
|
|
172
|
-
toFake: [
|
|
173
|
-
"setTimeout",
|
|
174
|
-
"clearTimeout",
|
|
175
|
-
"setInterval",
|
|
176
|
-
"clearInterval",
|
|
177
|
-
"setImmediate",
|
|
178
|
-
"clearImmediate",
|
|
179
|
-
"Date"
|
|
180
|
-
]
|
|
138
|
+
const CoverageProviderMap = {
|
|
139
|
+
c8: "@vitest/coverage-c8",
|
|
140
|
+
istanbul: "@vitest/coverage-istanbul"
|
|
181
141
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
include: defaultInclude,
|
|
192
|
-
exclude: defaultExclude,
|
|
193
|
-
testTimeout: 5e3,
|
|
194
|
-
hookTimeout: 1e4,
|
|
195
|
-
teardownTimeout: 1e3,
|
|
196
|
-
isolate: true,
|
|
197
|
-
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
198
|
-
forceRerunTriggers: [
|
|
199
|
-
"**/package.json/**",
|
|
200
|
-
"**/vitest.config.*/**",
|
|
201
|
-
"**/vite.config.*/**"
|
|
202
|
-
],
|
|
203
|
-
update: false,
|
|
204
|
-
reporters: [],
|
|
205
|
-
silent: false,
|
|
206
|
-
api: false,
|
|
207
|
-
ui: false,
|
|
208
|
-
uiBase: "/__vitest__/",
|
|
209
|
-
open: true,
|
|
210
|
-
css: {
|
|
211
|
-
include: [/\.module\./]
|
|
212
|
-
},
|
|
213
|
-
coverage: coverageConfigDefaults,
|
|
214
|
-
fakeTimers: fakeTimersDefaults,
|
|
215
|
-
maxConcurrency: 5,
|
|
216
|
-
dangerouslyIgnoreUnhandledErrors: false
|
|
217
|
-
};
|
|
218
|
-
const configDefaults = Object.freeze(config);
|
|
219
|
-
|
|
220
|
-
function resolveC8Options(options, root) {
|
|
221
|
-
const resolved = {
|
|
222
|
-
...configDefaults.coverage,
|
|
223
|
-
...options
|
|
224
|
-
};
|
|
225
|
-
resolved.reporter = toArray(resolved.reporter);
|
|
226
|
-
resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
|
|
227
|
-
resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
|
|
228
|
-
return resolved;
|
|
229
|
-
}
|
|
230
|
-
async function cleanCoverage(options, clean = true) {
|
|
231
|
-
if (clean && existsSync(options.reportsDirectory))
|
|
232
|
-
await promises.rm(options.reportsDirectory, { recursive: true, force: true });
|
|
233
|
-
if (!existsSync(options.tempDirectory))
|
|
234
|
-
await promises.mkdir(options.tempDirectory, { recursive: true });
|
|
142
|
+
async function resolveCoverageProvider(provider) {
|
|
143
|
+
if (typeof provider === "string") {
|
|
144
|
+
const pkg = CoverageProviderMap[provider];
|
|
145
|
+
if (!pkg)
|
|
146
|
+
throw new Error(`Unknown coverage provider: ${provider}`);
|
|
147
|
+
return await importModule(pkg);
|
|
148
|
+
} else {
|
|
149
|
+
return provider;
|
|
150
|
+
}
|
|
235
151
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
v8.takeCoverage();
|
|
152
|
+
async function getCoverageProvider(options) {
|
|
153
|
+
if ((options == null ? void 0 : options.enabled) && (options == null ? void 0 : options.provider)) {
|
|
154
|
+
const { getProvider } = await resolveCoverageProvider(options.provider);
|
|
155
|
+
return await getProvider();
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
243
158
|
}
|
|
244
|
-
async function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const sourceMapMeta = {};
|
|
249
|
-
await Promise.all(Array.from(ctx.vitenode.fetchCache.entries()).filter((i) => !i[0].includes("/node_modules/")).map(async ([file, { result }]) => {
|
|
250
|
-
const map = result.map;
|
|
251
|
-
if (!map)
|
|
252
|
-
return;
|
|
253
|
-
const url = _url.pathToFileURL(file).href;
|
|
254
|
-
let code;
|
|
255
|
-
try {
|
|
256
|
-
code = (await promises.readFile(file)).toString();
|
|
257
|
-
} catch {
|
|
258
|
-
}
|
|
259
|
-
const sources = [url];
|
|
260
|
-
sourceMapMeta[url] = {
|
|
261
|
-
source: result.code,
|
|
262
|
-
map: {
|
|
263
|
-
sourcesContent: code ? [code] : void 0,
|
|
264
|
-
...map,
|
|
265
|
-
sources
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
}));
|
|
269
|
-
const offset = 224;
|
|
270
|
-
report._getSourceMap = (coverage) => {
|
|
271
|
-
const path = _url.pathToFileURL(coverage.url).href;
|
|
272
|
-
const data = sourceMapMeta[path];
|
|
273
|
-
if (!data)
|
|
274
|
-
return {};
|
|
275
|
-
return {
|
|
276
|
-
sourceMap: {
|
|
277
|
-
sourcemap: data.map
|
|
278
|
-
},
|
|
279
|
-
source: Array(offset).fill(".").join("") + data.source
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
await report.run();
|
|
283
|
-
if (ctx.config.coverage.enabled) {
|
|
284
|
-
if (ctx.config.coverage["100"]) {
|
|
285
|
-
ctx.config.coverage.lines = 100;
|
|
286
|
-
ctx.config.coverage.functions = 100;
|
|
287
|
-
ctx.config.coverage.branches = 100;
|
|
288
|
-
ctx.config.coverage.statements = 100;
|
|
289
|
-
}
|
|
290
|
-
const { checkCoverages } = require("c8/lib/commands/check-coverage");
|
|
291
|
-
await checkCoverages(ctx.config.coverage, report);
|
|
159
|
+
async function takeCoverageInsideWorker(options) {
|
|
160
|
+
if (options.enabled && options.provider) {
|
|
161
|
+
const { takeCoverage } = await resolveCoverageProvider(options.provider);
|
|
162
|
+
return await (takeCoverage == null ? void 0 : takeCoverage());
|
|
292
163
|
}
|
|
293
164
|
}
|
|
294
165
|
|
|
@@ -677,4 +548,4 @@ const envPackageNames = {
|
|
|
677
548
|
"edge-runtime": "@edge-runtime/vm"
|
|
678
549
|
};
|
|
679
550
|
|
|
680
|
-
export {
|
|
551
|
+
export { CoverageProviderMap as C, envPackageNames as a, envs as b, environments as e, getCoverageProvider as g, pLimit as p, takeCoverageInsideWorker as t };
|
package/dist/{chunk-integrations-globals.c5b78414.mjs → chunk-integrations-globals.e81d2091.mjs}
RENAMED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { g as globalApis } from './chunk-constants.
|
|
2
|
-
import { i as index } from './chunk-runtime-hooks.
|
|
1
|
+
import { g as globalApis } from './chunk-constants.d3f8437b.mjs';
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.4789e99d.mjs';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './chunk-mock-date.
|
|
4
|
+
import './chunk-mock-date.debe9954.mjs';
|
|
5
5
|
import 'path';
|
|
6
|
+
import './vendor-picocolors.807856aa.mjs';
|
|
6
7
|
import 'tty';
|
|
7
8
|
import 'local-pkg';
|
|
8
|
-
import './chunk-runtime-chain.
|
|
9
|
+
import './chunk-runtime-chain.6e363ba2.mjs';
|
|
9
10
|
import 'util';
|
|
10
11
|
import 'chai';
|
|
11
12
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
13
|
+
import './chunk-runtime-rpc.29488183.mjs';
|
|
13
14
|
import './chunk-utils-global.fa20c2f6.mjs';
|
|
14
15
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
15
16
|
import 'fs';
|
|
16
|
-
import './chunk-utils-source-map.
|
|
17
|
+
import './chunk-utils-source-map.2a082ffd.mjs';
|
|
17
18
|
import './spy.mjs';
|
|
18
19
|
import 'tinyspy';
|
|
19
20
|
|
|
@@ -1,68 +1,7 @@
|
|
|
1
1
|
import path, { relative as relative$1 } from 'path';
|
|
2
|
-
import
|
|
2
|
+
import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
|
|
3
3
|
import { isPackageExists } from 'local-pkg';
|
|
4
4
|
|
|
5
|
-
var picocolors = {exports: {}};
|
|
6
|
-
|
|
7
|
-
let tty = require$$0;
|
|
8
|
-
|
|
9
|
-
let isColorSupported =
|
|
10
|
-
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
11
|
-
("FORCE_COLOR" in process.env ||
|
|
12
|
-
process.argv.includes("--color") ||
|
|
13
|
-
process.platform === "win32" ||
|
|
14
|
-
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
15
|
-
"CI" in process.env);
|
|
16
|
-
|
|
17
|
-
let formatter =
|
|
18
|
-
(open, close, replace = open) =>
|
|
19
|
-
input => {
|
|
20
|
-
let string = "" + input;
|
|
21
|
-
let index = string.indexOf(close, open.length);
|
|
22
|
-
return ~index
|
|
23
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
24
|
-
: open + string + close
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let replaceClose = (string, close, replace, index) => {
|
|
28
|
-
let start = string.substring(0, index) + replace;
|
|
29
|
-
let end = string.substring(index + close.length);
|
|
30
|
-
let nextIndex = end.indexOf(close);
|
|
31
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
let createColors = (enabled = isColorSupported) => ({
|
|
35
|
-
isColorSupported: enabled,
|
|
36
|
-
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
37
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
38
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
39
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
40
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
41
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
42
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
43
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
44
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
45
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
46
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
47
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
48
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
49
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
50
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
51
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
52
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
53
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
54
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
55
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
56
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
57
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
58
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
59
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
60
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
picocolors.exports = createColors();
|
|
64
|
-
picocolors.exports.createColors = createColors;
|
|
65
|
-
|
|
66
5
|
function normalizeWindowsPath(input = "") {
|
|
67
6
|
if (!input.includes("\\")) {
|
|
68
7
|
return input;
|
|
@@ -299,18 +238,21 @@ function isFinalObj(obj) {
|
|
|
299
238
|
return obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;
|
|
300
239
|
}
|
|
301
240
|
function collectOwnProperties(obj, collector) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
symbols.forEach((symbol) => collector.add(symbol));
|
|
241
|
+
const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
|
|
242
|
+
Object.getOwnPropertyNames(obj).forEach(collect);
|
|
243
|
+
Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
306
244
|
}
|
|
307
|
-
function
|
|
245
|
+
function getAllMockableProperties(obj) {
|
|
308
246
|
const allProps = /* @__PURE__ */ new Set();
|
|
309
247
|
let curr = obj;
|
|
310
248
|
do {
|
|
311
249
|
if (isFinalObj(curr))
|
|
312
250
|
break;
|
|
313
|
-
collectOwnProperties(curr,
|
|
251
|
+
collectOwnProperties(curr, (key) => {
|
|
252
|
+
const descriptor = Object.getOwnPropertyDescriptor(curr, key);
|
|
253
|
+
if (descriptor)
|
|
254
|
+
allProps.add({ key, descriptor });
|
|
255
|
+
});
|
|
314
256
|
} while (curr = Object.getPrototypeOf(curr));
|
|
315
257
|
return Array.from(allProps);
|
|
316
258
|
}
|
|
@@ -378,9 +320,9 @@ function deepMerge(target, ...sources) {
|
|
|
378
320
|
const source = sources.shift();
|
|
379
321
|
if (source === void 0)
|
|
380
322
|
return target;
|
|
381
|
-
if (
|
|
323
|
+
if (isMergeableObject(target) && isMergeableObject(source)) {
|
|
382
324
|
Object.keys(source).forEach((key) => {
|
|
383
|
-
if (
|
|
325
|
+
if (isMergeableObject(source[key])) {
|
|
384
326
|
if (!target[key])
|
|
385
327
|
target[key] = {};
|
|
386
328
|
deepMerge(target[key], source[key]);
|
|
@@ -391,7 +333,7 @@ function deepMerge(target, ...sources) {
|
|
|
391
333
|
}
|
|
392
334
|
return deepMerge(target, ...sources);
|
|
393
335
|
}
|
|
394
|
-
function
|
|
336
|
+
function isMergeableObject(item) {
|
|
395
337
|
return isPlainObject(item) && !Array.isArray(item);
|
|
396
338
|
}
|
|
397
339
|
function assertTypes(value, name, types) {
|
|
@@ -497,14 +439,14 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
497
439
|
`));
|
|
498
440
|
if (!promptInstall)
|
|
499
441
|
return false;
|
|
500
|
-
const prompts = await import('./vendor-index.
|
|
442
|
+
const prompts = await import('./vendor-index.ae96af6e.mjs').then(function (n) { return n.i; });
|
|
501
443
|
const { install } = await prompts.prompt({
|
|
502
444
|
type: "confirm",
|
|
503
445
|
name: "install",
|
|
504
446
|
message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
|
|
505
447
|
});
|
|
506
448
|
if (install) {
|
|
507
|
-
await (await import('./chunk-install-pkg.
|
|
449
|
+
await (await import('./chunk-install-pkg.3aa3eae6.mjs')).installPackage(dependency, { dev: true });
|
|
508
450
|
process.stderr.write(picocolors.exports.yellow(`
|
|
509
451
|
Package ${dependency} installed, re-run the command to start.
|
|
510
452
|
`));
|
|
@@ -549,4 +491,4 @@ class AggregateErrorPonyfill extends Error {
|
|
|
549
491
|
}
|
|
550
492
|
}
|
|
551
493
|
|
|
552
|
-
export { AggregateErrorPonyfill as A,
|
|
494
|
+
export { AggregateErrorPonyfill as A, relative as B, getTests as C, hasFailedSnapshot as D, getSuites as E, normalize as F, deepMerge as G, toNamespacedPath as H, ensurePackageInstalled as I, stdout as J, extname as K, isWindows as L, mergeSlashes as M, getAllMockableProperties as N, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, isBrowser as p, partitionSuiteChildren as q, resetDate as r, slash as s, toArray as t, shuffle as u, hasTests as v, hasFailed as w, resolve as x, basename as y, isAbsolute as z };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { x as resolve } from './chunk-mock-date.debe9954.mjs';
|
|
2
|
+
import { e as execa } from './vendor-index.fbec8a81.mjs';
|
|
3
|
+
import 'path';
|
|
4
|
+
import './vendor-picocolors.807856aa.mjs';
|
|
5
|
+
import 'tty';
|
|
6
|
+
import 'local-pkg';
|
|
7
|
+
import 'buffer';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
import 'process';
|
|
10
|
+
import './vendor-index.2ae8040a.mjs';
|
|
11
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
+
import 'fs';
|
|
13
|
+
import 'stream';
|
|
14
|
+
import 'util';
|
|
15
|
+
import 'url';
|
|
16
|
+
import 'os';
|
|
17
|
+
import './vendor-index.29636037.mjs';
|
|
18
|
+
import 'assert';
|
|
19
|
+
import 'events';
|
|
20
|
+
|
|
21
|
+
class VitestGit {
|
|
22
|
+
constructor(cwd) {
|
|
23
|
+
this.cwd = cwd;
|
|
24
|
+
}
|
|
25
|
+
async resolveFilesWithGitCommand(args) {
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
result = await execa("git", args, { cwd: this.root });
|
|
29
|
+
} catch (e) {
|
|
30
|
+
e.message = e.stderr;
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
|
34
|
+
}
|
|
35
|
+
async findChangedFiles(options) {
|
|
36
|
+
const root = await this.getRoot(this.cwd);
|
|
37
|
+
if (!root)
|
|
38
|
+
return null;
|
|
39
|
+
this.root = root;
|
|
40
|
+
const changedSince = options.changedSince;
|
|
41
|
+
if (typeof changedSince === "string") {
|
|
42
|
+
const [committed, staged2, unstaged2] = await Promise.all([
|
|
43
|
+
this.getFilesSince(changedSince),
|
|
44
|
+
this.getStagedFiles(),
|
|
45
|
+
this.getUnstagedFiles()
|
|
46
|
+
]);
|
|
47
|
+
return [...committed, ...staged2, ...unstaged2];
|
|
48
|
+
}
|
|
49
|
+
const [staged, unstaged] = await Promise.all([
|
|
50
|
+
this.getStagedFiles(),
|
|
51
|
+
this.getUnstagedFiles()
|
|
52
|
+
]);
|
|
53
|
+
return [...staged, ...unstaged];
|
|
54
|
+
}
|
|
55
|
+
getFilesSince(hash) {
|
|
56
|
+
return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
|
|
57
|
+
}
|
|
58
|
+
getStagedFiles() {
|
|
59
|
+
return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
|
|
60
|
+
}
|
|
61
|
+
getUnstagedFiles() {
|
|
62
|
+
return this.resolveFilesWithGitCommand([
|
|
63
|
+
"ls-files",
|
|
64
|
+
"--other",
|
|
65
|
+
"--modified",
|
|
66
|
+
"--exclude-standard"
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
async getRoot(cwd) {
|
|
70
|
+
const options = ["rev-parse", "--show-cdup"];
|
|
71
|
+
try {
|
|
72
|
+
const result = await execa("git", options, { cwd });
|
|
73
|
+
return resolve(cwd, result.stdout);
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { VitestGit };
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import util$1 from 'util';
|
|
2
|
-
import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes,
|
|
2
|
+
import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, e as getFullName, n as noop } from './chunk-mock-date.debe9954.mjs';
|
|
3
3
|
import * as chai$2 from 'chai';
|
|
4
4
|
import { expect, AssertionError, util } from 'chai';
|
|
5
5
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.29488183.mjs';
|
|
7
7
|
import fs, { promises } from 'fs';
|
|
8
|
-
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.
|
|
8
|
+
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.2a082ffd.mjs';
|
|
9
9
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
10
|
+
import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
|
|
10
11
|
import { isMockFunction } from './spy.mjs';
|
|
11
12
|
import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
12
13
|
|
|
13
14
|
function createChainable(keys, fn) {
|
|
14
|
-
function create(
|
|
15
|
+
function create(context) {
|
|
15
16
|
const chain2 = function(...args) {
|
|
16
|
-
return fn.apply(
|
|
17
|
+
return fn.apply(context, args);
|
|
17
18
|
};
|
|
19
|
+
Object.assign(chain2, fn);
|
|
20
|
+
chain2.withContext = () => chain2.bind(context);
|
|
18
21
|
for (const key of keys) {
|
|
19
22
|
Object.defineProperty(chain2, key, {
|
|
20
23
|
get() {
|
|
21
|
-
return create({ ...
|
|
24
|
+
return create({ ...context, [key]: true });
|
|
22
25
|
}
|
|
23
26
|
});
|
|
24
27
|
}
|
|
@@ -1233,8 +1236,13 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1233
1236
|
args[0] = args[0].map((key) => key.replace(/([.[\]])/g, "\\$1")).join(".");
|
|
1234
1237
|
const actual = this._obj;
|
|
1235
1238
|
const [propertyName, expected] = args;
|
|
1236
|
-
|
|
1237
|
-
|
|
1239
|
+
let pass = false;
|
|
1240
|
+
if (Object.prototype.hasOwnProperty.call(actual, propertyName)) {
|
|
1241
|
+
pass = true;
|
|
1242
|
+
} else {
|
|
1243
|
+
const { value, exists } = utils.getPathInfo(actual, propertyName);
|
|
1244
|
+
pass = exists && (args.length === 1 || equals(expected, value));
|
|
1245
|
+
}
|
|
1238
1246
|
return this.assert(pass, "expected #{this} to have property #{exp}", "expected #{this} to not have property #{exp}", expected, actual);
|
|
1239
1247
|
});
|
|
1240
1248
|
def("toBeCloseTo", function(received, precision = 2) {
|
|
@@ -2007,11 +2015,12 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2007
2015
|
return collector;
|
|
2008
2016
|
}
|
|
2009
2017
|
function createSuite() {
|
|
2010
|
-
|
|
2018
|
+
function suiteFn(name, factory) {
|
|
2011
2019
|
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
2012
2020
|
return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle);
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2021
|
+
}
|
|
2022
|
+
suiteFn.each = function(cases) {
|
|
2023
|
+
const suite2 = this.withContext();
|
|
2015
2024
|
return (name, fn) => {
|
|
2016
2025
|
cases.forEach((i, idx) => {
|
|
2017
2026
|
const items = Array.isArray(i) ? i : [i];
|
|
@@ -2019,23 +2028,24 @@ function createSuite() {
|
|
|
2019
2028
|
});
|
|
2020
2029
|
};
|
|
2021
2030
|
};
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
return
|
|
2031
|
+
suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
|
|
2032
|
+
suiteFn.runIf = (condition) => condition ? suite : suite.skip;
|
|
2033
|
+
return createChainable(["concurrent", "shuffle", "skip", "only", "todo"], suiteFn);
|
|
2025
2034
|
}
|
|
2026
2035
|
function createTest(fn) {
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
|
|
2036
|
+
const testFn = fn;
|
|
2037
|
+
testFn.each = function(cases) {
|
|
2038
|
+
const test2 = this.withContext();
|
|
2039
|
+
return (name, fn2, timeout) => {
|
|
2030
2040
|
cases.forEach((i, idx) => {
|
|
2031
2041
|
const items = Array.isArray(i) ? i : [i];
|
|
2032
|
-
test2(formatTitle(name, items, idx), () => fn2(...items));
|
|
2042
|
+
test2(formatTitle(name, items, idx), () => fn2(...items), timeout);
|
|
2033
2043
|
});
|
|
2034
2044
|
};
|
|
2035
2045
|
};
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
return
|
|
2046
|
+
testFn.skipIf = (condition) => condition ? test.skip : test;
|
|
2047
|
+
testFn.runIf = (condition) => condition ? test : test.skip;
|
|
2048
|
+
return createChainable(["concurrent", "skip", "only", "todo", "fails"], testFn);
|
|
2039
2049
|
}
|
|
2040
2050
|
|
|
2041
2051
|
export { GLOBAL_EXPECT as G, getDefaultHookTimeout as a, globalExpect as b, createExpect as c, describe as d, clearCollectorContext as e, defaultSuite as f, getCurrentSuite as g, setHooks as h, it as i, getHooks as j, collectorContext as k, setState as l, getFn as m, getState as n, createSuiteHooks as o, chai$1 as p, suite as s, test as t, withTimeout as w };
|