vitest 0.0.85 → 0.0.87
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 +3 -3
- package/dist/entry.js +1 -1
- package/dist/{error-c651f5ae.js → error-c5d734a1.js} +2 -0
- package/dist/{index-c033f95e.js → index-af5d5277.js} +37 -31
- package/dist/node.js +2 -2
- package/dist/worker.js +8255 -32
- package/package.json +4 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { c } from './error-
|
|
3
|
-
import { c as createVitest } from './index-
|
|
2
|
+
import { c } from './error-c5d734a1.js';
|
|
3
|
+
import { c as createVitest } from './index-af5d5277.js';
|
|
4
4
|
import 'fs';
|
|
5
5
|
import 'path';
|
|
6
6
|
import 'tty';
|
|
@@ -631,7 +631,7 @@ class CAC extends EventEmitter {
|
|
|
631
631
|
|
|
632
632
|
const cac = (name = "") => new CAC(name);
|
|
633
633
|
|
|
634
|
-
var version = "0.0.
|
|
634
|
+
var version = "0.0.87";
|
|
635
635
|
|
|
636
636
|
const cli = cac("vitest");
|
|
637
637
|
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", {
|
package/dist/entry.js
CHANGED
|
@@ -7,7 +7,7 @@ import path, { basename } from 'path';
|
|
|
7
7
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
8
8
|
import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
|
|
9
9
|
import fs from 'fs';
|
|
10
|
-
import { c as c$1, u as unifiedDiff } from './error-
|
|
10
|
+
import { c as c$1, u as unifiedDiff } from './error-c5d734a1.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-0e21bf9b.js';
|
|
13
13
|
import { n as nanoid } from './index-9e71c815.js';
|
|
@@ -1358,6 +1358,8 @@ function posToNumber(source, pos) {
|
|
|
1358
1358
|
const lines = source.split(splitRE);
|
|
1359
1359
|
const { line, column } = pos;
|
|
1360
1360
|
let start = 0;
|
|
1361
|
+
if (line > lines.length)
|
|
1362
|
+
return source.length;
|
|
1361
1363
|
for (let i = 0; i < line - 1; i++)
|
|
1362
1364
|
start += lines[i].length + 1;
|
|
1363
1365
|
return start + column;
|
|
@@ -5,8 +5,8 @@ import { promises } from 'fs';
|
|
|
5
5
|
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-adef7ffb.js';
|
|
6
6
|
import { g as getNames, s as slash, a as getTests, b as getSuites, t as toArray, h as hasFailed } from './utils-9dcc4050.js';
|
|
7
7
|
import { performance } from 'perf_hooks';
|
|
8
|
-
import { s as stringWidth, a as ansiStyles, b as stripAnsi, d as sliceAnsi, c, F as F_POINTER, e as F_DOWN, f as F_LONG_DASH, g as F_DOWN_RIGHT, h as F_DOT, i as F_CHECK, j as F_CROSS, k as cliTruncate, l as F_RIGHT, p as printError } from './error-
|
|
9
|
-
import
|
|
8
|
+
import { s as stringWidth, a as ansiStyles, b as stripAnsi, d as sliceAnsi, c, F as F_POINTER, e as F_DOWN, f as F_LONG_DASH, g as F_DOWN_RIGHT, h as F_DOT, i as F_CHECK, j as F_CROSS, k as cliTruncate, l as F_RIGHT, p as printError } from './error-c5d734a1.js';
|
|
9
|
+
import assert$1 from 'assert';
|
|
10
10
|
import require$$2 from 'events';
|
|
11
11
|
import { MessageChannel } from 'worker_threads';
|
|
12
12
|
import { pathToFileURL } from 'url';
|
|
@@ -644,7 +644,7 @@ const processOk = function (process) {
|
|
|
644
644
|
if (!processOk(process$1)) {
|
|
645
645
|
signalExit$1.exports = function () {};
|
|
646
646
|
} else {
|
|
647
|
-
var assert =
|
|
647
|
+
var assert = assert$1;
|
|
648
648
|
var signals = signals$1.exports;
|
|
649
649
|
var isWin = /^win/i.test(process$1.platform);
|
|
650
650
|
|
|
@@ -1609,21 +1609,24 @@ function createPool(ctx) {
|
|
|
1609
1609
|
}
|
|
1610
1610
|
const workerPath = new URL("./dist/worker.js", pathToFileURL(distDir)).href;
|
|
1611
1611
|
function createFakePool(ctx) {
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1612
|
+
const runWithFiles = (name) => {
|
|
1613
|
+
return async (files, invalidates) => {
|
|
1614
|
+
const worker = await import(workerPath);
|
|
1615
|
+
const { workerPort, port } = createChannel(ctx);
|
|
1616
|
+
const data = {
|
|
1617
|
+
port: workerPort,
|
|
1618
|
+
config: ctx.config,
|
|
1619
|
+
files,
|
|
1620
|
+
invalidates
|
|
1621
|
+
};
|
|
1622
|
+
await worker[name](data, { transferList: [workerPort] });
|
|
1623
|
+
port.close();
|
|
1624
|
+
workerPort.close();
|
|
1620
1625
|
};
|
|
1621
|
-
await run(data, { transferList: [workerPort] });
|
|
1622
|
-
port.close();
|
|
1623
|
-
workerPort.close();
|
|
1624
1626
|
};
|
|
1625
1627
|
return {
|
|
1626
|
-
|
|
1628
|
+
runTests: runWithFiles("run"),
|
|
1629
|
+
collectTests: runWithFiles("collect"),
|
|
1627
1630
|
close: async () => {
|
|
1628
1631
|
}
|
|
1629
1632
|
};
|
|
@@ -1638,22 +1641,25 @@ function createWorkerPool(ctx) {
|
|
|
1638
1641
|
if (ctx.config.minThreads != null)
|
|
1639
1642
|
options.minThreads = ctx.config.minThreads;
|
|
1640
1643
|
const piscina = new Piscina(options);
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1644
|
+
const runWithFiles = (name) => {
|
|
1645
|
+
return async (files, invalidates) => {
|
|
1646
|
+
await Promise.all(files.map(async (file) => {
|
|
1647
|
+
const { workerPort, port } = createChannel(ctx);
|
|
1648
|
+
const data = {
|
|
1649
|
+
port: workerPort,
|
|
1650
|
+
config: ctx.config,
|
|
1651
|
+
files: [file],
|
|
1652
|
+
invalidates
|
|
1653
|
+
};
|
|
1654
|
+
await piscina.run(data, { transferList: [workerPort], name });
|
|
1655
|
+
port.close();
|
|
1656
|
+
workerPort.close();
|
|
1657
|
+
}));
|
|
1658
|
+
};
|
|
1654
1659
|
};
|
|
1655
1660
|
return {
|
|
1656
|
-
|
|
1661
|
+
runTests: runWithFiles("run"),
|
|
1662
|
+
collectTests: runWithFiles("collect"),
|
|
1657
1663
|
close: () => piscina.destroy()
|
|
1658
1664
|
};
|
|
1659
1665
|
}
|
|
@@ -1772,7 +1778,7 @@ async function startWatcher(ctx) {
|
|
|
1772
1778
|
async function start(tests, id, invalidates) {
|
|
1773
1779
|
var _a;
|
|
1774
1780
|
await ctx.report("onWatcherRerun", tests, id);
|
|
1775
|
-
await ((_a = ctx.pool) == null ? void 0 : _a.
|
|
1781
|
+
await ((_a = ctx.pool) == null ? void 0 : _a.runTests(tests, invalidates));
|
|
1776
1782
|
await ctx.report("onFinished", ctx.state.getFiles(tests));
|
|
1777
1783
|
await ctx.report("onWatcherStart");
|
|
1778
1784
|
}
|
|
@@ -1832,7 +1838,7 @@ class Vitest {
|
|
|
1832
1838
|
}
|
|
1833
1839
|
if (!this.pool)
|
|
1834
1840
|
this.pool = createPool(this);
|
|
1835
|
-
await this.pool.
|
|
1841
|
+
await this.pool.runTests(testFilepaths);
|
|
1836
1842
|
if (hasFailed(this.state.getFiles()))
|
|
1837
1843
|
process.exitCode = 1;
|
|
1838
1844
|
await this.report("onFinished", this.state.getFiles());
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
1
|
+
export { c as createVitest } from './index-af5d5277.js';
|
|
2
2
|
import 'path';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'process';
|
|
@@ -7,7 +7,7 @@ import './constants-adef7ffb.js';
|
|
|
7
7
|
import 'url';
|
|
8
8
|
import './utils-9dcc4050.js';
|
|
9
9
|
import 'perf_hooks';
|
|
10
|
-
import './error-
|
|
10
|
+
import './error-c5d734a1.js';
|
|
11
11
|
import 'tty';
|
|
12
12
|
import 'source-map';
|
|
13
13
|
import 'assert';
|