vitest 0.23.2 → 0.24.0
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/browser.d.ts +3 -3
- package/dist/browser.js +24 -0
- package/dist/{chunk-api-setup.11cfd513.mjs → chunk-api-setup.33222ae9.js} +20 -20
- package/dist/{chunk-constants.71e8a211.mjs → chunk-constants.22640ce4.js} +0 -0
- package/dist/{chunk-env-node.ceb43f1c.mjs → chunk-env-node.700b7e95.js} +2 -1
- package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.107b0cd7.js} +56 -20
- package/dist/{chunk-integrations-coverage.99c020eb.mjs → chunk-integrations-coverage.cca09977.js} +0 -0
- package/dist/chunk-integrations-globals.f50b2307.js +25 -0
- package/dist/{chunk-magic-string.56b2b543.mjs → chunk-magic-string.cacfbf9d.js} +53 -7
- package/dist/{chunk-mock-date.2917be60.mjs → chunk-mock-date.b1b404e8.js} +3 -3
- package/dist/{chunk-node-git.a44b4872.mjs → chunk-node-git.6d82fb34.js} +5 -5
- package/dist/{chunk-runtime-chain.7a7f3c3b.mjs → chunk-runtime-chain.4dd0a07a.js} +22 -22
- package/dist/{chunk-runtime-error.2723946b.mjs → chunk-runtime-error.38d92035.js} +29 -19
- package/dist/{chunk-runtime-hooks.1a0bc3fd.mjs → chunk-runtime-hooks.72f95cdb.js} +6 -6
- package/dist/{chunk-runtime-mocker.8d4a2494.mjs → chunk-runtime-mocker.623b90b6.js} +20 -10
- package/dist/{chunk-runtime-rpc.00a890d2.mjs → chunk-runtime-rpc.4f6f88e8.js} +2 -2
- package/dist/{chunk-utils-source-map.2be5aa48.mjs → chunk-utils-source-map.175ffa40.js} +10 -6
- package/dist/{chunk-utils-timers.b48455ed.mjs → chunk-utils-timers.ab764c0c.js} +0 -0
- package/dist/{chunk-vite-node-client.da0a17ff.mjs → chunk-vite-node-client.4dd32c96.js} +2 -2
- package/dist/{chunk-vite-node-debug.536c4c5b.mjs → chunk-vite-node-debug.77d9dcea.js} +1 -1
- package/dist/{chunk-vite-node-externalize.f55c4577.mjs → chunk-vite-node-externalize.a2e9daf4.js} +1138 -1083
- package/dist/{chunk-vite-node-utils.473cd0b2.mjs → chunk-vite-node-utils.c8c74a41.js} +39 -15
- package/dist/{cli-wrapper.mjs → cli-wrapper.js} +9 -7
- package/dist/{cli.mjs → cli.js} +14 -14
- package/dist/config.d.ts +1 -1
- package/dist/{config.mjs → config.js} +0 -0
- package/dist/{entry.mjs → entry.js} +12 -12
- package/dist/environments.d.ts +1 -1
- package/dist/{environments.mjs → environments.js} +1 -1
- package/dist/{global-d05ffb3f.d.ts → global-6d79484b.d.ts} +16 -4
- package/dist/{index-60e2a8e1.d.ts → index-e0804ba8.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/{index.mjs → index.js} +9 -9
- package/dist/{loader.mjs → loader.js} +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +37 -0
- package/dist/{spy.mjs → spy.js} +0 -0
- package/dist/suite.js +16 -0
- package/dist/{vendor-_commonjsHelpers.4da45ef5.mjs → vendor-_commonjsHelpers.addc3445.js} +0 -0
- package/dist/{vendor-index.fbec8a81.mjs → vendor-index.07e6fc5a.js} +2 -2
- package/dist/{vendor-index.0557b03a.mjs → vendor-index.534e612c.js} +1 -1
- package/dist/{vendor-index.29636037.mjs → vendor-index.8919d83a.js} +1 -1
- package/dist/{vendor-index.2ae8040a.mjs → vendor-index.95542d0a.js} +1 -1
- package/dist/{vendor-index.ae96af6e.mjs → vendor-index.9f20a9be.js} +0 -0
- package/dist/{vendor-index.9d9196cc.mjs → vendor-index.c902d578.js} +0 -0
- package/dist/{worker.mjs → worker.js} +8 -8
- package/index.cjs +0 -0
- package/package.json +30 -23
- package/vitest.mjs +1 -1
- package/dist/browser.mjs +0 -24
- package/dist/chunk-integrations-globals.ad5b1b51.mjs +0 -25
- package/dist/node.mjs +0 -37
- package/dist/suite.mjs +0 -16
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-
|
|
2
|
-
import { R as ResolvedConfig } from './global-
|
|
3
|
-
export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-
|
|
1
|
+
export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-e0804ba8.js';
|
|
2
|
+
import { R as ResolvedConfig } from './global-6d79484b.js';
|
|
3
|
+
export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-6d79484b.js';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.4dd0a07a.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.72f95cdb.js';
|
|
3
|
+
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.38d92035.js';
|
|
4
|
+
import * as chai from 'chai';
|
|
5
|
+
export { chai };
|
|
6
|
+
export { assert, should } from 'chai';
|
|
7
|
+
import 'util';
|
|
8
|
+
import './chunk-mock-date.b1b404e8.js';
|
|
9
|
+
import 'path';
|
|
10
|
+
import './chunk-constants.22640ce4.js';
|
|
11
|
+
import 'tty';
|
|
12
|
+
import 'url';
|
|
13
|
+
import 'local-pkg';
|
|
14
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
15
|
+
import './chunk-runtime-rpc.4f6f88e8.js';
|
|
16
|
+
import './chunk-utils-timers.ab764c0c.js';
|
|
17
|
+
import 'fs';
|
|
18
|
+
import './chunk-utils-source-map.175ffa40.js';
|
|
19
|
+
import './spy.js';
|
|
20
|
+
import 'tinyspy';
|
|
21
|
+
import 'perf_hooks';
|
|
22
|
+
import './chunk-integrations-coverage.cca09977.js';
|
|
23
|
+
import './chunk-env-node.700b7e95.js';
|
|
24
|
+
import 'console';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-client.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-client.4dd32c96.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -9,17 +9,17 @@ import require$$2 from 'events';
|
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import url from 'url';
|
|
12
|
-
import { A as API_PATH } from './chunk-constants.
|
|
13
|
-
import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.22640ce4.js';
|
|
13
|
+
import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.175ffa40.js';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-vite-node-utils.
|
|
16
|
+
import './chunk-vite-node-utils.c8c74a41.js';
|
|
17
17
|
import 'path';
|
|
18
18
|
import 'assert';
|
|
19
19
|
import 'util';
|
|
20
20
|
import 'debug';
|
|
21
21
|
import 'tty';
|
|
22
|
-
import './chunk-mock-date.
|
|
22
|
+
import './chunk-mock-date.b1b404e8.js';
|
|
23
23
|
import 'local-pkg';
|
|
24
24
|
|
|
25
25
|
/*! (c) 2020 Andrea Giammarchi */
|
|
@@ -3182,20 +3182,20 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3182
3182
|
}
|
|
3183
3183
|
|
|
3184
3184
|
const isSecure = parsedUrl.protocol === 'wss:';
|
|
3185
|
-
const
|
|
3186
|
-
let
|
|
3185
|
+
const isIpcUrl = parsedUrl.protocol === 'ws+unix:';
|
|
3186
|
+
let invalidUrlMessage;
|
|
3187
3187
|
|
|
3188
|
-
if (parsedUrl.protocol !== 'ws:' && !isSecure && !
|
|
3189
|
-
|
|
3188
|
+
if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
|
|
3189
|
+
invalidUrlMessage =
|
|
3190
3190
|
'The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"';
|
|
3191
|
-
} else if (
|
|
3192
|
-
|
|
3191
|
+
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
3192
|
+
invalidUrlMessage = "The URL's pathname is empty";
|
|
3193
3193
|
} else if (parsedUrl.hash) {
|
|
3194
|
-
|
|
3194
|
+
invalidUrlMessage = 'The URL contains a fragment identifier';
|
|
3195
3195
|
}
|
|
3196
3196
|
|
|
3197
|
-
if (
|
|
3198
|
-
const err = new SyntaxError(
|
|
3197
|
+
if (invalidUrlMessage) {
|
|
3198
|
+
const err = new SyntaxError(invalidUrlMessage);
|
|
3199
3199
|
|
|
3200
3200
|
if (websocket._redirects === 0) {
|
|
3201
3201
|
throw err;
|
|
@@ -3265,7 +3265,7 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3265
3265
|
opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
3266
3266
|
}
|
|
3267
3267
|
|
|
3268
|
-
if (
|
|
3268
|
+
if (isIpcUrl) {
|
|
3269
3269
|
const parts = opts.path.split(':');
|
|
3270
3270
|
|
|
3271
3271
|
opts.socketPath = parts[0];
|
|
@@ -3276,9 +3276,9 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3276
3276
|
|
|
3277
3277
|
if (opts.followRedirects) {
|
|
3278
3278
|
if (websocket._redirects === 0) {
|
|
3279
|
-
websocket.
|
|
3279
|
+
websocket._originalIpc = isIpcUrl;
|
|
3280
3280
|
websocket._originalSecure = isSecure;
|
|
3281
|
-
websocket._originalHostOrSocketPath =
|
|
3281
|
+
websocket._originalHostOrSocketPath = isIpcUrl
|
|
3282
3282
|
? opts.socketPath
|
|
3283
3283
|
: parsedUrl.host;
|
|
3284
3284
|
|
|
@@ -3296,11 +3296,11 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3296
3296
|
}
|
|
3297
3297
|
}
|
|
3298
3298
|
} else if (websocket.listenerCount('redirect') === 0) {
|
|
3299
|
-
const isSameHost =
|
|
3300
|
-
? websocket.
|
|
3299
|
+
const isSameHost = isIpcUrl
|
|
3300
|
+
? websocket._originalIpc
|
|
3301
3301
|
? opts.socketPath === websocket._originalHostOrSocketPath
|
|
3302
3302
|
: false
|
|
3303
|
-
: websocket.
|
|
3303
|
+
: websocket._originalIpc
|
|
3304
3304
|
? false
|
|
3305
3305
|
: parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
3306
3306
|
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import path$2 from 'path';
|
|
2
1
|
import fs$2 from 'fs';
|
|
2
|
+
import path$2 from 'path';
|
|
3
3
|
import util from 'util';
|
|
4
4
|
import childProcess$1 from 'child_process';
|
|
5
|
-
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.
|
|
6
|
-
import { o as onetime$1 } from './vendor-index.
|
|
5
|
+
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.95542d0a.js';
|
|
6
|
+
import { o as onetime$1 } from './vendor-index.c902d578.js';
|
|
7
7
|
import require$$0 from 'os';
|
|
8
|
-
import { s as signalExit } from './vendor-index.
|
|
9
|
-
import './vendor-_commonjsHelpers.
|
|
8
|
+
import { s as signalExit } from './vendor-index.8919d83a.js';
|
|
9
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
10
10
|
import 'buffer';
|
|
11
11
|
import 'stream';
|
|
12
12
|
import 'assert';
|
|
@@ -1611,32 +1611,68 @@ execa$1.exports.node = (scriptPath, args, options = {}) => {
|
|
|
1611
1611
|
};
|
|
1612
1612
|
|
|
1613
1613
|
// src/detect.ts
|
|
1614
|
+
var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
|
|
1614
1615
|
var LOCKS = {
|
|
1616
|
+
"bun.lockb": "bun",
|
|
1615
1617
|
"pnpm-lock.yaml": "pnpm",
|
|
1616
1618
|
"yarn.lock": "yarn",
|
|
1617
|
-
"package-lock.json": "npm"
|
|
1619
|
+
"package-lock.json": "npm",
|
|
1620
|
+
"npm-shrinkwrap.json": "npm"
|
|
1618
1621
|
};
|
|
1619
1622
|
async function detectPackageManager(cwd = process.cwd()) {
|
|
1620
|
-
|
|
1621
|
-
const
|
|
1623
|
+
let agent = null;
|
|
1624
|
+
const lockPath = await findUp(Object.keys(LOCKS), { cwd });
|
|
1625
|
+
let packageJsonPath;
|
|
1626
|
+
if (lockPath)
|
|
1627
|
+
packageJsonPath = path$2.resolve(lockPath, "../package.json");
|
|
1628
|
+
else
|
|
1629
|
+
packageJsonPath = await findUp("package.json", { cwd });
|
|
1630
|
+
if (packageJsonPath && fs$2.existsSync(packageJsonPath)) {
|
|
1631
|
+
try {
|
|
1632
|
+
const pkg = JSON.parse(fs$2.readFileSync(packageJsonPath, "utf8"));
|
|
1633
|
+
if (typeof pkg.packageManager === "string") {
|
|
1634
|
+
const [name, version] = pkg.packageManager.split("@");
|
|
1635
|
+
if (name === "yarn" && parseInt(version) > 1)
|
|
1636
|
+
agent = "yarn@berry";
|
|
1637
|
+
else if (name === "pnpm" && parseInt(version) < 7)
|
|
1638
|
+
agent = "pnpm@6";
|
|
1639
|
+
else if (name in AGENTS)
|
|
1640
|
+
agent = name;
|
|
1641
|
+
else
|
|
1642
|
+
console.warn("[ni] Unknown packageManager:", pkg.packageManager);
|
|
1643
|
+
}
|
|
1644
|
+
} catch {
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
if (!agent && lockPath)
|
|
1648
|
+
agent = LOCKS[path$2.basename(lockPath)];
|
|
1622
1649
|
return agent;
|
|
1623
1650
|
}
|
|
1624
1651
|
async function installPackage(names, options = {}) {
|
|
1625
|
-
const
|
|
1652
|
+
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
1653
|
+
const [agent] = detectedAgent.split("@");
|
|
1626
1654
|
if (!Array.isArray(names))
|
|
1627
1655
|
names = [names];
|
|
1628
1656
|
const args = options.additionalArgs || [];
|
|
1629
|
-
if (options.preferOffline)
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1657
|
+
if (options.preferOffline) {
|
|
1658
|
+
if (detectedAgent === "yarn@berry")
|
|
1659
|
+
args.unshift("--cached");
|
|
1660
|
+
else
|
|
1661
|
+
args.unshift("--prefer-offline");
|
|
1662
|
+
}
|
|
1663
|
+
return execa$1.exports(
|
|
1664
|
+
agent,
|
|
1665
|
+
[
|
|
1666
|
+
agent === "yarn" ? "add" : "install",
|
|
1667
|
+
options.dev ? "-D" : "",
|
|
1668
|
+
...args,
|
|
1669
|
+
...names
|
|
1670
|
+
].filter(Boolean),
|
|
1671
|
+
{
|
|
1672
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
1673
|
+
cwd: options.cwd
|
|
1674
|
+
}
|
|
1675
|
+
);
|
|
1640
1676
|
}
|
|
1641
1677
|
|
|
1642
1678
|
export { detectPackageManager, installPackage };
|
package/dist/{chunk-integrations-coverage.99c020eb.mjs → chunk-integrations-coverage.cca09977.js}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { k as globalApis } from './chunk-constants.22640ce4.js';
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.72f95cdb.js';
|
|
3
|
+
import 'tty';
|
|
4
|
+
import 'url';
|
|
5
|
+
import 'path';
|
|
6
|
+
import './chunk-runtime-chain.4dd0a07a.js';
|
|
7
|
+
import 'util';
|
|
8
|
+
import './chunk-mock-date.b1b404e8.js';
|
|
9
|
+
import 'local-pkg';
|
|
10
|
+
import 'chai';
|
|
11
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
12
|
+
import './chunk-runtime-rpc.4f6f88e8.js';
|
|
13
|
+
import './chunk-utils-timers.ab764c0c.js';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import './chunk-utils-source-map.175ffa40.js';
|
|
16
|
+
import './spy.js';
|
|
17
|
+
import 'tinyspy';
|
|
18
|
+
|
|
19
|
+
function registerApiGlobally() {
|
|
20
|
+
globalApis.forEach((api) => {
|
|
21
|
+
globalThis[api] = index[api];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { registerApiGlobally };
|
|
@@ -77,11 +77,10 @@ class Chunk {
|
|
|
77
77
|
this.storeName = false;
|
|
78
78
|
this.edited = false;
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
80
|
+
{
|
|
81
|
+
this.previous = null;
|
|
82
|
+
this.next = null;
|
|
83
|
+
}
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
appendLeft(content) {
|
|
@@ -1092,7 +1091,7 @@ class MagicString {
|
|
|
1092
1091
|
return this.original !== this.toString();
|
|
1093
1092
|
}
|
|
1094
1093
|
|
|
1095
|
-
|
|
1094
|
+
_replaceRegexp(searchValue, replacement) {
|
|
1096
1095
|
function getReplacement(match, str) {
|
|
1097
1096
|
if (typeof replacement === 'string') {
|
|
1098
1097
|
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
@@ -1115,7 +1114,7 @@ class MagicString {
|
|
|
1115
1114
|
}
|
|
1116
1115
|
return matches;
|
|
1117
1116
|
}
|
|
1118
|
-
if (
|
|
1117
|
+
if (searchValue.global) {
|
|
1119
1118
|
const matches = matchAll(searchValue, this.original);
|
|
1120
1119
|
matches.forEach((match) => {
|
|
1121
1120
|
if (match.index != null)
|
|
@@ -1136,6 +1135,53 @@ class MagicString {
|
|
|
1136
1135
|
}
|
|
1137
1136
|
return this;
|
|
1138
1137
|
}
|
|
1138
|
+
|
|
1139
|
+
_replaceString(string, replacement) {
|
|
1140
|
+
const { original } = this;
|
|
1141
|
+
const index = original.indexOf(string);
|
|
1142
|
+
|
|
1143
|
+
if (index !== -1) {
|
|
1144
|
+
this.overwrite(index, index + string.length, replacement);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
replace(searchValue, replacement) {
|
|
1151
|
+
if (typeof searchValue === 'string') {
|
|
1152
|
+
return this._replaceString(searchValue, replacement);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
_replaceAllString(string, replacement) {
|
|
1159
|
+
const { original } = this;
|
|
1160
|
+
const stringLength = string.length;
|
|
1161
|
+
for (
|
|
1162
|
+
let index = original.indexOf(string);
|
|
1163
|
+
index !== -1;
|
|
1164
|
+
index = original.indexOf(string, index + stringLength)
|
|
1165
|
+
) {
|
|
1166
|
+
this.overwrite(index, index + stringLength, replacement);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
return this;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
replaceAll(searchValue, replacement) {
|
|
1173
|
+
if (typeof searchValue === 'string') {
|
|
1174
|
+
return this._replaceAllString(searchValue, replacement);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
if (!searchValue.global) {
|
|
1178
|
+
throw new TypeError(
|
|
1179
|
+
'MagicString.prototype.replaceAll called with a non-global RegExp argument'
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1184
|
+
}
|
|
1139
1185
|
}
|
|
1140
1186
|
|
|
1141
1187
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative } from 'path';
|
|
2
|
-
import { r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.
|
|
2
|
+
import { r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.22640ce4.js';
|
|
3
3
|
import { isPackageExists } from 'local-pkg';
|
|
4
4
|
|
|
5
5
|
const RealDate = Date;
|
|
@@ -266,14 +266,14 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
266
266
|
`));
|
|
267
267
|
if (!promptInstall)
|
|
268
268
|
return false;
|
|
269
|
-
const prompts = await import('./vendor-index.
|
|
269
|
+
const prompts = await import('./vendor-index.9f20a9be.js').then(function (n) { return n.i; });
|
|
270
270
|
const { install } = await prompts.prompt({
|
|
271
271
|
type: "confirm",
|
|
272
272
|
name: "install",
|
|
273
273
|
message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
|
|
274
274
|
});
|
|
275
275
|
if (install) {
|
|
276
|
-
await (await import('./chunk-install-pkg.
|
|
276
|
+
await (await import('./chunk-install-pkg.107b0cd7.js')).installPackage(dependency, { dev: true });
|
|
277
277
|
process.stderr.write(picocolors.exports.yellow(`
|
|
278
278
|
Package ${dependency} installed, re-run the command to start.
|
|
279
279
|
`));
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { a as resolve } from './chunk-constants.
|
|
2
|
-
import { e as execa } from './vendor-index.
|
|
1
|
+
import { a as resolve } from './chunk-constants.22640ce4.js';
|
|
2
|
+
import { e as execa } from './vendor-index.07e6fc5a.js';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'url';
|
|
5
5
|
import 'path';
|
|
6
6
|
import 'buffer';
|
|
7
7
|
import 'child_process';
|
|
8
8
|
import 'process';
|
|
9
|
-
import './vendor-index.
|
|
10
|
-
import './vendor-_commonjsHelpers.
|
|
9
|
+
import './vendor-index.95542d0a.js';
|
|
10
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
11
11
|
import 'fs';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'os';
|
|
15
|
-
import './vendor-index.
|
|
15
|
+
import './vendor-index.8919d83a.js';
|
|
16
16
|
import 'assert';
|
|
17
17
|
import 'events';
|
|
18
18
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import util$1 from 'util';
|
|
2
|
-
import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName,
|
|
2
|
+
import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-mock-date.b1b404e8.js';
|
|
3
3
|
import * as chai$2 from 'chai';
|
|
4
4
|
import { expect, AssertionError, util } from 'chai';
|
|
5
|
-
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
5
|
+
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.4f6f88e8.js';
|
|
7
7
|
import fs, { promises } from 'fs';
|
|
8
|
-
import { j as join, d as dirname, p as picocolors } from './chunk-constants.
|
|
9
|
-
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.
|
|
10
|
-
import { isMockFunction } from './spy.
|
|
11
|
-
import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.
|
|
8
|
+
import { j as join, d as dirname, p as picocolors } from './chunk-constants.22640ce4.js';
|
|
9
|
+
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.175ffa40.js';
|
|
10
|
+
import { isMockFunction } from './spy.js';
|
|
11
|
+
import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.ab764c0c.js';
|
|
12
12
|
|
|
13
13
|
function createChainable(keys, fn) {
|
|
14
14
|
function create(context) {
|
|
@@ -125,7 +125,7 @@ function equals(a, b, customTesters, strictCheck) {
|
|
|
125
125
|
return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
|
|
126
126
|
}
|
|
127
127
|
function isAsymmetric(obj) {
|
|
128
|
-
return !!obj && isA("Function", obj.asymmetricMatch);
|
|
128
|
+
return !!obj && typeof obj === "object" && "asymmetricMatch" in obj && isA("Function", obj.asymmetricMatch);
|
|
129
129
|
}
|
|
130
130
|
function asymmetricMatch(a, b) {
|
|
131
131
|
const asymmetricA = isAsymmetric(a);
|
|
@@ -600,7 +600,7 @@ function deepMergeSnapshot(target, source) {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
async function saveInlineSnapshots(snapshots) {
|
|
603
|
-
const MagicString = (await import('./chunk-magic-string.
|
|
603
|
+
const MagicString = (await import('./chunk-magic-string.cacfbf9d.js')).default;
|
|
604
604
|
const files = new Set(snapshots.map((i) => i.file));
|
|
605
605
|
await Promise.all(Array.from(files).map(async (file) => {
|
|
606
606
|
const map = await rpc().getSourceMap(file);
|
|
@@ -617,7 +617,7 @@ async function saveInlineSnapshots(snapshots) {
|
|
|
617
617
|
await promises.writeFile(file, transformed, "utf-8");
|
|
618
618
|
}));
|
|
619
619
|
}
|
|
620
|
-
const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*({)/m;
|
|
620
|
+
const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*({)/m;
|
|
621
621
|
function replaceObjectSnap(code, s, index, newSnap) {
|
|
622
622
|
code = code.slice(index);
|
|
623
623
|
const startMatch = startObjectRegex.exec(code);
|
|
@@ -645,7 +645,7 @@ function prepareSnapString(snap, source, index) {
|
|
|
645
645
|
${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\${/g, "\\${")}
|
|
646
646
|
${indent}${quote}`;
|
|
647
647
|
}
|
|
648
|
-
const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*[\w_$]*(['"`\)])/m;
|
|
648
|
+
const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*[\w_$]*(['"`\)])/m;
|
|
649
649
|
function replaceInlineSnap(code, s, index, newSnap) {
|
|
650
650
|
const startMatch = startRegex.exec(code.slice(index));
|
|
651
651
|
if (!startMatch)
|
|
@@ -1588,7 +1588,7 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
|
1588
1588
|
thrown && thrown.message
|
|
1589
1589
|
);
|
|
1590
1590
|
}
|
|
1591
|
-
if (typeof expected.asymmetricMatch === "function") {
|
|
1591
|
+
if (typeof expected === "object" && "asymmetricMatch" in expected && typeof expected.asymmetricMatch === "function") {
|
|
1592
1592
|
const matcher = expected;
|
|
1593
1593
|
return this.assert(
|
|
1594
1594
|
thrown && matcher.asymmetricMatch(thrown),
|
|
@@ -2184,7 +2184,7 @@ const test = createTest(
|
|
|
2184
2184
|
}
|
|
2185
2185
|
);
|
|
2186
2186
|
const bench = createBenchmark(
|
|
2187
|
-
function(name, fn, options) {
|
|
2187
|
+
function(name, fn = noop, options = {}) {
|
|
2188
2188
|
getCurrentSuite().benchmark.fn.call(this, name, fn, options);
|
|
2189
2189
|
}
|
|
2190
2190
|
);
|
|
@@ -2222,12 +2222,12 @@ function createSuiteHooks() {
|
|
|
2222
2222
|
};
|
|
2223
2223
|
}
|
|
2224
2224
|
function createSuiteCollector(name, factory = () => {
|
|
2225
|
-
}, mode, concurrent, shuffle) {
|
|
2225
|
+
}, mode, concurrent, shuffle, suiteOptions) {
|
|
2226
2226
|
const tasks = [];
|
|
2227
2227
|
const factoryQueue = [];
|
|
2228
2228
|
let suite2;
|
|
2229
2229
|
initSuite();
|
|
2230
|
-
const test2 = createTest(function(name2, fn = noop, options) {
|
|
2230
|
+
const test2 = createTest(function(name2, fn = noop, options = suiteOptions) {
|
|
2231
2231
|
if (!isRunningInTest())
|
|
2232
2232
|
throw new Error("`test()` and `it()` is only available in test mode.");
|
|
2233
2233
|
const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
@@ -2257,8 +2257,8 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2257
2257
|
));
|
|
2258
2258
|
tasks.push(test3);
|
|
2259
2259
|
});
|
|
2260
|
-
const benchmark = createBenchmark(function(name2, fn = noop, options) {
|
|
2261
|
-
const mode2 = this.skip ? "skip" : "run";
|
|
2260
|
+
const benchmark = createBenchmark(function(name2, fn = noop, options = {}) {
|
|
2261
|
+
const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
2262
2262
|
if (!isRunningInBenchmark())
|
|
2263
2263
|
throw new Error("`bench()` is only available in benchmark mode. Run with `vitest bench` instead.");
|
|
2264
2264
|
const benchmark2 = {
|
|
@@ -2322,16 +2322,16 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2322
2322
|
return collector;
|
|
2323
2323
|
}
|
|
2324
2324
|
function createSuite() {
|
|
2325
|
-
function suiteFn(name, factory) {
|
|
2325
|
+
function suiteFn(name, factory, options) {
|
|
2326
2326
|
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
2327
|
-
return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle);
|
|
2327
|
+
return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle, options);
|
|
2328
2328
|
}
|
|
2329
2329
|
suiteFn.each = function(cases) {
|
|
2330
2330
|
const suite2 = this.withContext();
|
|
2331
|
-
return (name, fn) => {
|
|
2331
|
+
return (name, fn, options) => {
|
|
2332
2332
|
cases.forEach((i, idx) => {
|
|
2333
2333
|
const items = Array.isArray(i) ? i : [i];
|
|
2334
|
-
suite2(formatTitle(name, items, idx), () => fn(...items));
|
|
2334
|
+
suite2(formatTitle(name, items, idx), () => fn(...items), options);
|
|
2335
2335
|
});
|
|
2336
2336
|
};
|
|
2337
2337
|
};
|
|
@@ -2362,7 +2362,7 @@ function createTest(fn) {
|
|
|
2362
2362
|
}
|
|
2363
2363
|
function createBenchmark(fn) {
|
|
2364
2364
|
const benchmark = createChainable(
|
|
2365
|
-
["skip"],
|
|
2365
|
+
["skip", "only", "todo"],
|
|
2366
2366
|
fn
|
|
2367
2367
|
);
|
|
2368
2368
|
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|