vitest 0.0.91 → 0.0.92
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/bin/vitest.mjs +3 -2
- package/dist/cli.js +14 -9
- package/dist/entry.js +13 -7
- package/dist/{error-abd1f726.js → error-4b0c4b4b.js} +1 -1
- package/dist/index-40ecbcb4.js +5515 -0
- package/dist/index-5cc247ff.js +331 -0
- package/dist/index-e7a421bb.js +2409 -0
- package/dist/index-fa899e66.js +5707 -0
- package/dist/index.d.ts +3 -2
- package/dist/middleware-b1884a99.js +79 -0
- package/dist/node.js +7 -6
- package/dist/{utils-5d0cec8a.js → utils-860e5f7e.js} +18 -9
- package/dist/utils.js +2 -2
- package/dist/worker.js +2 -1
- package/package.json +6 -3
- package/dist/index-25bef3dd.js +0 -1896
- package/dist/middleware-52c3b35a.js +0 -34
package/dist/index.d.ts
CHANGED
|
@@ -291,6 +291,7 @@ interface SnapshotSummary {
|
|
|
291
291
|
updated: number;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
294
295
|
interface InlineConfig {
|
|
295
296
|
/**
|
|
296
297
|
* Include globs for test files
|
|
@@ -336,7 +337,7 @@ interface InlineConfig {
|
|
|
336
337
|
*
|
|
337
338
|
* @default 'node'
|
|
338
339
|
*/
|
|
339
|
-
environment?:
|
|
340
|
+
environment?: BuiltinEnvironment;
|
|
340
341
|
/**
|
|
341
342
|
* Update snapshot files
|
|
342
343
|
*
|
|
@@ -695,4 +696,4 @@ declare global {
|
|
|
695
696
|
}
|
|
696
697
|
}
|
|
697
698
|
|
|
698
|
-
export { ArgumentsType, Arrayable, Awaitable, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vi, vitest };
|
|
699
|
+
export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vi, vitest };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { A as API_PATH } from './constants-9cfa4d7b.js';
|
|
2
|
+
import 'path';
|
|
3
|
+
import 'url';
|
|
4
|
+
|
|
5
|
+
/*! (c) 2020 Andrea Giammarchi */
|
|
6
|
+
|
|
7
|
+
const {parse: $parse, stringify: $stringify} = JSON;
|
|
8
|
+
|
|
9
|
+
const Primitive = String; // it could be Number
|
|
10
|
+
const primitive = 'string'; // it could be 'number'
|
|
11
|
+
const object = 'object';
|
|
12
|
+
|
|
13
|
+
const noop = (_, value) => value;
|
|
14
|
+
|
|
15
|
+
const set = (known, input, value) => {
|
|
16
|
+
const index = Primitive(input.push(value) - 1);
|
|
17
|
+
known.set(value, index);
|
|
18
|
+
return index;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const stringify = (value, replacer, space) => {
|
|
22
|
+
const $ = replacer && typeof replacer === object ?
|
|
23
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
24
|
+
(replacer || noop);
|
|
25
|
+
const known = new Map;
|
|
26
|
+
const input = [];
|
|
27
|
+
const output = [];
|
|
28
|
+
let i = +set(known, input, $.call({'': value}, '', value));
|
|
29
|
+
let firstRun = !i;
|
|
30
|
+
while (i < input.length) {
|
|
31
|
+
firstRun = true;
|
|
32
|
+
output[i] = $stringify(input[i++], replace, space);
|
|
33
|
+
}
|
|
34
|
+
return '[' + output.join(',') + ']';
|
|
35
|
+
function replace(key, value) {
|
|
36
|
+
if (firstRun) {
|
|
37
|
+
firstRun = !firstRun;
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
const after = $.call(this, key, value);
|
|
41
|
+
switch (typeof after) {
|
|
42
|
+
case object:
|
|
43
|
+
if (after === null) return after;
|
|
44
|
+
case primitive:
|
|
45
|
+
return known.get(after) || set(known, input, after);
|
|
46
|
+
}
|
|
47
|
+
return after;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function sendFlatted(res, data) {
|
|
52
|
+
res.setHeader("Content-Type", "application/json");
|
|
53
|
+
res.write(stringify(data));
|
|
54
|
+
res.statusCode = 200;
|
|
55
|
+
res.end();
|
|
56
|
+
}
|
|
57
|
+
function middlewareAPI() {
|
|
58
|
+
return (req, res, next) => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
|
|
61
|
+
return next();
|
|
62
|
+
const url = req.url.slice(API_PATH.length);
|
|
63
|
+
const ctx = process.__vitest__;
|
|
64
|
+
if (url === "/") {
|
|
65
|
+
return sendFlatted(res, {
|
|
66
|
+
files: ctx.state.filesMap
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (url === "/files") {
|
|
70
|
+
return sendFlatted(res, {
|
|
71
|
+
files: Object.keys(ctx.state.filesMap)
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
res.statusCode = 404;
|
|
75
|
+
res.end();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { middlewareAPI as default, sendFlatted };
|
package/dist/node.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
1
|
+
export { c as createVitest } from './index-40ecbcb4.js';
|
|
2
2
|
import 'path';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'process';
|
|
5
5
|
import 'fs';
|
|
6
|
+
import 'fast-glob';
|
|
7
|
+
import 'util';
|
|
6
8
|
import './constants-9cfa4d7b.js';
|
|
7
9
|
import 'url';
|
|
8
|
-
import './utils-
|
|
9
|
-
import 'module';
|
|
10
|
+
import './utils-860e5f7e.js';
|
|
10
11
|
import 'tty';
|
|
12
|
+
import 'local-pkg';
|
|
11
13
|
import 'perf_hooks';
|
|
12
|
-
import './error-
|
|
14
|
+
import './error-4b0c4b4b.js';
|
|
13
15
|
import 'source-map';
|
|
16
|
+
import './index-5cc247ff.js';
|
|
14
17
|
import 'assert';
|
|
15
18
|
import 'events';
|
|
16
19
|
import 'worker_threads';
|
|
17
20
|
import 'piscina';
|
|
18
|
-
import 'fast-glob';
|
|
19
|
-
import 'micromatch';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
1
|
import require$$0 from 'tty';
|
|
2
|
+
import { isPackageExists } from 'local-pkg';
|
|
3
3
|
|
|
4
4
|
var picocolors = {exports: {}};
|
|
5
5
|
|
|
@@ -137,15 +137,24 @@ function getNames(task) {
|
|
|
137
137
|
}
|
|
138
138
|
return names;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
} catch {
|
|
145
|
-
console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Cound not find '${dependency}' peer dependency, please try installing it
|
|
140
|
+
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI) {
|
|
141
|
+
if (isPackageExists(dependency))
|
|
142
|
+
return true;
|
|
143
|
+
console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
146
144
|
`));
|
|
147
|
-
|
|
145
|
+
if (!promptInstall)
|
|
146
|
+
return false;
|
|
147
|
+
const prompts = await import('./index-fa899e66.js').then(function (n) { return n.i; });
|
|
148
|
+
const { install } = await prompts.prompt({
|
|
149
|
+
type: "confirm",
|
|
150
|
+
name: "install",
|
|
151
|
+
message: `Do you want to install ${c.green(dependency)}?`
|
|
152
|
+
});
|
|
153
|
+
if (install) {
|
|
154
|
+
await (await import('./index-e7a421bb.js')).installPackage(dependency);
|
|
155
|
+
return true;
|
|
148
156
|
}
|
|
157
|
+
return false;
|
|
149
158
|
}
|
|
150
159
|
|
|
151
|
-
export { getTests as a, getSuites as b, c, hasTests as d,
|
|
160
|
+
export { getTests as a, getSuites as b, c, hasTests as d, ensurePackageInstalled as e, getTasks as f, getNames as g, hasFailed as h, interpretOnlyMode as i, notNullish as n, partitionSuiteChildren as p, slash as s, toArray as t };
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { e as ensurePackageInstalled, g as getNames, b as getSuites, f as getTasks, a as getTests, h as hasFailed, d as hasTests, i as interpretOnlyMode, n as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-860e5f7e.js';
|
|
2
|
+
import 'local-pkg';
|
|
3
3
|
import 'tty';
|
package/dist/worker.js
CHANGED
|
@@ -4,12 +4,13 @@ import { c as distDir } from './constants-9cfa4d7b.js';
|
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath, URL as URL$1 } from 'url';
|
|
6
6
|
import vm from 'vm';
|
|
7
|
-
import { s as slash } from './utils-
|
|
7
|
+
import { s as slash } from './utils-860e5f7e.js';
|
|
8
8
|
import fs, { realpathSync, statSync, Stats, promises } from 'fs';
|
|
9
9
|
import assert from 'assert';
|
|
10
10
|
import { format as format$3, inspect } from 'util';
|
|
11
11
|
import { s as send } from './rpc-7de86f29.js';
|
|
12
12
|
import 'tty';
|
|
13
|
+
import 'local-pkg';
|
|
13
14
|
|
|
14
15
|
function normalizeWindowsPath$2(input = "") {
|
|
15
16
|
if (!input.includes("\\")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -51,19 +51,21 @@
|
|
|
51
51
|
"chai": "^4.3.4",
|
|
52
52
|
"chai-subset": "^1.6.0",
|
|
53
53
|
"fast-glob": "^3.2.7",
|
|
54
|
-
"flatted": "^3.2.4",
|
|
55
54
|
"local-pkg": "^0.4.0",
|
|
56
|
-
"micromatch": "^4.0.4",
|
|
57
55
|
"piscina": "^3.2.0",
|
|
58
56
|
"source-map": "^0.7.3",
|
|
59
57
|
"tinyspy": "^0.1.0"
|
|
60
58
|
},
|
|
61
59
|
"devDependencies": {
|
|
60
|
+
"flatted": "^3.2.4",
|
|
61
|
+
"micromatch": "^4.0.4",
|
|
62
|
+
"@antfu/install-pkg": "^0.1.0",
|
|
62
63
|
"@types/diff": "^5.0.1",
|
|
63
64
|
"@types/jsdom": "^16.2.13",
|
|
64
65
|
"@types/micromatch": "^4.0.2",
|
|
65
66
|
"@types/natural-compare": "^1.4.1",
|
|
66
67
|
"@types/node": "^17.0.0",
|
|
68
|
+
"@types/prompts": "^2.0.14",
|
|
67
69
|
"c8": "^7.10.0",
|
|
68
70
|
"cac": "^6.7.12",
|
|
69
71
|
"cli-truncate": "^3.1.0",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"picocolors": "^1.0.0",
|
|
80
82
|
"pkg-types": "^0.3.2",
|
|
81
83
|
"pretty-format": "^27.4.2",
|
|
84
|
+
"prompts": "^2.4.2",
|
|
82
85
|
"rollup": "^2.61.1",
|
|
83
86
|
"strip-ansi": "^7.0.1",
|
|
84
87
|
"typescript": "^4.5.4"
|