vitest 0.0.115 → 0.0.119
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 +27 -28
- package/dist/cli.js +30 -11
- package/dist/{constants-5968a78c.js → constants-22bbd600.js} +1 -1
- package/dist/{diff-67678e1f.js → diff-a295cb37.js} +1 -1
- package/dist/entry.js +95 -16
- package/dist/{global-bc40af7c.js → global-8f03a13e.js} +4 -4
- package/dist/{index-7c024e16.js → index-090545ef.js} +3 -20
- package/dist/{index-7f57c252.js → index-31a38185.js} +1 -1
- package/dist/{index-b4f86684.js → index-478354a1.js} +67 -58
- package/dist/index.d.ts +33 -19
- package/dist/index.js +3 -3
- package/dist/node.d.ts +22 -17
- package/dist/node.js +4 -4
- package/dist/setup-638014f2.js +4318 -0
- package/dist/utils.js +1 -1
- package/dist/{vi-2115c609.js → vi-092f86e3.js} +30 -16
- package/dist/worker.js +17 -8
- package/package.json +5 -6
- package/dist/middleware-647438b9.js +0 -81
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as deepMerge, e as ensurePackageInstalled, g as getFullName,
|
|
1
|
+
export { l as deepMerge, e as ensurePackageInstalled, g as getFullName, v as getNames, f as getSuites, z as getTasks, j as getTests, h as hasFailed, x as hasTests, i as isObject, y as isWindows, p as mergeSlashes, n as noop, o as notNullish, w as partitionSuiteChildren, k as resolvePath, s as slash, t as toArray, m as toFilePath } from './index-090545ef.js';
|
|
2
2
|
import 'url';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'local-pkg';
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { n as noop, i as isObject } from './index-
|
|
1
|
+
import { n as noop, i as isObject } from './index-090545ef.js';
|
|
2
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
|
|
3
3
|
import { a as spyOn, f as fn, s as spies } from './jest-mock-4a754991.js';
|
|
4
4
|
|
|
5
|
-
let urlAlphabet =
|
|
6
|
-
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
7
|
-
let nanoid = (size = 21) => {
|
|
8
|
-
let id = '';
|
|
9
|
-
let i = size;
|
|
10
|
-
while (i--) {
|
|
11
|
-
id += urlAlphabet[(Math.random() * 64) | 0];
|
|
12
|
-
}
|
|
13
|
-
return id
|
|
14
|
-
};
|
|
15
|
-
|
|
16
5
|
var __defProp = Object.defineProperty;
|
|
17
6
|
var __defProps = Object.defineProperties;
|
|
18
7
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -145,7 +134,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
145
134
|
const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
146
135
|
const computeMode = this.concurrent ? "concurrent" : void 0;
|
|
147
136
|
const test3 = {
|
|
148
|
-
id:
|
|
137
|
+
id: "",
|
|
149
138
|
type: "test",
|
|
150
139
|
name: name2,
|
|
151
140
|
mode: mode2,
|
|
@@ -171,7 +160,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
171
160
|
}
|
|
172
161
|
function initSuite() {
|
|
173
162
|
suite2 = {
|
|
174
|
-
id:
|
|
163
|
+
id: "",
|
|
175
164
|
type: "suite",
|
|
176
165
|
computeMode: "serial",
|
|
177
166
|
name,
|
|
@@ -440,6 +429,31 @@ const subsetEquality = (object, subset) => {
|
|
|
440
429
|
};
|
|
441
430
|
return subsetEqualityWithContext()(object, subset);
|
|
442
431
|
};
|
|
432
|
+
const typeEquality = (a, b) => {
|
|
433
|
+
if (a == null || b == null || a.constructor === b.constructor)
|
|
434
|
+
return void 0;
|
|
435
|
+
return false;
|
|
436
|
+
};
|
|
437
|
+
const arrayBufferEquality = (a, b) => {
|
|
438
|
+
if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer))
|
|
439
|
+
return void 0;
|
|
440
|
+
const dataViewA = new DataView(a);
|
|
441
|
+
const dataViewB = new DataView(b);
|
|
442
|
+
if (dataViewA.byteLength !== dataViewB.byteLength)
|
|
443
|
+
return false;
|
|
444
|
+
for (let i = 0; i < dataViewA.byteLength; i++) {
|
|
445
|
+
if (dataViewA.getUint8(i) !== dataViewB.getUint8(i))
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
return true;
|
|
449
|
+
};
|
|
450
|
+
const sparseArrayEquality = (a, b) => {
|
|
451
|
+
if (!Array.isArray(a) || !Array.isArray(b))
|
|
452
|
+
return void 0;
|
|
453
|
+
const aKeys = Object.keys(a);
|
|
454
|
+
const bKeys = Object.keys(b);
|
|
455
|
+
return equals(a, b, [iterableEquality, typeEquality], true) && equals(aKeys, bKeys);
|
|
456
|
+
};
|
|
443
457
|
|
|
444
458
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
445
459
|
if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
|
|
@@ -498,7 +512,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
498
512
|
return this.eql(expected);
|
|
499
513
|
});
|
|
500
514
|
def("toStrictEqual", function(expected) {
|
|
501
|
-
return this
|
|
515
|
+
return iterableEquality(this, expected) ?? typeEquality(this, expected) ?? sparseArrayEquality(this, expected) ?? arrayBufferEquality(this, expected);
|
|
502
516
|
});
|
|
503
517
|
def("toBe", function(expected) {
|
|
504
518
|
return this.equal(expected);
|
|
@@ -1025,4 +1039,4 @@ class VitestUtils {
|
|
|
1025
1039
|
const vitest = new VitestUtils();
|
|
1026
1040
|
const vi = vitest;
|
|
1027
1041
|
|
|
1028
|
-
export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m,
|
|
1042
|
+
export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m, setHooks as n, getHooks as o, context as p, getFn as q, setState as s, test as t, vitest as v, withTimeout as w };
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as dirname$2, b as basename$2, k as resolve, p as mergeSlashes, q as join$2, s as slash, m as toFilePath } from './index-090545ef.js';
|
|
2
2
|
import { c as createBirpc } from './index-e909c175.js';
|
|
3
|
-
import { c as distDir } from './constants-
|
|
3
|
+
import { c as distDir } from './constants-22bbd600.js';
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
|
|
6
6
|
import vm from 'vm';
|
|
@@ -9218,13 +9218,15 @@ var __spreadValues = (a, b) => {
|
|
|
9218
9218
|
};
|
|
9219
9219
|
function resolveMockPath(mockPath, root, nmName) {
|
|
9220
9220
|
if (nmName) {
|
|
9221
|
-
const
|
|
9221
|
+
const mockDirname = dirname$2(nmName);
|
|
9222
|
+
const baseFilename = basename$2(nmName);
|
|
9223
|
+
const mockFolder = resolve(root, "__mocks__", mockDirname);
|
|
9222
9224
|
if (!existsSync(mockFolder))
|
|
9223
9225
|
return null;
|
|
9224
9226
|
const files = readdirSync(mockFolder);
|
|
9225
9227
|
for (const file of files) {
|
|
9226
9228
|
const [basename2] = file.split(".");
|
|
9227
|
-
if (basename2 ===
|
|
9229
|
+
if (basename2 === baseFilename)
|
|
9228
9230
|
return resolve(mockFolder, file).replace(root, "");
|
|
9229
9231
|
}
|
|
9230
9232
|
return null;
|
|
@@ -9306,6 +9308,11 @@ function createMocker(root, mockMap) {
|
|
|
9306
9308
|
s.mockClear();
|
|
9307
9309
|
});
|
|
9308
9310
|
}
|
|
9311
|
+
function resolveDependency(dep) {
|
|
9312
|
+
if (dep.startsWith("/node_modules/"))
|
|
9313
|
+
return mergeSlashes(`/@fs/${join$2(root, dep)}`);
|
|
9314
|
+
return dep;
|
|
9315
|
+
}
|
|
9309
9316
|
return {
|
|
9310
9317
|
mockPath,
|
|
9311
9318
|
unmockPath,
|
|
@@ -9313,7 +9320,8 @@ function createMocker(root, mockMap) {
|
|
|
9313
9320
|
getActualPath,
|
|
9314
9321
|
mockObject,
|
|
9315
9322
|
getSuiteFilepath,
|
|
9316
|
-
resolveMockPath
|
|
9323
|
+
resolveMockPath,
|
|
9324
|
+
resolveDependency
|
|
9317
9325
|
};
|
|
9318
9326
|
}
|
|
9319
9327
|
|
|
@@ -9374,7 +9382,8 @@ async function executeInViteNode(options) {
|
|
|
9374
9382
|
mockPath,
|
|
9375
9383
|
clearMocks,
|
|
9376
9384
|
unmockPath,
|
|
9377
|
-
resolveMockPath
|
|
9385
|
+
resolveMockPath,
|
|
9386
|
+
resolveDependency
|
|
9378
9387
|
} = createMocker(root, mockMap);
|
|
9379
9388
|
const result = [];
|
|
9380
9389
|
for (const file of files)
|
|
@@ -9397,7 +9406,7 @@ async function executeInViteNode(options) {
|
|
|
9397
9406
|
var _a;
|
|
9398
9407
|
if (canMock) {
|
|
9399
9408
|
const mocks2 = mockMap[suite || ""] || {};
|
|
9400
|
-
const mock = mocks2[dep];
|
|
9409
|
+
const mock = mocks2[resolveDependency(dep)];
|
|
9401
9410
|
if (typeof mock === "function")
|
|
9402
9411
|
return callFunctionMock(dep, mock);
|
|
9403
9412
|
if (typeof mock === "string")
|
|
@@ -9596,7 +9605,7 @@ function init(ctx) {
|
|
|
9596
9605
|
config,
|
|
9597
9606
|
rpc: createBirpc({
|
|
9598
9607
|
functions: {},
|
|
9599
|
-
eventNames: ["onUserLog", "onCollected", "
|
|
9608
|
+
eventNames: ["onUserLog", "onCollected", "onWorkerExit"],
|
|
9600
9609
|
post(v) {
|
|
9601
9610
|
port.postMessage(v);
|
|
9602
9611
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.119",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@types/jsdom": "^16.2.14",
|
|
61
61
|
"@types/micromatch": "^4.0.2",
|
|
62
62
|
"@types/natural-compare": "^1.4.1",
|
|
63
|
-
"@types/node": "^17.0.
|
|
63
|
+
"@types/node": "^17.0.5",
|
|
64
64
|
"@types/prompts": "^2.4.0",
|
|
65
65
|
"birpc": "^0.0.2",
|
|
66
66
|
"c8": "^7.10.0",
|
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
"micromatch": "^4.0.4",
|
|
80
80
|
"mlly": "^0.3.16",
|
|
81
81
|
"mockdate": "^3.0.5",
|
|
82
|
-
"nanoid": "^3.1.30",
|
|
83
82
|
"natural-compare": "^1.4.0",
|
|
84
83
|
"pathe": "^0.2.0",
|
|
85
84
|
"picocolors": "^1.0.0",
|
|
@@ -89,7 +88,8 @@
|
|
|
89
88
|
"rollup": "^2.62.0",
|
|
90
89
|
"source-map-js": "^1.0.1",
|
|
91
90
|
"strip-ansi": "^7.0.1",
|
|
92
|
-
"typescript": "^4.5.4"
|
|
91
|
+
"typescript": "^4.5.4",
|
|
92
|
+
"ws": "^8.4.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"c8": "*",
|
|
@@ -113,8 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
"scripts": {
|
|
115
115
|
"build": "rimraf dist && rollup -c",
|
|
116
|
-
"dev": "rollup -c --watch src"
|
|
117
|
-
"typecheck": "tsc --noEmit"
|
|
116
|
+
"dev": "rollup -c --watch src"
|
|
118
117
|
},
|
|
119
118
|
"readme": "# vitest\n\n[](https://www.npmjs.com/package/vitest)\n\nA blazing fast unit test framework powered by Vite.\n\n> **This project is currently in closed beta exclusively for Sponsors.**<br>\n> Become a Sponsor of [@patak-dev](https://github.com/sponsors/patak-dev) or [@antfu](https://github.com/sponsors/antfu) to access the source code and issues tracker.\n> Learn more at [vitest.dev](https://vitest.dev)\n"
|
|
120
119
|
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { A as API_PATH } from './constants-5968a78c.js';
|
|
2
|
-
import 'url';
|
|
3
|
-
import './index-7c024e16.js';
|
|
4
|
-
import 'tty';
|
|
5
|
-
import 'local-pkg';
|
|
6
|
-
import 'path';
|
|
7
|
-
|
|
8
|
-
/*! (c) 2020 Andrea Giammarchi */
|
|
9
|
-
|
|
10
|
-
const {parse: $parse, stringify: $stringify} = JSON;
|
|
11
|
-
|
|
12
|
-
const Primitive = String; // it could be Number
|
|
13
|
-
const primitive = 'string'; // it could be 'number'
|
|
14
|
-
const object = 'object';
|
|
15
|
-
|
|
16
|
-
const noop = (_, value) => value;
|
|
17
|
-
|
|
18
|
-
const set = (known, input, value) => {
|
|
19
|
-
const index = Primitive(input.push(value) - 1);
|
|
20
|
-
known.set(value, index);
|
|
21
|
-
return index;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const stringify = (value, replacer, space) => {
|
|
25
|
-
const $ = replacer && typeof replacer === object ?
|
|
26
|
-
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
27
|
-
(replacer || noop);
|
|
28
|
-
const known = new Map;
|
|
29
|
-
const input = [];
|
|
30
|
-
const output = [];
|
|
31
|
-
let i = +set(known, input, $.call({'': value}, '', value));
|
|
32
|
-
let firstRun = !i;
|
|
33
|
-
while (i < input.length) {
|
|
34
|
-
firstRun = true;
|
|
35
|
-
output[i] = $stringify(input[i++], replace, space);
|
|
36
|
-
}
|
|
37
|
-
return '[' + output.join(',') + ']';
|
|
38
|
-
function replace(key, value) {
|
|
39
|
-
if (firstRun) {
|
|
40
|
-
firstRun = !firstRun;
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
const after = $.call(this, key, value);
|
|
44
|
-
switch (typeof after) {
|
|
45
|
-
case object:
|
|
46
|
-
if (after === null) return after;
|
|
47
|
-
case primitive:
|
|
48
|
-
return known.get(after) || set(known, input, after);
|
|
49
|
-
}
|
|
50
|
-
return after;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function sendFlatted(res, data) {
|
|
55
|
-
res.setHeader("Content-Type", "application/json");
|
|
56
|
-
res.write(stringify(data));
|
|
57
|
-
res.statusCode = 200;
|
|
58
|
-
res.end();
|
|
59
|
-
}
|
|
60
|
-
function middlewareAPI(ctx) {
|
|
61
|
-
return (req, res, next) => {
|
|
62
|
-
var _a;
|
|
63
|
-
if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
|
|
64
|
-
return next();
|
|
65
|
-
const url = req.url.slice(API_PATH.length);
|
|
66
|
-
if (url === "/") {
|
|
67
|
-
return sendFlatted(res, {
|
|
68
|
-
files: ctx.state.filesMap
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (url === "/files") {
|
|
72
|
-
return sendFlatted(res, {
|
|
73
|
-
files: Object.keys(ctx.state.filesMap)
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
res.statusCode = 404;
|
|
77
|
-
res.end();
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { middlewareAPI as default, sendFlatted };
|