vitest 0.0.98 → 0.0.102
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 +1835 -0
- package/dist/_commonjsHelpers-bdec4bbd.js +7 -0
- package/dist/cli.js +13 -19
- package/dist/{constants-e78c749a.js → constants-a1417084.js} +2 -2
- package/dist/entry.js +108 -16
- package/dist/error-d97062cd.js +4737 -0
- package/dist/{global-97ee5fb8.js → global-12f52a87.js} +6 -4
- package/dist/{index-e7a421bb.js → index-0c3a317d.js} +2 -1
- package/dist/{index-0697046c.js → index-37755855.js} +2626 -151
- package/dist/{index-5cc247ff.js → index-825cb54c.js} +2 -3
- package/dist/{index-368448f4.js → index-a190f5a1.js} +1 -1
- package/dist/index.d.ts +26 -111
- package/dist/index.js +6 -2
- package/dist/{middleware-8b68d8d7.js → middleware-05e03d95.js} +4 -2
- package/dist/node.d.ts +309 -0
- package/dist/node.js +11 -11
- package/dist/suite-64b3e636.js +201 -0
- package/dist/{utils-70b78878.js → utils-c8e62373.js} +187 -3
- package/dist/utils.js +2 -1
- package/dist/worker.js +2 -3
- package/node.d.ts +1 -0
- package/package.json +13 -12
- package/{bin/vitest.mjs → vitest.mjs} +3 -4
- package/LICENSE +0 -22
- package/dist/error-2437ee7f.js +0 -1416
- package/dist/index-1488b423.js +0 -186
- package/dist/suite-b8c6cb53.js +0 -236
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
+
|
|
3
|
+
function commonjsRequire (path) {
|
|
4
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { commonjsRequire as a, commonjsGlobal as c };
|
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import require$$0 from 'readline';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { e as ensurePackageInstalled
|
|
4
|
-
import { c as createVitest } from './index-
|
|
3
|
+
import { e as ensurePackageInstalled } from './utils-c8e62373.js';
|
|
4
|
+
import { c as createVitest } from './index-37755855.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
|
-
import './index-1488b423.js';
|
|
8
7
|
import 'path';
|
|
9
8
|
import 'vite';
|
|
10
9
|
import 'process';
|
|
11
10
|
import 'fs';
|
|
12
|
-
import '
|
|
11
|
+
import 'os';
|
|
13
12
|
import 'util';
|
|
14
|
-
import '
|
|
13
|
+
import 'stream';
|
|
14
|
+
import './constants-a1417084.js';
|
|
15
15
|
import 'url';
|
|
16
16
|
import 'perf_hooks';
|
|
17
|
-
import './error-
|
|
18
|
-
import '
|
|
19
|
-
import './
|
|
17
|
+
import './error-d97062cd.js';
|
|
18
|
+
import './index-825cb54c.js';
|
|
19
|
+
import './_commonjsHelpers-bdec4bbd.js';
|
|
20
20
|
import 'assert';
|
|
21
21
|
import 'worker_threads';
|
|
22
22
|
import 'tinypool';
|
|
@@ -634,10 +634,10 @@ class CAC extends EventEmitter {
|
|
|
634
634
|
|
|
635
635
|
const cac = (name = "") => new CAC(name);
|
|
636
636
|
|
|
637
|
-
var version = "0.0.
|
|
637
|
+
var version = "0.0.102";
|
|
638
638
|
|
|
639
639
|
const cli = cac("vitest");
|
|
640
|
-
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
640
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
641
641
|
default: "node"
|
|
642
642
|
}).help();
|
|
643
643
|
cli.command("run [...filters]").action(run);
|
|
@@ -645,10 +645,9 @@ cli.command("watch [...filters]").action(dev);
|
|
|
645
645
|
cli.command("dev [...filters]").action(dev);
|
|
646
646
|
cli.command("[...filters]").action(dev);
|
|
647
647
|
cli.parse();
|
|
648
|
-
const PROCESS_EXIT_TIMEOUT = 5e3;
|
|
649
648
|
async function dev(cliFilters, argv) {
|
|
650
649
|
if (argv.watch == null)
|
|
651
|
-
argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE;
|
|
650
|
+
argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE && !argv.silent && !argv.run;
|
|
652
651
|
await run(cliFilters, argv);
|
|
653
652
|
}
|
|
654
653
|
async function run(cliFilters, options) {
|
|
@@ -673,13 +672,8 @@ async function run(cliFilters, options) {
|
|
|
673
672
|
if (!ctx.config.watch)
|
|
674
673
|
await ctx.close();
|
|
675
674
|
}
|
|
676
|
-
if (!ctx.config.watch)
|
|
677
|
-
|
|
678
|
-
console.error(c.red("Process hanging for 5 seconds after all tests are done. Exiting..."));
|
|
679
|
-
process.exit(1);
|
|
680
|
-
}, PROCESS_EXIT_TIMEOUT);
|
|
681
|
-
timer.unref();
|
|
682
|
-
}
|
|
675
|
+
if (!ctx.config.watch)
|
|
676
|
+
process.exit();
|
|
683
677
|
}
|
|
684
678
|
function registerConsoleShortcuts(ctx) {
|
|
685
679
|
if (process.stdin.isTTY) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { h as resolve } from './utils-c8e62373.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
6
|
-
const defaultExclude = ["
|
|
6
|
+
const defaultExclude = ["node_modules", "dist", ".idea", ".git", ".cache"];
|
|
7
7
|
const defaultPort = 51204;
|
|
8
8
|
const API_PATH = "/__vitest_api__";
|
|
9
9
|
const configFiles = [
|
package/dist/entry.js
CHANGED
|
@@ -2,19 +2,17 @@ import fs, { promises } from 'fs';
|
|
|
2
2
|
import { Console } from 'console';
|
|
3
3
|
import { Writable } from 'stream';
|
|
4
4
|
import { importModule } from 'local-pkg';
|
|
5
|
-
import chai, { expect, util } from 'chai';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import chai$1, { expect, util } from 'chai';
|
|
6
|
+
import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
|
|
7
|
+
import { l as index, g as getNames, c as c$1, t as toArray, b as basename, m as interpretOnlyMode, p as partitionSuiteChildren, o as hasTests, j as hasFailed } from './utils-c8e62373.js';
|
|
8
8
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
9
|
-
import {
|
|
10
|
-
import { u as unifiedDiff } from './error-2437ee7f.js';
|
|
9
|
+
import { u as unifiedDiff } from './error-d97062cd.js';
|
|
11
10
|
import { performance } from 'perf_hooks';
|
|
12
|
-
import {
|
|
11
|
+
import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-64b3e636.js';
|
|
13
12
|
import { n as nanoid } from './index-9e71c815.js';
|
|
14
13
|
import { format as format$1 } from 'util';
|
|
15
|
-
import 'path';
|
|
16
14
|
import 'tty';
|
|
17
|
-
import '
|
|
15
|
+
import 'path';
|
|
18
16
|
|
|
19
17
|
var node = {
|
|
20
18
|
name: "node",
|
|
@@ -298,6 +296,91 @@ const environments = {
|
|
|
298
296
|
"happy-dom": happy
|
|
299
297
|
};
|
|
300
298
|
|
|
299
|
+
var chaiSubset = {exports: {}};
|
|
300
|
+
|
|
301
|
+
(function (module, exports) {
|
|
302
|
+
(function() {
|
|
303
|
+
(function(chaiSubset) {
|
|
304
|
+
if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
|
|
305
|
+
return module.exports = chaiSubset;
|
|
306
|
+
} else {
|
|
307
|
+
return chai.use(chaiSubset);
|
|
308
|
+
}
|
|
309
|
+
})(function(chai, utils) {
|
|
310
|
+
var Assertion = chai.Assertion;
|
|
311
|
+
var assertionPrototype = Assertion.prototype;
|
|
312
|
+
|
|
313
|
+
Assertion.addMethod('containSubset', function (expected) {
|
|
314
|
+
var actual = utils.flag(this, 'object');
|
|
315
|
+
var showDiff = chai.config.showDiff;
|
|
316
|
+
|
|
317
|
+
assertionPrototype.assert.call(this,
|
|
318
|
+
compare(expected, actual),
|
|
319
|
+
'expected #{act} to contain subset #{exp}',
|
|
320
|
+
'expected #{act} to not contain subset #{exp}',
|
|
321
|
+
expected,
|
|
322
|
+
actual,
|
|
323
|
+
showDiff
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
chai.assert.containSubset = function(val, exp, msg) {
|
|
328
|
+
new chai.Assertion(val, msg).to.be.containSubset(exp);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
function compare(expected, actual) {
|
|
332
|
+
if (expected === actual) {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if (typeof(actual) !== typeof(expected)) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (typeof(expected) !== 'object' || expected === null) {
|
|
339
|
+
return expected === actual;
|
|
340
|
+
}
|
|
341
|
+
if (!!expected && !actual) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (Array.isArray(expected)) {
|
|
346
|
+
if (typeof(actual.length) !== 'number') {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
var aa = Array.prototype.slice.call(actual);
|
|
350
|
+
return expected.every(function (exp) {
|
|
351
|
+
return aa.some(function (act) {
|
|
352
|
+
return compare(exp, act);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (expected instanceof Date) {
|
|
358
|
+
if (actual instanceof Date) {
|
|
359
|
+
return expected.getTime() === actual.getTime();
|
|
360
|
+
} else {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return Object.keys(expected).every(function (key) {
|
|
366
|
+
var eo = expected[key];
|
|
367
|
+
var ao = actual[key];
|
|
368
|
+
if (typeof(eo) === 'object' && eo !== null && ao !== null) {
|
|
369
|
+
return compare(eo, ao);
|
|
370
|
+
}
|
|
371
|
+
if (typeof(eo) === 'function') {
|
|
372
|
+
return eo(ao);
|
|
373
|
+
}
|
|
374
|
+
return ao === eo;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
}).call(commonjsGlobal);
|
|
380
|
+
}(chaiSubset));
|
|
381
|
+
|
|
382
|
+
var Subset = chaiSubset.exports;
|
|
383
|
+
|
|
301
384
|
var naturalCompare$2 = {exports: {}};
|
|
302
385
|
|
|
303
386
|
/*
|
|
@@ -3407,7 +3490,7 @@ function JestExtendPlugin(expects) {
|
|
|
3407
3490
|
c.expect.fail(message());
|
|
3408
3491
|
}
|
|
3409
3492
|
const expectAssertionWrapper = isAsyncFunction(expectAssertion) ? expectAsyncWrapper : expectSyncWrapper;
|
|
3410
|
-
utils.addMethod(chai.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
|
|
3493
|
+
utils.addMethod(chai$1.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
|
|
3411
3494
|
});
|
|
3412
3495
|
};
|
|
3413
3496
|
}
|
|
@@ -3788,11 +3871,11 @@ let installed = false;
|
|
|
3788
3871
|
async function setupChai() {
|
|
3789
3872
|
if (installed)
|
|
3790
3873
|
return;
|
|
3791
|
-
chai.use(JestExtend);
|
|
3792
|
-
chai.use(JestChaiExpect);
|
|
3793
|
-
chai.use(Subset);
|
|
3794
|
-
chai.use(SnapshotPlugin);
|
|
3795
|
-
chai.use(JestAsymmetricMatchers);
|
|
3874
|
+
chai$1.use(JestExtend);
|
|
3875
|
+
chai$1.use(JestChaiExpect);
|
|
3876
|
+
chai$1.use(Subset);
|
|
3877
|
+
chai$1.use(SnapshotPlugin);
|
|
3878
|
+
chai$1.use(JestAsymmetricMatchers);
|
|
3796
3879
|
installed = true;
|
|
3797
3880
|
}
|
|
3798
3881
|
|
|
@@ -3804,7 +3887,7 @@ async function setupGlobalEnv(config) {
|
|
|
3804
3887
|
setupConsoleLogSpy();
|
|
3805
3888
|
await setupChai();
|
|
3806
3889
|
if (config.global)
|
|
3807
|
-
(await import('./global-
|
|
3890
|
+
(await import('./global-12f52a87.js')).registerApiGlobally();
|
|
3808
3891
|
}
|
|
3809
3892
|
function setupConsoleLogSpy() {
|
|
3810
3893
|
const stdout = new Writable({
|
|
@@ -3893,12 +3976,12 @@ async function collectTests(paths, config) {
|
|
|
3893
3976
|
filepath,
|
|
3894
3977
|
tasks: []
|
|
3895
3978
|
};
|
|
3896
|
-
setHooks(file, createSuiteHooks());
|
|
3897
3979
|
clearContext();
|
|
3898
3980
|
try {
|
|
3899
3981
|
await runSetupFiles(config);
|
|
3900
3982
|
await import(filepath);
|
|
3901
3983
|
const defaultTasks = await defaultSuite.collect(file);
|
|
3984
|
+
setHooks(file, getHooks(defaultTasks));
|
|
3902
3985
|
for (const c of [...defaultTasks.tasks, ...context.tasks]) {
|
|
3903
3986
|
if (c.type === "test") {
|
|
3904
3987
|
file.tasks.push(c);
|
|
@@ -3959,6 +4042,15 @@ async function runTest(test) {
|
|
|
3959
4042
|
test.result.state = "fail";
|
|
3960
4043
|
test.result.error = processError(e);
|
|
3961
4044
|
}
|
|
4045
|
+
if (test.fails) {
|
|
4046
|
+
if (test.result.state === "pass") {
|
|
4047
|
+
test.result.state = "fail";
|
|
4048
|
+
test.result.error = processError(new Error("Expect test to fail"));
|
|
4049
|
+
} else {
|
|
4050
|
+
test.result.state = "pass";
|
|
4051
|
+
test.result.error = void 0;
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
3962
4054
|
getSnapshotClient().clearTest();
|
|
3963
4055
|
test.result.end = performance.now();
|
|
3964
4056
|
process.__vitest_worker__.current = void 0;
|