vitest 0.0.116 → 0.0.117
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/dist/cli.js +5 -4
- package/dist/entry.js +11 -5
- package/dist/{global-a73dfade.js → global-d95ee155.js} +2 -2
- package/dist/{index-80d9a771.js → index-2b1f526f.js} +1 -1
- package/dist/{index-1af8810e.js → index-33d800eb.js} +11 -29
- package/dist/index.js +2 -2
- package/dist/node.js +1 -1
- package/dist/{vi-b3412f83.js → vi-39f06eb7.js} +26 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709
|
|
|
8
8
|
import require$$0, { constants } from 'os';
|
|
9
9
|
import { s as signalExit } from './index-648e7ab2.js';
|
|
10
10
|
import { e as ensurePackageInstalled } from './index-bf29f0e6.js';
|
|
11
|
-
import { c as createVitest } from './index-
|
|
11
|
+
import { c as createVitest } from './index-33d800eb.js';
|
|
12
12
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
import 'fs';
|
|
14
14
|
import 'stream';
|
|
@@ -1700,7 +1700,7 @@ function execa(file, args, options) {
|
|
|
1700
1700
|
return mergePromise(spawned, handlePromiseOnce);
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
|
-
var version = "0.0.
|
|
1703
|
+
var version = "0.0.117";
|
|
1704
1704
|
|
|
1705
1705
|
const cli = cac("vitest");
|
|
1706
1706
|
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 UI", { default: false }).option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
|
|
@@ -1750,8 +1750,9 @@ async function run(cliFilters, options) {
|
|
|
1750
1750
|
if (!ctx.config.watch)
|
|
1751
1751
|
await ctx.close();
|
|
1752
1752
|
}
|
|
1753
|
-
if (!ctx.config.watch)
|
|
1754
|
-
process.exit();
|
|
1753
|
+
if (!ctx.config.watch) {
|
|
1754
|
+
setTimeout(() => process.exit(), 1e3).unref();
|
|
1755
|
+
}
|
|
1755
1756
|
}
|
|
1756
1757
|
function registerConsoleShortcuts(ctx) {
|
|
1757
1758
|
require$$0$1.emitKeypressEvents(process.stdin);
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-
|
|
2
|
+
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-39f06eb7.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
@@ -3532,7 +3532,7 @@ async function setupGlobalEnv(config) {
|
|
|
3532
3532
|
setupConsoleLogSpy();
|
|
3533
3533
|
await setupChai();
|
|
3534
3534
|
if (config.global)
|
|
3535
|
-
(await import('./global-
|
|
3535
|
+
(await import('./global-d95ee155.js')).registerApiGlobally();
|
|
3536
3536
|
}
|
|
3537
3537
|
function setupConsoleLogSpy() {
|
|
3538
3538
|
const stdout = new Writable({
|
|
@@ -3596,9 +3596,15 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
3596
3596
|
if (seen.has(val))
|
|
3597
3597
|
return val;
|
|
3598
3598
|
seen.add(val);
|
|
3599
|
-
|
|
3600
|
-
val
|
|
3601
|
-
|
|
3599
|
+
if (Array.isArray(val)) {
|
|
3600
|
+
val = val.map((e) => {
|
|
3601
|
+
return serializeError(e, seen);
|
|
3602
|
+
});
|
|
3603
|
+
} else {
|
|
3604
|
+
Object.keys(val).forEach((key) => {
|
|
3605
|
+
val[key] = serializeError(val[key], seen);
|
|
3606
|
+
});
|
|
3607
|
+
}
|
|
3602
3608
|
return val;
|
|
3603
3609
|
}
|
|
3604
3610
|
function processError(err) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { g as globalApis } from './constants-080f26e8.js';
|
|
2
|
-
import { i as index } from './index-
|
|
2
|
+
import { i as index } from './index-2b1f526f.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './index-bf29f0e6.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-39f06eb7.js';
|
|
9
9
|
import './_commonjsHelpers-c9e3b764.js';
|
|
10
10
|
import './jest-mock-4a754991.js';
|
|
11
11
|
import 'chai';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-39f06eb7.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
3
|
import { s as spies, a as spyOn, f as fn } from './jest-mock-4a754991.js';
|
|
4
4
|
|
|
@@ -7707,9 +7707,8 @@ class DefaultReporter extends BaseReporter {
|
|
|
7707
7707
|
}
|
|
7708
7708
|
async stopListRender() {
|
|
7709
7709
|
var _a;
|
|
7710
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
7710
|
+
await ((_a = this.renderer) == null ? void 0 : _a.stop());
|
|
7711
7711
|
this.renderer = void 0;
|
|
7712
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
7713
7712
|
}
|
|
7714
7713
|
async onWatcherRerun(files, trigger) {
|
|
7715
7714
|
await this.stopListRender();
|
|
@@ -7864,7 +7863,7 @@ function resolveC8Options(options, root) {
|
|
|
7864
7863
|
reportsDirectory: "./coverage",
|
|
7865
7864
|
excludeNodeModules: true,
|
|
7866
7865
|
exclude: defaultExcludes,
|
|
7867
|
-
reporter: "text",
|
|
7866
|
+
reporter: ["text", "html"],
|
|
7868
7867
|
allowExternal: false
|
|
7869
7868
|
}, options);
|
|
7870
7869
|
resolved.reporter = toArray(resolved.reporter);
|
|
@@ -7878,18 +7877,12 @@ async function cleanCoverage(options, clean = true) {
|
|
|
7878
7877
|
if (!existsSync(options.tempDirectory))
|
|
7879
7878
|
await promises.mkdir(options.tempDirectory, { recursive: true });
|
|
7880
7879
|
}
|
|
7881
|
-
async function prepareCoverage(options) {
|
|
7882
|
-
if (options.enabled)
|
|
7883
|
-
return false;
|
|
7884
|
-
await cleanCoverage(options, options.clean);
|
|
7885
|
-
}
|
|
7886
7880
|
const require2 = createRequire(import.meta.url);
|
|
7887
7881
|
async function reportCoverage(ctx) {
|
|
7888
7882
|
const createReport = require2("c8/lib/report");
|
|
7889
7883
|
const report = createReport(ctx.config.coverage);
|
|
7884
|
+
await report.getCoverageMapFromAllCoverageFiles();
|
|
7890
7885
|
Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
|
|
7891
|
-
if (!existsSync(file))
|
|
7892
|
-
return;
|
|
7893
7886
|
const url = pathToFileURL(file).href;
|
|
7894
7887
|
report.sourceMapCache[url] = {
|
|
7895
7888
|
data: __spreadProps$1(__spreadValues$1({}, map), {
|
|
@@ -8010,23 +8003,8 @@ async function _transformRequest(ctx, id) {
|
|
|
8010
8003
|
if (result)
|
|
8011
8004
|
result = await ctx.server.ssrTransform(result.code, result.map, id);
|
|
8012
8005
|
}
|
|
8013
|
-
if (result && process.env.NODE_V8_COVERAGE)
|
|
8014
|
-
|
|
8015
|
-
if (result.map)
|
|
8016
|
-
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
8017
|
-
}
|
|
8018
|
-
return result;
|
|
8019
|
-
}
|
|
8020
|
-
let SOURCEMAPPING_URL = "sourceMa";
|
|
8021
|
-
SOURCEMAPPING_URL += "ppingURL";
|
|
8022
|
-
async function withInlineSourcemap(result) {
|
|
8023
|
-
const { code, map } = result;
|
|
8024
|
-
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
8025
|
-
return result;
|
|
8026
|
-
if (map)
|
|
8027
|
-
result.code = `${code}
|
|
8028
|
-
|
|
8029
|
-
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
|
|
8006
|
+
if ((result == null ? void 0 : result.map) && process.env.NODE_V8_COVERAGE)
|
|
8007
|
+
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
8030
8008
|
return result;
|
|
8031
8009
|
}
|
|
8032
8010
|
|
|
@@ -8093,7 +8071,8 @@ function createWorkerPool(ctx) {
|
|
|
8093
8071
|
return {
|
|
8094
8072
|
runTests: runWithFiles("run"),
|
|
8095
8073
|
collectTests: runWithFiles("collect"),
|
|
8096
|
-
close: () =>
|
|
8074
|
+
close: async () => {
|
|
8075
|
+
}
|
|
8097
8076
|
};
|
|
8098
8077
|
}
|
|
8099
8078
|
function createChannel(ctx) {
|
|
@@ -8190,7 +8169,7 @@ class Vitest {
|
|
|
8190
8169
|
this.runningPromise = void 0;
|
|
8191
8170
|
this._onRestartListeners.forEach((fn) => fn());
|
|
8192
8171
|
if (resolved.coverage.enabled)
|
|
8193
|
-
await
|
|
8172
|
+
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
8194
8173
|
}
|
|
8195
8174
|
async start(filters) {
|
|
8196
8175
|
this.report("onInit", this);
|
|
@@ -8365,6 +8344,9 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8365
8344
|
open: options.open,
|
|
8366
8345
|
strictPort: true
|
|
8367
8346
|
},
|
|
8347
|
+
build: {
|
|
8348
|
+
sourcemap: true
|
|
8349
|
+
},
|
|
8368
8350
|
optimizeDeps: {
|
|
8369
8351
|
exclude: [
|
|
8370
8352
|
"vitest"
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-39f06eb7.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-2b1f526f.js';
|
|
3
3
|
export { f as fn, s as spies, a as spyOn } from './jest-mock-4a754991.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
5
|
import './index-bf29f0e6.js';
|
package/dist/node.js
CHANGED
|
@@ -429,6 +429,31 @@ const subsetEquality = (object, subset) => {
|
|
|
429
429
|
};
|
|
430
430
|
return subsetEqualityWithContext()(object, subset);
|
|
431
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
|
+
};
|
|
432
457
|
|
|
433
458
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
434
459
|
if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
|
|
@@ -487,7 +512,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
487
512
|
return this.eql(expected);
|
|
488
513
|
});
|
|
489
514
|
def("toStrictEqual", function(expected) {
|
|
490
|
-
return this
|
|
515
|
+
return iterableEquality(this, expected) ?? typeEquality(this, expected) ?? sparseArrayEquality(this, expected) ?? arrayBufferEquality(this, expected);
|
|
491
516
|
});
|
|
492
517
|
def("toBe", function(expected) {
|
|
493
518
|
return this.equal(expected);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.117",
|
|
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",
|