vitest 0.10.0 → 0.10.3
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/{chunk-api-setup.d70fc960.js → chunk-api-setup.0baa5b9c.js} +40 -17
- package/dist/{chunk-constants.d540b1d1.js → chunk-constants.54c46a47.js} +1 -1
- package/dist/{chunk-defaults.04d5d90b.js → chunk-defaults.c143550b.js} +1 -1
- package/dist/{chunk-integrations-globals.d2c09cd2.js → chunk-integrations-globals.12eb8517.js} +7 -7
- package/dist/{chunk-runtime-chain.f863f182.js → chunk-runtime-chain.0ac0691b.js} +74 -21
- package/dist/{chunk-runtime-mocker.111ac858.js → chunk-runtime-mocker.89015cf8.js} +5 -21
- package/dist/{chunk-runtime-rpc.8f648236.js → chunk-runtime-rpc.710f6f7f.js} +1 -1
- package/dist/{chunk-utils-global.37a7c822.js → chunk-utils-global.eb31f3da.js} +38 -1
- package/dist/{chunk-utils-timers.12bc05d1.js → chunk-utils-timers.8a5e7cd5.js} +3 -1
- package/dist/{chunk-vite-node-externalize.5c678054.js → chunk-vite-node-externalize.f88b9527.js} +134 -45
- package/dist/{chunk-vite-node-utils.33447cc0.js → chunk-vite-node-utils.3cb38009.js} +3 -1
- package/dist/cli.js +6 -6
- package/dist/entry.js +6 -6
- package/dist/index.d.ts +23 -7
- package/dist/index.js +4 -4
- package/dist/node.d.ts +17 -6
- package/dist/node.js +7 -7
- package/dist/{vendor-entry.369fd6c9.js → vendor-entry.2f0617df.js} +59 -17
- package/dist/worker.js +9 -6
- package/package.json +10 -11
- package/vitest.mjs +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-utils.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-utils.3cb38009.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -9,11 +9,11 @@ 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 { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.54c46a47.js';
|
|
13
|
+
import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.8a5e7cd5.js';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-utils-global.
|
|
16
|
+
import './chunk-utils-global.eb31f3da.js';
|
|
17
17
|
import 'tty';
|
|
18
18
|
import 'local-pkg';
|
|
19
19
|
import 'path';
|
|
@@ -2526,10 +2526,11 @@ const {
|
|
|
2526
2526
|
const { format, parse: parse$1 } = extension$1;
|
|
2527
2527
|
const { toBuffer } = bufferUtil$1.exports;
|
|
2528
2528
|
|
|
2529
|
+
const closeTimeout = 30 * 1000;
|
|
2530
|
+
const kAborted = Symbol('kAborted');
|
|
2531
|
+
const protocolVersions = [8, 13];
|
|
2529
2532
|
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
|
|
2530
2533
|
const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
2531
|
-
const protocolVersions = [8, 13];
|
|
2532
|
-
const closeTimeout = 30 * 1000;
|
|
2533
2534
|
|
|
2534
2535
|
/**
|
|
2535
2536
|
* Class representing a WebSocket.
|
|
@@ -3143,7 +3144,7 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3143
3144
|
hostname: undefined,
|
|
3144
3145
|
protocol: undefined,
|
|
3145
3146
|
timeout: undefined,
|
|
3146
|
-
method:
|
|
3147
|
+
method: 'GET',
|
|
3147
3148
|
host: undefined,
|
|
3148
3149
|
path: undefined,
|
|
3149
3150
|
port: undefined
|
|
@@ -3197,7 +3198,7 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3197
3198
|
|
|
3198
3199
|
const defaultPort = isSecure ? 443 : 80;
|
|
3199
3200
|
const key = randomBytes(16).toString('base64');
|
|
3200
|
-
const
|
|
3201
|
+
const request = isSecure ? https.request : http$1.request;
|
|
3201
3202
|
const protocolSet = new Set();
|
|
3202
3203
|
let perMessageDeflate;
|
|
3203
3204
|
|
|
@@ -3262,6 +3263,8 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3262
3263
|
opts.path = parts[1];
|
|
3263
3264
|
}
|
|
3264
3265
|
|
|
3266
|
+
let req;
|
|
3267
|
+
|
|
3265
3268
|
if (opts.followRedirects) {
|
|
3266
3269
|
if (websocket._redirects === 0) {
|
|
3267
3270
|
websocket._originalHost = parsedUrl.host;
|
|
@@ -3279,7 +3282,10 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3279
3282
|
options.headers[key.toLowerCase()] = value;
|
|
3280
3283
|
}
|
|
3281
3284
|
}
|
|
3282
|
-
} else if (
|
|
3285
|
+
} else if (
|
|
3286
|
+
websocket.listenerCount('redirect') === 0 &&
|
|
3287
|
+
parsedUrl.host !== websocket._originalHost
|
|
3288
|
+
) {
|
|
3283
3289
|
//
|
|
3284
3290
|
// Match curl 7.77.0 behavior and drop the following headers. These
|
|
3285
3291
|
// headers are also dropped when following a redirect to a subdomain.
|
|
@@ -3299,9 +3305,24 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3299
3305
|
options.headers.authorization =
|
|
3300
3306
|
'Basic ' + Buffer.from(opts.auth).toString('base64');
|
|
3301
3307
|
}
|
|
3302
|
-
}
|
|
3303
3308
|
|
|
3304
|
-
|
|
3309
|
+
req = websocket._req = request(opts);
|
|
3310
|
+
|
|
3311
|
+
if (websocket._redirects) {
|
|
3312
|
+
//
|
|
3313
|
+
// Unlike what is done for the `'upgrade'` event, no early exit is
|
|
3314
|
+
// triggered here if the user calls `websocket.close()` or
|
|
3315
|
+
// `websocket.terminate()` from a listener of the `'redirect'` event. This
|
|
3316
|
+
// is because the user can also call `request.destroy()` with an error
|
|
3317
|
+
// before calling `websocket.close()` or `websocket.terminate()` and this
|
|
3318
|
+
// would result in an error being emitted on the `request` object with no
|
|
3319
|
+
// `'error'` event listeners attached.
|
|
3320
|
+
//
|
|
3321
|
+
websocket.emit('redirect', websocket.url, req);
|
|
3322
|
+
}
|
|
3323
|
+
} else {
|
|
3324
|
+
req = websocket._req = request(opts);
|
|
3325
|
+
}
|
|
3305
3326
|
|
|
3306
3327
|
if (opts.timeout) {
|
|
3307
3328
|
req.on('timeout', () => {
|
|
@@ -3310,7 +3331,7 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3310
3331
|
}
|
|
3311
3332
|
|
|
3312
3333
|
req.on('error', (err) => {
|
|
3313
|
-
if (req === null || req
|
|
3334
|
+
if (req === null || req[kAborted]) return;
|
|
3314
3335
|
|
|
3315
3336
|
req = websocket._req = null;
|
|
3316
3337
|
emitErrorAndClose(websocket, err);
|
|
@@ -3357,8 +3378,8 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3357
3378
|
websocket.emit('upgrade', res);
|
|
3358
3379
|
|
|
3359
3380
|
//
|
|
3360
|
-
// The user may have closed the connection from a listener of the
|
|
3361
|
-
// event.
|
|
3381
|
+
// The user may have closed the connection from a listener of the
|
|
3382
|
+
// `'upgrade'` event.
|
|
3362
3383
|
//
|
|
3363
3384
|
if (websocket.readyState !== WebSocket$1.CONNECTING) return;
|
|
3364
3385
|
|
|
@@ -3443,10 +3464,12 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3443
3464
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
3444
3465
|
});
|
|
3445
3466
|
});
|
|
3467
|
+
|
|
3468
|
+
req.end();
|
|
3446
3469
|
}
|
|
3447
3470
|
|
|
3448
3471
|
/**
|
|
3449
|
-
* Emit the `'error'` and `'close'`
|
|
3472
|
+
* Emit the `'error'` and `'close'` events.
|
|
3450
3473
|
*
|
|
3451
3474
|
* @param {WebSocket} websocket The WebSocket instance
|
|
3452
3475
|
* @param {Error} The error to emit
|
|
@@ -3503,6 +3526,7 @@ function abortHandshake$1(websocket, stream, message) {
|
|
|
3503
3526
|
Error.captureStackTrace(err, abortHandshake$1);
|
|
3504
3527
|
|
|
3505
3528
|
if (stream.setHeader) {
|
|
3529
|
+
stream[kAborted] = true;
|
|
3506
3530
|
stream.abort();
|
|
3507
3531
|
|
|
3508
3532
|
if (stream.socket && !stream.socket.destroyed) {
|
|
@@ -3514,8 +3538,7 @@ function abortHandshake$1(websocket, stream, message) {
|
|
|
3514
3538
|
stream.socket.destroy();
|
|
3515
3539
|
}
|
|
3516
3540
|
|
|
3517
|
-
|
|
3518
|
-
websocket.emit('error', err);
|
|
3541
|
+
process.nextTick(emitErrorAndClose, websocket, err);
|
|
3519
3542
|
} else {
|
|
3520
3543
|
stream.destroy(err);
|
|
3521
3544
|
stream.once('error', websocket.emit.bind(websocket, 'error'));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { k as resolve } from './chunk-utils-global.
|
|
2
|
+
import { k as resolve } from './chunk-utils-global.eb31f3da.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultPort = 51204;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
-
import { t as toArray, k as resolve } from './chunk-utils-global.
|
|
4
|
+
import { t as toArray, k as resolve } from './chunk-utils-global.eb31f3da.js';
|
|
5
5
|
|
|
6
6
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
7
7
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
package/dist/{chunk-integrations-globals.d2c09cd2.js → chunk-integrations-globals.12eb8517.js}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { g as globalApis } from './chunk-constants.
|
|
2
|
-
import { i as index } from './vendor-entry.
|
|
1
|
+
import { g as globalApis } from './chunk-constants.54c46a47.js';
|
|
2
|
+
import { i as index } from './vendor-entry.2f0617df.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './chunk-utils-global.
|
|
4
|
+
import './chunk-utils-global.eb31f3da.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'console';
|
|
10
10
|
import 'stream';
|
|
11
|
-
import './chunk-runtime-chain.
|
|
11
|
+
import './chunk-runtime-chain.0ac0691b.js';
|
|
12
12
|
import 'chai';
|
|
13
13
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
14
|
-
import './chunk-runtime-rpc.
|
|
15
|
-
import './chunk-utils-timers.
|
|
14
|
+
import './chunk-runtime-rpc.710f6f7f.js';
|
|
15
|
+
import './chunk-utils-timers.8a5e7cd5.js';
|
|
16
16
|
import './chunk-integrations-spy.f036df6f.js';
|
|
17
17
|
import 'tinyspy';
|
|
18
18
|
import 'util';
|
|
19
|
-
import './chunk-defaults.
|
|
19
|
+
import './chunk-defaults.c143550b.js';
|
|
20
20
|
import 'module';
|
|
21
21
|
import 'crypto';
|
|
22
22
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import chai$1, { expect as expect$1, util } from 'chai';
|
|
2
2
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
3
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
4
|
-
import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.
|
|
3
|
+
import { r as rpc } from './chunk-runtime-rpc.710f6f7f.js';
|
|
4
|
+
import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.eb31f3da.js';
|
|
5
5
|
import fs, { promises } from 'fs';
|
|
6
|
-
import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.
|
|
6
|
+
import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.8a5e7cd5.js';
|
|
7
7
|
import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.f036df6f.js';
|
|
8
8
|
import require$$0, { format } from 'util';
|
|
9
9
|
|
|
@@ -534,14 +534,18 @@ ${snapshots.join("\n\n")}
|
|
|
534
534
|
}
|
|
535
535
|
function prepareExpected(expected) {
|
|
536
536
|
function findStartIndent() {
|
|
537
|
-
var _a;
|
|
538
|
-
const
|
|
539
|
-
|
|
537
|
+
var _a, _b;
|
|
538
|
+
const matchObject = /^( +)}\s+$/m.exec(expected || "");
|
|
539
|
+
const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
|
|
540
|
+
if (objectIndent)
|
|
541
|
+
return objectIndent;
|
|
542
|
+
const matchText = /^\n( +)"/.exec(expected || "");
|
|
543
|
+
return ((_b = matchText == null ? void 0 : matchText[1]) == null ? void 0 : _b.length) || 0;
|
|
540
544
|
}
|
|
541
|
-
const
|
|
545
|
+
const startIndent = findStartIndent();
|
|
542
546
|
let expectedTrimmed = expected == null ? void 0 : expected.trim();
|
|
543
|
-
if (
|
|
544
|
-
expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(
|
|
547
|
+
if (startIndent) {
|
|
548
|
+
expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +}$/, "}");
|
|
545
549
|
}
|
|
546
550
|
return expectedTrimmed;
|
|
547
551
|
}
|
|
@@ -898,7 +902,17 @@ class SnapshotClient {
|
|
|
898
902
|
clearTest() {
|
|
899
903
|
this.test = void 0;
|
|
900
904
|
}
|
|
901
|
-
assert(
|
|
905
|
+
assert(options) {
|
|
906
|
+
const {
|
|
907
|
+
test = this.test,
|
|
908
|
+
message,
|
|
909
|
+
isInline = false,
|
|
910
|
+
properties,
|
|
911
|
+
inlineSnapshot,
|
|
912
|
+
error,
|
|
913
|
+
errorMessage
|
|
914
|
+
} = options;
|
|
915
|
+
let { received } = options;
|
|
902
916
|
if (!test)
|
|
903
917
|
throw new Error("Snapshot cannot be used outside of test");
|
|
904
918
|
if (typeof properties === "object") {
|
|
@@ -911,7 +925,7 @@ class SnapshotClient {
|
|
|
911
925
|
else
|
|
912
926
|
received = deepMergeSnapshot(received, properties);
|
|
913
927
|
} catch (err) {
|
|
914
|
-
err.message = "Snapshot mismatched";
|
|
928
|
+
err.message = errorMessage || "Snapshot mismatched";
|
|
915
929
|
throw err;
|
|
916
930
|
}
|
|
917
931
|
}
|
|
@@ -931,7 +945,7 @@ class SnapshotClient {
|
|
|
931
945
|
try {
|
|
932
946
|
expect$1(actual.trim()).equals(expected ? expected.trim() : "");
|
|
933
947
|
} catch (error2) {
|
|
934
|
-
error2.message = `Snapshot \`${key || "unknown"}\` mismatched`;
|
|
948
|
+
error2.message = errorMessage || `Snapshot \`${key || "unknown"}\` mismatched`;
|
|
935
949
|
throw error2;
|
|
936
950
|
}
|
|
937
951
|
}
|
|
@@ -973,7 +987,15 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
973
987
|
message = properties;
|
|
974
988
|
properties = void 0;
|
|
975
989
|
}
|
|
976
|
-
|
|
990
|
+
const errorMessage = utils.flag(this, "message");
|
|
991
|
+
getSnapshotClient().assert({
|
|
992
|
+
received: expected,
|
|
993
|
+
test,
|
|
994
|
+
message,
|
|
995
|
+
isInline: false,
|
|
996
|
+
properties,
|
|
997
|
+
errorMessage
|
|
998
|
+
});
|
|
977
999
|
});
|
|
978
1000
|
}
|
|
979
1001
|
utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
|
@@ -987,18 +1009,43 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
987
1009
|
}
|
|
988
1010
|
if (inlineSnapshot)
|
|
989
1011
|
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
|
990
|
-
|
|
1012
|
+
const errorMessage = utils.flag(this, "message");
|
|
1013
|
+
getSnapshotClient().assert({
|
|
1014
|
+
received: expected,
|
|
1015
|
+
test,
|
|
1016
|
+
message,
|
|
1017
|
+
isInline: true,
|
|
1018
|
+
properties,
|
|
1019
|
+
inlineSnapshot,
|
|
1020
|
+
error,
|
|
1021
|
+
errorMessage
|
|
1022
|
+
});
|
|
991
1023
|
});
|
|
992
1024
|
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
|
|
993
1025
|
const expected = utils.flag(this, "object");
|
|
994
1026
|
const test = utils.flag(this, "vitest-test");
|
|
995
|
-
|
|
1027
|
+
const errorMessage = utils.flag(this, "message");
|
|
1028
|
+
getSnapshotClient().assert({
|
|
1029
|
+
received: getErrorString(expected),
|
|
1030
|
+
test,
|
|
1031
|
+
message,
|
|
1032
|
+
errorMessage
|
|
1033
|
+
});
|
|
996
1034
|
});
|
|
997
1035
|
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
|
998
1036
|
const expected = utils.flag(this, "object");
|
|
999
1037
|
const error = utils.flag(this, "error");
|
|
1000
1038
|
const test = utils.flag(this, "vitest-test");
|
|
1001
|
-
|
|
1039
|
+
const errorMessage = utils.flag(this, "message");
|
|
1040
|
+
getSnapshotClient().assert({
|
|
1041
|
+
received: getErrorString(expected),
|
|
1042
|
+
test,
|
|
1043
|
+
message,
|
|
1044
|
+
inlineSnapshot,
|
|
1045
|
+
isInline: true,
|
|
1046
|
+
error,
|
|
1047
|
+
errorMessage
|
|
1048
|
+
});
|
|
1002
1049
|
});
|
|
1003
1050
|
};
|
|
1004
1051
|
|
|
@@ -1307,8 +1354,8 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
|
1307
1354
|
def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
|
|
1308
1355
|
const spy = getSpy(this);
|
|
1309
1356
|
const spyName = spy.getMockName();
|
|
1310
|
-
const
|
|
1311
|
-
this.assert(
|
|
1357
|
+
const successfulReturns = spy.mock.results.reduce((success, { type }) => type === "throw" ? success : ++success, 0);
|
|
1358
|
+
this.assert(successfulReturns === times, `expected "${spyName}" to be successfully called ${times} times`, `expected "${spyName}" to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfulReturns}`);
|
|
1312
1359
|
});
|
|
1313
1360
|
def(["toHaveReturnedWith", "toReturnWith"], function(value) {
|
|
1314
1361
|
const spy = getSpy(this);
|
|
@@ -1764,7 +1811,7 @@ function withTimeout(fn, timeout = getDefaultTestTimeout(), isHook = false) {
|
|
|
1764
1811
|
}
|
|
1765
1812
|
function createTestContext(test) {
|
|
1766
1813
|
const context = function() {
|
|
1767
|
-
throw new Error("done() callback is
|
|
1814
|
+
throw new Error("done() callback is deprecated, use promise instead");
|
|
1768
1815
|
};
|
|
1769
1816
|
context.meta = test;
|
|
1770
1817
|
let _expect;
|
|
@@ -1919,6 +1966,8 @@ function createSuite() {
|
|
|
1919
1966
|
});
|
|
1920
1967
|
};
|
|
1921
1968
|
};
|
|
1969
|
+
suite2.skipIf = (condition) => condition ? suite2.skip : suite2;
|
|
1970
|
+
suite2.runIf = (condition) => condition ? suite2 : suite2.skip;
|
|
1922
1971
|
return suite2;
|
|
1923
1972
|
}
|
|
1924
1973
|
function createTest(fn) {
|
|
@@ -1931,6 +1980,8 @@ function createTest(fn) {
|
|
|
1931
1980
|
});
|
|
1932
1981
|
};
|
|
1933
1982
|
};
|
|
1983
|
+
test2.skipIf = (condition) => condition ? test2.skip : test2;
|
|
1984
|
+
test2.runIf = (condition) => condition ? test2 : test2.skip;
|
|
1934
1985
|
return test2;
|
|
1935
1986
|
}
|
|
1936
1987
|
|
|
@@ -4632,8 +4683,10 @@ class VitestUtils {
|
|
|
4632
4683
|
});
|
|
4633
4684
|
this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
|
|
4634
4685
|
this._mockedDate = null;
|
|
4635
|
-
if (!this._mocker)
|
|
4636
|
-
|
|
4686
|
+
if (!this._mocker) {
|
|
4687
|
+
const errorMsg = 'Vitest was initialized with native Node instead of Vite Node.\n\nOne of the following is possible:\n- "vitest" is imported outside of your tests (in that case, use "vitest/node" or import.meta.vitest)\n- "vitest" is imported inside "globalSetup" (use "setupFiles", because "globalSetup" runs in a different context)\n- Your dependency inside "node_modules" imports "vitest" directly (in that case, inline that dependency, using "deps.inline" config)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
|
|
4688
|
+
throw new Error(errorMsg);
|
|
4689
|
+
}
|
|
4637
4690
|
}
|
|
4638
4691
|
useFakeTimers() {
|
|
4639
4692
|
this._timers.useFakeTimers();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
1
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.3cb38009.js';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import { b as getWorkerState,
|
|
3
|
+
import { b as getWorkerState, D as isWindows, E as mergeSlashes, h as dirname, f as basename, k as resolve, F as getType, G as getAllProperties, s as slash } from './chunk-utils-global.eb31f3da.js';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import { d as distDir } from './chunk-constants.
|
|
5
|
+
import { d as distDir } from './chunk-constants.54c46a47.js';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -20,22 +20,6 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
}
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
|
-
function getType(value) {
|
|
24
|
-
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
25
|
-
}
|
|
26
|
-
function getAllProperties(obj) {
|
|
27
|
-
const allProps = /* @__PURE__ */ new Set();
|
|
28
|
-
let curr = obj;
|
|
29
|
-
do {
|
|
30
|
-
if (curr === Object.prototype || curr === Function.prototype || curr === RegExp.prototype)
|
|
31
|
-
break;
|
|
32
|
-
const props = Object.getOwnPropertyNames(curr);
|
|
33
|
-
const symbs = Object.getOwnPropertySymbols(curr);
|
|
34
|
-
props.forEach((prop) => allProps.add(prop));
|
|
35
|
-
symbs.forEach((symb) => allProps.add(symb));
|
|
36
|
-
} while (curr = Object.getPrototypeOf(curr));
|
|
37
|
-
return Array.from(allProps);
|
|
38
|
-
}
|
|
39
23
|
const _VitestMocker = class {
|
|
40
24
|
constructor(options, moduleCache, request) {
|
|
41
25
|
this.options = options;
|
|
@@ -136,8 +120,8 @@ const _VitestMocker = class {
|
|
|
136
120
|
else if (type !== "Object" && type !== "Module")
|
|
137
121
|
return value;
|
|
138
122
|
const newObj = {};
|
|
139
|
-
const
|
|
140
|
-
for (const k of
|
|
123
|
+
const properties = getAllProperties(value);
|
|
124
|
+
for (const k of properties) {
|
|
141
125
|
newObj[k] = this.mockValue(value[k]);
|
|
142
126
|
const type2 = getType(value[k]);
|
|
143
127
|
if (type2.includes("Function") && !value[k]._isMockFunction) {
|
|
@@ -250,6 +250,19 @@ function getWorkerState() {
|
|
|
250
250
|
return globalThis.__vitest_worker__;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
function getAllProperties(obj) {
|
|
254
|
+
const allProps = /* @__PURE__ */ new Set();
|
|
255
|
+
let curr = obj;
|
|
256
|
+
do {
|
|
257
|
+
if (curr === Object.prototype || curr === Function.prototype || curr === RegExp.prototype)
|
|
258
|
+
break;
|
|
259
|
+
const props = Object.getOwnPropertyNames(curr);
|
|
260
|
+
const symbs = Object.getOwnPropertySymbols(curr);
|
|
261
|
+
props.forEach((prop) => allProps.add(prop));
|
|
262
|
+
symbs.forEach((symb) => allProps.add(symb));
|
|
263
|
+
} while (curr = Object.getPrototypeOf(curr));
|
|
264
|
+
return Array.from(allProps);
|
|
265
|
+
}
|
|
253
266
|
function notNullish(v) {
|
|
254
267
|
return v != null;
|
|
255
268
|
}
|
|
@@ -261,6 +274,27 @@ function mergeSlashes(str) {
|
|
|
261
274
|
}
|
|
262
275
|
const noop = () => {
|
|
263
276
|
};
|
|
277
|
+
function getType(value) {
|
|
278
|
+
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
279
|
+
}
|
|
280
|
+
function clone(val) {
|
|
281
|
+
let k, out, tmp;
|
|
282
|
+
if (Array.isArray(val)) {
|
|
283
|
+
out = Array(k = val.length);
|
|
284
|
+
while (k--)
|
|
285
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
289
|
+
out = Object.create(Object.getPrototypeOf(val));
|
|
290
|
+
const props = getAllProperties(val);
|
|
291
|
+
for (const k2 of props) {
|
|
292
|
+
out[k2] = (tmp = val[k2]) && typeof tmp === "object" ? clone(tmp) : tmp;
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
296
|
+
return val;
|
|
297
|
+
}
|
|
264
298
|
function toArray(array) {
|
|
265
299
|
if (array === null || array === void 0)
|
|
266
300
|
array = [];
|
|
@@ -301,6 +335,9 @@ function assertTypes(value, name, types) {
|
|
|
301
335
|
if (!pass)
|
|
302
336
|
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
303
337
|
}
|
|
338
|
+
function stdout() {
|
|
339
|
+
return console._stdout || process.stdout;
|
|
340
|
+
}
|
|
304
341
|
|
|
305
342
|
function getTests(suite) {
|
|
306
343
|
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
|
|
@@ -420,4 +457,4 @@ function getCallLastIndex(code) {
|
|
|
420
457
|
return null;
|
|
421
458
|
}
|
|
422
459
|
|
|
423
|
-
export {
|
|
460
|
+
export { ensurePackageInstalled as A, stdout as B, extname as C, isWindows as D, mergeSlashes as E, getType as F, getAllProperties as G, clone as H, partitionSuiteChildren as I, hasTests as J, index as a, getWorkerState as b, getNames as c, assertTypes as d, notNullish as e, basename as f, getCallLastIndex as g, dirname as h, isObject as i, join as j, resolve as k, isAbsolute as l, relative as m, noop as n, getTests as o, picocolors as p, getFullName as q, resetModules as r, slash as s, toArray as t, hasFailed as u, hasFailedSnapshot as v, getSuites as w, normalize as x, deepMerge as y, toNamespacedPath as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.
|
|
1
|
+
import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.eb31f3da.js';
|
|
2
2
|
|
|
3
3
|
const setTimeout$1 = globalThis.setTimeout;
|
|
4
4
|
const setInterval = globalThis.setInterval;
|
|
@@ -5656,6 +5656,8 @@ const stackBarePathRE = /at ?(.*) (.+):(\d+):(\d+)$/;
|
|
|
5656
5656
|
async function interpretSourcePos(stackFrames, ctx) {
|
|
5657
5657
|
var _a;
|
|
5658
5658
|
for (const frame of stackFrames) {
|
|
5659
|
+
if ("sourcePos" in frame)
|
|
5660
|
+
continue;
|
|
5659
5661
|
const transformResult = (_a = ctx.server.moduleGraph.getModuleById(frame.file)) == null ? void 0 : _a.ssrTransformResult;
|
|
5660
5662
|
if (!transformResult)
|
|
5661
5663
|
continue;
|