vitest 0.0.103 → 0.0.104
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 +44 -0
- package/dist/cli.js +7 -5
- package/dist/{constants-a1417084.js → constants-c4dc2ff5.js} +1 -1
- package/dist/entry.js +29 -4
- package/dist/{error-0e2f75a4.js → error-796962c6.js} +1 -1
- package/dist/{global-12f52a87.js → global-166f6789.js} +5 -5
- package/dist/index-145f6f09.js +31 -0
- package/dist/{index-6f17b444.js → index-40564dba.js} +1139 -21
- package/dist/index.d.ts +64 -8
- package/dist/index.js +3 -3
- package/dist/{middleware-05e03d95.js → middleware-0627688d.js} +4 -2
- package/dist/node.d.ts +15 -0
- package/dist/node.js +6 -4
- package/dist/{suite-64b3e636.js → suite-8d666d5a.js} +1 -1
- package/dist/{utils-c8e62373.js → utils-49e5008c.js} +339 -1
- package/dist/utils.js +3 -1
- package/dist/worker.js +113 -6
- package/package.json +2 -1
- package/dist/index-a190f5a1.js +0 -352
package/LICENSE.md
CHANGED
|
@@ -1001,6 +1001,21 @@ Repository: sindresorhus/log-update
|
|
|
1001
1001
|
|
|
1002
1002
|
---------------------------------------
|
|
1003
1003
|
|
|
1004
|
+
## magic-string
|
|
1005
|
+
License: MIT
|
|
1006
|
+
By: Rich Harris
|
|
1007
|
+
Repository: https://github.com/rich-harris/magic-string
|
|
1008
|
+
|
|
1009
|
+
> Copyright 2018 Rich Harris
|
|
1010
|
+
>
|
|
1011
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1012
|
+
>
|
|
1013
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1014
|
+
>
|
|
1015
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1016
|
+
|
|
1017
|
+
---------------------------------------
|
|
1018
|
+
|
|
1004
1019
|
## merge-stream
|
|
1005
1020
|
License: MIT
|
|
1006
1021
|
By: Stephen Sugden
|
|
@@ -1699,6 +1714,35 @@ Repository: 7rulnik/source-map
|
|
|
1699
1714
|
|
|
1700
1715
|
---------------------------------------
|
|
1701
1716
|
|
|
1717
|
+
## sourcemap-codec
|
|
1718
|
+
License: MIT
|
|
1719
|
+
By: Rich Harris
|
|
1720
|
+
Repository: https://github.com/Rich-Harris/sourcemap-codec
|
|
1721
|
+
|
|
1722
|
+
> The MIT License
|
|
1723
|
+
>
|
|
1724
|
+
> Copyright (c) 2015 Rich Harris
|
|
1725
|
+
>
|
|
1726
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1727
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
1728
|
+
> in the Software without restriction, including without limitation the rights
|
|
1729
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1730
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
1731
|
+
> furnished to do so, subject to the following conditions:
|
|
1732
|
+
>
|
|
1733
|
+
> The above copyright notice and this permission notice shall be included in
|
|
1734
|
+
> all copies or substantial portions of the Software.
|
|
1735
|
+
>
|
|
1736
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1737
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1738
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1739
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1740
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1741
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1742
|
+
> THE SOFTWARE.
|
|
1743
|
+
|
|
1744
|
+
---------------------------------------
|
|
1745
|
+
|
|
1702
1746
|
## string-width
|
|
1703
1747
|
License: MIT
|
|
1704
1748
|
By: Sindre Sorhus
|
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import require$$0 from 'readline';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { e as ensurePackageInstalled } from './utils-
|
|
4
|
-
import { c as createVitest } from './index-
|
|
3
|
+
import { e as ensurePackageInstalled } from './utils-49e5008c.js';
|
|
4
|
+
import { c as createVitest } from './index-40564dba.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
+
import 'chai';
|
|
9
|
+
import 'tinyspy';
|
|
8
10
|
import 'vite';
|
|
9
11
|
import 'process';
|
|
10
12
|
import 'fs';
|
|
11
13
|
import 'os';
|
|
12
14
|
import 'util';
|
|
13
15
|
import 'stream';
|
|
14
|
-
import './constants-
|
|
16
|
+
import './constants-c4dc2ff5.js';
|
|
15
17
|
import 'url';
|
|
16
18
|
import 'perf_hooks';
|
|
17
|
-
import './error-
|
|
19
|
+
import './error-796962c6.js';
|
|
18
20
|
import './index-825cb54c.js';
|
|
19
21
|
import './_commonjsHelpers-bdec4bbd.js';
|
|
20
22
|
import 'assert';
|
|
@@ -634,7 +636,7 @@ class CAC extends EventEmitter {
|
|
|
634
636
|
|
|
635
637
|
const cac = (name = "") => new CAC(name);
|
|
636
638
|
|
|
637
|
-
var version = "0.0.
|
|
639
|
+
var version = "0.0.104";
|
|
638
640
|
|
|
639
641
|
const cli = cac("vitest");
|
|
640
642
|
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", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { m as resolve } from './utils-49e5008c.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}"];
|
package/dist/entry.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
+
import { u as index, g as getNames, c as c$1, t as toArray, k as basename, w as interpretOnlyMode, x as partitionSuiteChildren, y as hasTests, o as hasFailed, z as clearModuleMocks, b as vi } from './utils-49e5008c.js';
|
|
2
3
|
import { Console } from 'console';
|
|
3
4
|
import { Writable } from 'stream';
|
|
4
5
|
import { importModule } from 'local-pkg';
|
|
5
6
|
import chai$1, { expect, util } from 'chai';
|
|
6
7
|
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 { u as unifiedDiff } from './error-
|
|
9
|
+
import { u as unifiedDiff } from './error-796962c6.js';
|
|
10
10
|
import { performance } from 'perf_hooks';
|
|
11
|
-
import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-
|
|
11
|
+
import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-8d666d5a.js';
|
|
12
12
|
import { n as nanoid } from './index-9e71c815.js';
|
|
13
13
|
import { format as format$1 } from 'util';
|
|
14
14
|
import 'tty';
|
|
15
15
|
import 'path';
|
|
16
|
+
import 'tinyspy';
|
|
16
17
|
|
|
17
18
|
var node = {
|
|
18
19
|
name: "node",
|
|
@@ -3851,6 +3852,23 @@ class Any extends AsymmetricMatcher {
|
|
|
3851
3852
|
return `Any<${this.fnNameFor(this.sample)}>`;
|
|
3852
3853
|
}
|
|
3853
3854
|
}
|
|
3855
|
+
class StringMatching extends AsymmetricMatcher {
|
|
3856
|
+
constructor(sample, inverse = false) {
|
|
3857
|
+
if (!isA("String", sample) && !isA("RegExp", sample))
|
|
3858
|
+
throw new Error("Expected is not a String or a RegExp");
|
|
3859
|
+
super(new RegExp(sample), inverse);
|
|
3860
|
+
}
|
|
3861
|
+
asymmetricMatch(other) {
|
|
3862
|
+
const result = isA("String", other) && this.sample.test(other);
|
|
3863
|
+
return this.inverse ? !result : result;
|
|
3864
|
+
}
|
|
3865
|
+
toString() {
|
|
3866
|
+
return `String${this.inverse ? "Not" : ""}Matching`;
|
|
3867
|
+
}
|
|
3868
|
+
getExpectedType() {
|
|
3869
|
+
return "string";
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3854
3872
|
const JestAsymmetricMatchers = (chai, utils) => {
|
|
3855
3873
|
utils.addMethod(chai.expect, "stringContaining", (expected) => new StringContaining(expected));
|
|
3856
3874
|
utils.addMethod(chai.expect, "anything", () => {
|
|
@@ -3865,6 +3883,9 @@ const JestAsymmetricMatchers = (chai, utils) => {
|
|
|
3865
3883
|
utils.addMethod(chai.expect, "arrayContaining", (expected) => {
|
|
3866
3884
|
return new ArrayContaining(expected);
|
|
3867
3885
|
});
|
|
3886
|
+
utils.addMethod(chai.expect, "stringMatching", (expected) => {
|
|
3887
|
+
return new StringMatching(expected);
|
|
3888
|
+
});
|
|
3868
3889
|
};
|
|
3869
3890
|
|
|
3870
3891
|
let installed = false;
|
|
@@ -3887,7 +3908,7 @@ async function setupGlobalEnv(config) {
|
|
|
3887
3908
|
setupConsoleLogSpy();
|
|
3888
3909
|
await setupChai();
|
|
3889
3910
|
if (config.global)
|
|
3890
|
-
(await import('./global-
|
|
3911
|
+
(await import('./global-166f6789.js')).registerApiGlobally();
|
|
3891
3912
|
}
|
|
3892
3913
|
function setupConsoleLogSpy() {
|
|
3893
3914
|
const stdout = new Writable({
|
|
@@ -4026,6 +4047,7 @@ async function runTest(test) {
|
|
|
4026
4047
|
state: "run"
|
|
4027
4048
|
};
|
|
4028
4049
|
updateTask(test);
|
|
4050
|
+
clearModuleMocks();
|
|
4029
4051
|
getSnapshotClient().setTest(test);
|
|
4030
4052
|
process.__vitest_worker__.current = test;
|
|
4031
4053
|
try {
|
|
@@ -4123,9 +4145,12 @@ async function run(files, config) {
|
|
|
4123
4145
|
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
4124
4146
|
if (!["node", "jsdom", "happy-dom"].includes(env))
|
|
4125
4147
|
throw new Error(`Unsupported environment: ${env}`);
|
|
4148
|
+
process.__vitest_worker__.filepath = file;
|
|
4149
|
+
vi.restoreAllMocks();
|
|
4126
4150
|
await withEnv(env, async () => {
|
|
4127
4151
|
await startTests([file], config);
|
|
4128
4152
|
});
|
|
4153
|
+
process.__vitest_worker__.filepath = void 0;
|
|
4129
4154
|
}
|
|
4130
4155
|
}
|
|
4131
4156
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
2
|
import { format } from 'util';
|
|
3
|
-
import {
|
|
3
|
+
import { p as notNullish, c, r as relative } from './utils-49e5008c.js';
|
|
4
4
|
|
|
5
5
|
function Diff() {}
|
|
6
6
|
Diff.prototype = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-c4dc2ff5.js';
|
|
2
|
+
import { i as index } from './index-145f6f09.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './utils-
|
|
4
|
+
import './utils-49e5008c.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './suite-64b3e636.js';
|
|
9
|
-
import './index-9e71c815.js';
|
|
10
8
|
import 'chai';
|
|
11
9
|
import 'tinyspy';
|
|
10
|
+
import './suite-8d666d5a.js';
|
|
11
|
+
import './index-9e71c815.js';
|
|
12
12
|
|
|
13
13
|
function registerApiGlobally() {
|
|
14
14
|
globalApis.forEach((api) => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-8d666d5a.js';
|
|
2
|
+
import chai, { assert, should, expect } from 'chai';
|
|
3
|
+
import { s as spies, a as spyOn, f as fn, v as vitest, b as vi } from './utils-49e5008c.js';
|
|
4
|
+
|
|
5
|
+
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
|
+
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
7
|
+
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
8
|
+
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
9
|
+
|
|
10
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
11
|
+
__proto__: null,
|
|
12
|
+
suite: suite,
|
|
13
|
+
test: test,
|
|
14
|
+
describe: describe,
|
|
15
|
+
it: it,
|
|
16
|
+
beforeAll: beforeAll,
|
|
17
|
+
afterAll: afterAll,
|
|
18
|
+
beforeEach: beforeEach,
|
|
19
|
+
afterEach: afterEach,
|
|
20
|
+
assert: assert,
|
|
21
|
+
should: should,
|
|
22
|
+
expect: expect,
|
|
23
|
+
chai: chai,
|
|
24
|
+
spies: spies,
|
|
25
|
+
spyOn: spyOn,
|
|
26
|
+
fn: fn,
|
|
27
|
+
vitest: vitest,
|
|
28
|
+
vi: vi
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i };
|