vitest 0.27.0 → 0.27.2

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.
Files changed (40) hide show
  1. package/LICENSE.md +13 -12
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +10 -10
  4. package/dist/{chunk-api-setup.16ac28c0.js → chunk-api-setup.029198e3.js} +54 -30
  5. package/dist/{chunk-env-node.b3664da2.js → chunk-env-node.787e9561.js} +7 -0
  6. package/dist/{chunk-install-pkg.6dd2bae6.js → chunk-install-pkg.7b006b3e.js} +8 -8
  7. package/dist/{chunk-integrations-globals.3dfaeb99.js → chunk-integrations-globals.0024ce21.js} +6 -6
  8. package/dist/{chunk-mock-date.a1c85759.js → chunk-mock-date.c543fa3e.js} +15 -7
  9. package/dist/{chunk-node-git.543e964a.js → chunk-node-git.125c9008.js} +3 -3
  10. package/dist/{chunk-runtime-chain.6df5a66b.js → chunk-runtime-chain.2da9e75c.js} +6 -6
  11. package/dist/{chunk-runtime-error.fad2c32b.js → chunk-runtime-error.de671af0.js} +1 -1
  12. package/dist/{chunk-runtime-mocker.a677dd28.js → chunk-runtime-mocker.58511c38.js} +4 -4
  13. package/dist/{chunk-runtime-rpc.7f83c8a9.js → chunk-runtime-rpc.d709e91b.js} +1 -1
  14. package/dist/{chunk-runtime-setup.731b2b04.js → chunk-runtime-setup.35da9209.js} +15 -12
  15. package/dist/{chunk-snapshot-manager.700322bf.js → chunk-snapshot-manager.ce714e21.js} +127 -57
  16. package/dist/{chunk-utils-env.b861e3a0.js → chunk-utils-env.f4a39d2c.js} +7 -7
  17. package/dist/{chunk-utils-import.2baa69a9.js → chunk-utils-import.054ab315.js} +47 -4
  18. package/dist/{chunk-utils-source-map.60562959.js → chunk-utils-source-map.5f5d12cf.js} +2 -2
  19. package/dist/cli-wrapper.js +5 -5
  20. package/dist/cli.js +8 -8
  21. package/dist/config.cjs +1 -1
  22. package/dist/config.d.ts +1 -1
  23. package/dist/config.js +1 -1
  24. package/dist/entry.js +9 -9
  25. package/dist/environments.d.ts +1 -1
  26. package/dist/environments.js +1 -1
  27. package/dist/{index-2d10c3fd.d.ts → index-50755efe.d.ts} +4 -2
  28. package/dist/index.d.ts +8 -4
  29. package/dist/index.js +7 -7
  30. package/dist/loader.js +8 -9
  31. package/dist/node.d.ts +2 -2
  32. package/dist/node.js +12 -10
  33. package/dist/suite.js +5 -5
  34. package/dist/{types-e1e1d1e5.d.ts → types-d97c72c7.d.ts} +17 -3
  35. package/dist/{vendor-index.b2fdde54.js → vendor-index.451e37bc.js} +1 -1
  36. package/dist/vendor-index.b0346fe4.js +395 -0
  37. package/dist/{vendor-index.7a2cebfe.js → vendor-index.e6c27006.js} +12 -12
  38. package/dist/worker.js +23 -18
  39. package/package.json +10 -9
  40. package/dist/vendor-index.2e96c50b.js +0 -215
package/LICENSE.md CHANGED
@@ -2138,24 +2138,25 @@ By: Einar Otto Stangvik
2138
2138
  Repository: websockets/ws
2139
2139
 
2140
2140
  > Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2141
+ > Copyright (c) 2013 Arnout Kazemier and contributors
2142
+ > Copyright (c) 2016 Luigi Pinca and contributors
2141
2143
  >
2142
- > Permission is hereby granted, free of charge, to any person obtaining a copy
2143
- > of this software and associated documentation files (the "Software"), to deal
2144
- > in the Software without restriction, including without limitation the rights
2145
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2146
- > copies of the Software, and to permit persons to whom the Software is
2147
- > furnished to do so, subject to the following conditions:
2144
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of
2145
+ > this software and associated documentation files (the "Software"), to deal in
2146
+ > the Software without restriction, including without limitation the rights to
2147
+ > use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
2148
+ > the Software, and to permit persons to whom the Software is furnished to do so,
2149
+ > subject to the following conditions:
2148
2150
  >
2149
2151
  > The above copyright notice and this permission notice shall be included in all
2150
2152
  > copies or substantial portions of the Software.
2151
2153
  >
2152
2154
  > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2153
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2154
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2155
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2156
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2157
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2158
- > SOFTWARE.
2155
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
2156
+ > FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
2157
+ > COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
2158
+ > IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2159
+ > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2159
2160
 
2160
2161
  ---------------------------------------
2161
2162
 
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-2d10c3fd.js';
2
- import { b as ResolvedConfig } from './types-e1e1d1e5.js';
3
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ao as BaseCoverageOptions, au as BenchFunction, as as Benchmark, av as BenchmarkAPI, at as BenchmarkResult, ar as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ab as Constructable, i as Context, aq as CoverageC8Options, ap as CoverageIstanbulOptions, am as CoverageOptions, aj as CoverageProvider, ak as CoverageProviderModule, al as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ah as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, c as ModuleGraphData, aa as MutableArray, a5 as Nullable, ai as OnServerRestartHandler, O as OnTestFailedHandler, ag as ParsedStack, e as RawErrsMap, d as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, an as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, q as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, f as TscErrorInfo, l as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, k as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-e1e1d1e5.js';
1
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-50755efe.js';
2
+ import { b as ResolvedConfig } from './types-d97c72c7.js';
3
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ab as Constructable, i as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, aj as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ah as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, c as ModuleGraphData, aa as MutableArray, a5 as Nullable, ai as OnServerRestartHandler, O as OnTestFailedHandler, ag as ParsedStack, e as RawErrsMap, ak as ReportContext, d as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, q as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, f as TscErrorInfo, l as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, k as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-d97c72c7.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
package/dist/browser.js CHANGED
@@ -1,31 +1,31 @@
1
- export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6df5a66b.js';
2
- import { e as dist } from './chunk-utils-import.2baa69a9.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-utils-import.2baa69a9.js';
4
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.731b2b04.js';
1
+ export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.2da9e75c.js';
2
+ import { e as dist } from './chunk-utils-import.054ab315.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-utils-import.054ab315.js';
4
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.35da9209.js';
5
5
  import * as chai from 'chai';
6
6
  export { chai };
7
7
  export { assert, should } from 'chai';
8
8
  import 'util';
9
- import './chunk-mock-date.a1c85759.js';
9
+ import './chunk-mock-date.c543fa3e.js';
10
10
  import 'node:path';
11
11
  import 'picocolors';
12
12
  import 'local-pkg';
13
- import './chunk-utils-env.b861e3a0.js';
13
+ import './chunk-utils-env.f4a39d2c.js';
14
14
  import 'node:url';
15
15
  import 'path';
16
16
  import './vendor-_commonjsHelpers.addc3445.js';
17
17
  import './chunk-utils-timers.52534f96.js';
18
18
  import './vendor-index.723a074f.js';
19
19
  import 'tinyspy';
20
- import './chunk-utils-source-map.60562959.js';
21
- import './chunk-runtime-rpc.7f83c8a9.js';
20
+ import './chunk-utils-source-map.5f5d12cf.js';
21
+ import './chunk-runtime-rpc.d709e91b.js';
22
22
  import 'node:fs';
23
23
  import 'fs';
24
24
  import 'perf_hooks';
25
25
  import './chunk-integrations-coverage.44413252.js';
26
- import './chunk-runtime-error.fad2c32b.js';
26
+ import './chunk-runtime-error.de671af0.js';
27
27
  import 'vite-node/source-map';
28
- import './chunk-env-node.b3664da2.js';
28
+ import './chunk-env-node.787e9561.js';
29
29
  import 'node:console';
30
30
 
31
31
 
@@ -1,7 +1,8 @@
1
1
  import { promises } from 'node:fs';
2
2
  import { c as createBirpc } from './vendor-index.783e7f3e.js';
3
- import require$$0$1 from 'stream';
3
+ import require$$0$2 from 'stream';
4
4
  import require$$0 from 'zlib';
5
+ import require$$0$1 from 'buffer';
5
6
  import require$$3 from 'net';
6
7
  import require$$4 from 'tls';
7
8
  import require$$5 from 'crypto';
@@ -9,9 +10,9 @@ import require$$2 from 'events';
9
10
  import require$$1 from 'https';
10
11
  import require$$2$1 from 'http';
11
12
  import require$$7 from 'url';
12
- import { A as API_PATH } from './chunk-utils-env.b861e3a0.js';
13
- import './chunk-mock-date.a1c85759.js';
14
- import { b as parseStacktrace } from './chunk-utils-source-map.60562959.js';
13
+ import { A as API_PATH } from './chunk-utils-env.f4a39d2c.js';
14
+ import './chunk-mock-date.c543fa3e.js';
15
+ import { b as parseStacktrace } from './chunk-utils-source-map.5f5d12cf.js';
15
16
  import 'node:url';
16
17
  import 'path';
17
18
  import 'node:path';
@@ -163,6 +164,8 @@ var mask;
163
164
 
164
165
  const { EMPTY_BUFFER: EMPTY_BUFFER$3 } = constants;
165
166
 
167
+ const FastBuffer$2 = Buffer[Symbol.species];
168
+
166
169
  /**
167
170
  * Merges an array of buffers into a new buffer.
168
171
  *
@@ -184,7 +187,9 @@ function concat$1(list, totalLength) {
184
187
  offset += buf.length;
185
188
  }
186
189
 
187
- if (offset < totalLength) return target.slice(0, offset);
190
+ if (offset < totalLength) {
191
+ return new FastBuffer$2(target.buffer, target.byteOffset, offset);
192
+ }
188
193
 
189
194
  return target;
190
195
  }
@@ -226,11 +231,11 @@ function _unmask(buffer, mask) {
226
231
  * @public
227
232
  */
228
233
  function toArrayBuffer$1(buf) {
229
- if (buf.byteLength === buf.buffer.byteLength) {
234
+ if (buf.length === buf.buffer.byteLength) {
230
235
  return buf.buffer;
231
236
  }
232
237
 
233
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
238
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
234
239
  }
235
240
 
236
241
  /**
@@ -249,9 +254,9 @@ function toBuffer$2(data) {
249
254
  let buf;
250
255
 
251
256
  if (data instanceof ArrayBuffer) {
252
- buf = Buffer.from(data);
257
+ buf = new FastBuffer$2(data);
253
258
  } else if (ArrayBuffer.isView(data)) {
254
- buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
259
+ buf = new FastBuffer$2(data.buffer, data.byteOffset, data.byteLength);
255
260
  } else {
256
261
  buf = Buffer.from(data);
257
262
  toBuffer$2.readOnly = false;
@@ -347,6 +352,7 @@ const bufferUtil = bufferUtil$1.exports;
347
352
  const Limiter = limiter;
348
353
  const { kStatusCode: kStatusCode$2 } = constants;
349
354
 
355
+ const FastBuffer$1 = Buffer[Symbol.species];
350
356
  const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
351
357
  const kPerMessageDeflate = Symbol('permessage-deflate');
352
358
  const kTotalLength = Symbol('total-length');
@@ -778,7 +784,9 @@ class PerMessageDeflate$4 {
778
784
  this._deflate[kTotalLength]
779
785
  );
780
786
 
781
- if (fin) data = data.slice(0, data.length - 4);
787
+ if (fin) {
788
+ data = new FastBuffer$1(data.buffer, data.byteOffset, data.length - 4);
789
+ }
782
790
 
783
791
  //
784
792
  // Ensure that the callback will not be called again in
@@ -855,6 +863,8 @@ var validation = {exports: {}};
855
863
 
856
864
  var isValidUTF8_1;
857
865
 
866
+ const { isUtf8 } = require$$0$1;
867
+
858
868
  //
859
869
  // Allowed token characters:
860
870
  //
@@ -966,20 +976,23 @@ validation.exports = {
966
976
  tokenChars: tokenChars$2
967
977
  };
968
978
 
969
- /* istanbul ignore else */
970
- if (!process.env.WS_NO_UTF_8_VALIDATE) {
979
+ if (isUtf8) {
980
+ isValidUTF8_1 = validation.exports.isValidUTF8 = function (buf) {
981
+ return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
982
+ };
983
+ } /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
971
984
  try {
972
985
  const isValidUTF8 = require('utf-8-validate');
973
986
 
974
987
  isValidUTF8_1 = validation.exports.isValidUTF8 = function (buf) {
975
- return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
988
+ return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
976
989
  };
977
990
  } catch (e) {
978
991
  // Continue regardless of the error.
979
992
  }
980
993
  }
981
994
 
982
- const { Writable } = require$$0$1;
995
+ const { Writable } = require$$0$2;
983
996
 
984
997
  const PerMessageDeflate$3 = permessageDeflate;
985
998
  const {
@@ -991,6 +1004,7 @@ const {
991
1004
  const { concat, toArrayBuffer, unmask } = bufferUtil$1.exports;
992
1005
  const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validation.exports;
993
1006
 
1007
+ const FastBuffer = Buffer[Symbol.species];
994
1008
  const GET_INFO = 0;
995
1009
  const GET_PAYLOAD_LENGTH_16 = 1;
996
1010
  const GET_PAYLOAD_LENGTH_64 = 2;
@@ -1076,8 +1090,13 @@ class Receiver$1 extends Writable {
1076
1090
 
1077
1091
  if (n < this._buffers[0].length) {
1078
1092
  const buf = this._buffers[0];
1079
- this._buffers[0] = buf.slice(n);
1080
- return buf.slice(0, n);
1093
+ this._buffers[0] = new FastBuffer(
1094
+ buf.buffer,
1095
+ buf.byteOffset + n,
1096
+ buf.length - n
1097
+ );
1098
+
1099
+ return new FastBuffer(buf.buffer, buf.byteOffset, n);
1081
1100
  }
1082
1101
 
1083
1102
  const dst = Buffer.allocUnsafe(n);
@@ -1090,7 +1109,11 @@ class Receiver$1 extends Writable {
1090
1109
  dst.set(this._buffers.shift(), offset);
1091
1110
  } else {
1092
1111
  dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
1093
- this._buffers[0] = buf.slice(n);
1112
+ this._buffers[0] = new FastBuffer(
1113
+ buf.buffer,
1114
+ buf.byteOffset + n,
1115
+ buf.length - n
1116
+ );
1094
1117
  }
1095
1118
 
1096
1119
  n -= buf.length;
@@ -1238,7 +1261,10 @@ class Receiver$1 extends Writable {
1238
1261
  );
1239
1262
  }
1240
1263
 
1241
- if (this._payloadLength > 0x7d) {
1264
+ if (
1265
+ this._payloadLength > 0x7d ||
1266
+ (this._opcode === 0x08 && this._payloadLength === 1)
1267
+ ) {
1242
1268
  this._loop = false;
1243
1269
  return error(
1244
1270
  RangeError,
@@ -1525,14 +1551,6 @@ class Receiver$1 extends Writable {
1525
1551
  if (data.length === 0) {
1526
1552
  this.emit('conclude', 1005, EMPTY_BUFFER$2);
1527
1553
  this.end();
1528
- } else if (data.length === 1) {
1529
- return error(
1530
- RangeError,
1531
- 'invalid payload length 1',
1532
- true,
1533
- 1002,
1534
- 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH'
1535
- );
1536
1554
  } else {
1537
1555
  const code = data.readUInt16BE(0);
1538
1556
 
@@ -1546,7 +1564,11 @@ class Receiver$1 extends Writable {
1546
1564
  );
1547
1565
  }
1548
1566
 
1549
- const buf = data.slice(2);
1567
+ const buf = new FastBuffer(
1568
+ data.buffer,
1569
+ data.byteOffset + 2,
1570
+ data.length - 2
1571
+ );
1550
1572
 
1551
1573
  if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
1552
1574
  return error(
@@ -2844,7 +2866,8 @@ class WebSocket$1 extends EventEmitter$1 {
2844
2866
  if (this.readyState === WebSocket$1.CLOSED) return;
2845
2867
  if (this.readyState === WebSocket$1.CONNECTING) {
2846
2868
  const msg = 'WebSocket was closed before the connection was established';
2847
- return abortHandshake$1(this, this._req, msg);
2869
+ abortHandshake$1(this, this._req, msg);
2870
+ return;
2848
2871
  }
2849
2872
 
2850
2873
  if (this.readyState === WebSocket$1.CLOSING) {
@@ -3039,7 +3062,8 @@ class WebSocket$1 extends EventEmitter$1 {
3039
3062
  if (this.readyState === WebSocket$1.CLOSED) return;
3040
3063
  if (this.readyState === WebSocket$1.CONNECTING) {
3041
3064
  const msg = 'WebSocket was closed before the connection was established';
3042
- return abortHandshake$1(this, this._req, msg);
3065
+ abortHandshake$1(this, this._req, msg);
3066
+ return;
3043
3067
  }
3044
3068
 
3045
3069
  if (this._socket) {
@@ -3658,7 +3682,7 @@ function sendAfterClose(websocket, data, cb) {
3658
3682
  `WebSocket is not open: readyState ${websocket.readyState} ` +
3659
3683
  `(${readyStates[websocket.readyState]})`
3660
3684
  );
3661
- cb(err);
3685
+ process.nextTick(cb, err);
3662
3686
  }
3663
3687
  }
3664
3688
 
@@ -286,6 +286,13 @@ function populateGlobal(global, win, options = {}) {
286
286
  global.parent = global;
287
287
  if (global.global)
288
288
  global.global = global;
289
+ if (global.document && global.document.defaultView) {
290
+ Object.defineProperty(global.document, "defaultView", {
291
+ get: () => global,
292
+ enumerable: true,
293
+ configurable: true
294
+ });
295
+ }
289
296
  skipKeys.forEach((k) => keys.add(k));
290
297
  return {
291
298
  keys,
@@ -1,8 +1,8 @@
1
1
  import require$$0 from 'fs';
2
- import g from 'path';
2
+ import k from 'path';
3
3
  import util from 'util';
4
4
  import require$$0$2 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.7a2cebfe.js';
5
+ import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.e6c27006.js';
6
6
  import { o as onetime$1 } from './vendor-index.9c919048.js';
7
7
  import require$$0$1 from 'os';
8
8
  import './vendor-_commonjsHelpers.addc3445.js';
@@ -205,7 +205,7 @@ const pLocate$1 = async (iterable, tester, options) => {
205
205
 
206
206
  var pLocate_1 = pLocate$1;
207
207
 
208
- const path$1 = g;
208
+ const path$1 = k;
209
209
  const fs$1 = require$$0;
210
210
  const {promisify: promisify$1} = util;
211
211
  const pLocate = pLocate_1;
@@ -299,7 +299,7 @@ pathExists.exports.sync = path => {
299
299
  };
300
300
 
301
301
  (function (module) {
302
- const path = g;
302
+ const path = k;
303
303
  const locatePath$1 = locatePath.exports;
304
304
  const pathExists$1 = pathExists.exports;
305
305
 
@@ -411,7 +411,7 @@ var stripFinalNewline$1 = input => {
411
411
  var npmRunPath$1 = {exports: {}};
412
412
 
413
413
  (function (module) {
414
- const path = g;
414
+ const path = k;
415
415
  const pathKey$1 = pathKey.exports;
416
416
 
417
417
  const npmRunPath = options => {
@@ -1341,7 +1341,7 @@ var command = {
1341
1341
  parseCommand: parseCommand$1
1342
1342
  };
1343
1343
 
1344
- const path = g;
1344
+ const path = k;
1345
1345
  const childProcess = require$$0$2;
1346
1346
  const crossSpawn = crossSpawn$1.exports;
1347
1347
  const stripFinalNewline = stripFinalNewline$1;
@@ -1623,7 +1623,7 @@ async function detectPackageManager(cwd = process.cwd()) {
1623
1623
  const lockPath = await findUp(Object.keys(LOCKS), { cwd });
1624
1624
  let packageJsonPath;
1625
1625
  if (lockPath)
1626
- packageJsonPath = g.resolve(lockPath, "../package.json");
1626
+ packageJsonPath = k.resolve(lockPath, "../package.json");
1627
1627
  else
1628
1628
  packageJsonPath = await findUp("package.json", { cwd });
1629
1629
  if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
@@ -1644,7 +1644,7 @@ async function detectPackageManager(cwd = process.cwd()) {
1644
1644
  }
1645
1645
  }
1646
1646
  if (!agent && lockPath)
1647
- agent = LOCKS[g.basename(lockPath)];
1647
+ agent = LOCKS[k.basename(lockPath)];
1648
1648
  return agent;
1649
1649
  }
1650
1650
  async function installPackage(names, options = {}) {
@@ -1,11 +1,11 @@
1
- import { m as globalApis } from './chunk-utils-env.b861e3a0.js';
2
- import { i as index } from './chunk-utils-import.2baa69a9.js';
1
+ import { m as globalApis } from './chunk-utils-env.f4a39d2c.js';
2
+ import { i as index } from './chunk-utils-import.054ab315.js';
3
3
  import 'node:url';
4
4
  import 'path';
5
- import './chunk-runtime-chain.6df5a66b.js';
5
+ import './chunk-runtime-chain.2da9e75c.js';
6
6
  import 'util';
7
7
  import 'chai';
8
- import './chunk-mock-date.a1c85759.js';
8
+ import './chunk-mock-date.c543fa3e.js';
9
9
  import 'node:path';
10
10
  import 'picocolors';
11
11
  import 'local-pkg';
@@ -13,8 +13,8 @@ import './vendor-_commonjsHelpers.addc3445.js';
13
13
  import './chunk-utils-timers.52534f96.js';
14
14
  import './vendor-index.723a074f.js';
15
15
  import 'tinyspy';
16
- import './chunk-utils-source-map.60562959.js';
17
- import './chunk-runtime-rpc.7f83c8a9.js';
16
+ import './chunk-utils-source-map.5f5d12cf.js';
17
+ import './chunk-runtime-rpc.d709e91b.js';
18
18
  import 'node:fs';
19
19
  import 'fs';
20
20
 
@@ -1,7 +1,7 @@
1
1
  import { relative } from 'node:path';
2
2
  import c from 'picocolors';
3
3
  import { isPackageExists } from 'local-pkg';
4
- import { i as isNode, a as isBrowser, r as relative$1, E as EXIT_CODE_RESTART } from './chunk-utils-env.b861e3a0.js';
4
+ import { i as isNode, a as isBrowser, r as relative$1, E as EXIT_CODE_RESTART } from './chunk-utils-env.f4a39d2c.js';
5
5
 
6
6
  const RealDate = Date;
7
7
  let now = null;
@@ -60,8 +60,8 @@ function collectOwnProperties(obj, collector) {
60
60
  Object.getOwnPropertyNames(obj).forEach(collect);
61
61
  Object.getOwnPropertySymbols(obj).forEach(collect);
62
62
  }
63
- function getAllMockableProperties(obj) {
64
- const allProps = /* @__PURE__ */ new Set();
63
+ function getAllMockableProperties(obj, isModule) {
64
+ const allProps = /* @__PURE__ */ new Map();
65
65
  let curr = obj;
66
66
  do {
67
67
  if (isFinalObj(curr))
@@ -69,10 +69,15 @@ function getAllMockableProperties(obj) {
69
69
  collectOwnProperties(curr, (key) => {
70
70
  const descriptor = Object.getOwnPropertyDescriptor(curr, key);
71
71
  if (descriptor)
72
- allProps.add({ key, descriptor });
72
+ allProps.set(key, { key, descriptor });
73
73
  });
74
74
  } while (curr = Object.getPrototypeOf(curr));
75
- return Array.from(allProps);
75
+ if (isModule && !allProps.has("default") && "default" in obj) {
76
+ const descriptor = Object.getOwnPropertyDescriptor(obj, "default");
77
+ if (descriptor)
78
+ allProps.set("default", { key: "default", descriptor });
79
+ }
80
+ return Array.from(allProps.values());
76
81
  }
77
82
  function notNullish(v) {
78
83
  return v != null;
@@ -176,6 +181,9 @@ function isAtomTest(s) {
176
181
  function getTests(suite) {
177
182
  return toArray(suite).flatMap((s) => isAtomTest(s) ? [s] : s.tasks.flatMap((c) => isAtomTest(c) ? [c] : getTests(c)));
178
183
  }
184
+ function getTasks(tasks = []) {
185
+ return toArray(tasks).flatMap((s) => isAtomTest(s) ? [s] : [s, ...getTasks(s.tasks)]);
186
+ }
179
187
  function getSuites(suite) {
180
188
  return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
181
189
  }
@@ -272,7 +280,7 @@ async function ensurePackageInstalled(dependency, root) {
272
280
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
273
281
  });
274
282
  if (install) {
275
- await (await import('./chunk-install-pkg.6dd2bae6.js')).installPackage(dependency, { dev: true });
283
+ await (await import('./chunk-install-pkg.7b006b3e.js')).installPackage(dependency, { dev: true });
276
284
  process.stderr.write(c.yellow(`
277
285
  Package ${dependency} installed, re-run the command to start.
278
286
  `));
@@ -338,4 +346,4 @@ function objectAttr(source, path, defaultValue = void 0) {
338
346
  return result;
339
347
  }
340
348
 
341
- export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getSuites as C, deepMerge as D, removeUndefinedValues as E, isWindows as F, stdout as G, getAllMockableProperties as H, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, getCurrentEnvironment as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, createDefer as v, deepClone as w, getType as x, ensurePackageInstalled as y, getTests as z };
349
+ export { AggregateErrorPonyfill as A, getTests as B, hasFailedSnapshot as C, getSuites as D, deepMerge as E, removeUndefinedValues as F, isWindows as G, stdout as H, getAllMockableProperties as I, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, getCurrentEnvironment as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, createDefer as v, deepClone as w, getType as x, ensurePackageInstalled as y, getTasks as z };
@@ -1,12 +1,12 @@
1
- import { b as resolve } from './chunk-utils-env.b861e3a0.js';
2
- import { e as execa } from './vendor-index.b2fdde54.js';
1
+ import { b as resolve } from './chunk-utils-env.f4a39d2c.js';
2
+ import { e as execa } from './vendor-index.451e37bc.js';
3
3
  import 'node:url';
4
4
  import 'path';
5
5
  import 'node:buffer';
6
6
  import 'node:path';
7
7
  import 'node:child_process';
8
8
  import 'node:process';
9
- import './vendor-index.7a2cebfe.js';
9
+ import './vendor-index.e6c27006.js';
10
10
  import 'child_process';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import 'fs';
@@ -1,15 +1,15 @@
1
1
  import util$1 from 'util';
2
2
  import * as chai$2 from 'chai';
3
3
  import { AssertionError, util, expect } from 'chai';
4
- import { i as isObject$1, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as getCurrentEnvironment, e as getFullName, o as objectAttr, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-mock-date.a1c85759.js';
4
+ import { i as isObject$1, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as getCurrentEnvironment, e as getFullName, o as objectAttr, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-mock-date.c543fa3e.js';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
6
6
  import c from 'picocolors';
7
7
  import { c as createPatch, a as stringify, p as plugins_1, f as format_1, s as safeSetTimeout, b as safeClearTimeout } from './chunk-utils-timers.52534f96.js';
8
8
  import { i as isMockFunction } from './vendor-index.723a074f.js';
9
- import { c as cliTruncate, a as positionToOffset, o as offsetToLineNumber, l as lineSplitRE, b as parseStacktrace } from './chunk-utils-source-map.60562959.js';
10
- import { r as rpc } from './chunk-runtime-rpc.7f83c8a9.js';
9
+ import { c as cliTruncate, a as positionToOffset, o as offsetToLineNumber, l as lineSplitRE, b as parseStacktrace } from './chunk-utils-source-map.5f5d12cf.js';
10
+ import { r as rpc } from './chunk-runtime-rpc.d709e91b.js';
11
11
  import fs from 'node:fs';
12
- import { j as join, d as dirname } from './chunk-utils-env.b861e3a0.js';
12
+ import { j as join, d as dirname } from './chunk-utils-env.f4a39d2c.js';
13
13
  import { promises } from 'fs';
14
14
 
15
15
  function createChainable(keys, fn) {
@@ -1175,7 +1175,7 @@ Number of calls: ${c.bold(spy.mock.calls.length)}
1175
1175
  ]
1176
1176
  );
1177
1177
  if (called && isNot)
1178
- msg += formatCalls(spy, msg);
1178
+ msg = formatCalls(spy, msg);
1179
1179
  if (called && isNot || !called && !isNot) {
1180
1180
  const err = new Error(msg);
1181
1181
  err.name = "AssertionError";
@@ -1197,7 +1197,7 @@ Number of calls: ${c.bold(spy.mock.calls.length)}
1197
1197
  ]
1198
1198
  );
1199
1199
  if (pass && isNot || !pass && !isNot) {
1200
- msg += formatCalls(spy, msg, args);
1200
+ msg = formatCalls(spy, msg, args);
1201
1201
  const err = new Error(msg);
1202
1202
  err.name = "AssertionError";
1203
1203
  throw err;
@@ -1,7 +1,7 @@
1
1
  import util$1 from 'util';
2
2
  import { util } from 'chai';
3
3
  import { a as stringify } from './chunk-utils-timers.52534f96.js';
4
- import { w as deepClone, g as getWorkerState, x as getType } from './chunk-mock-date.a1c85759.js';
4
+ import { w as deepClone, g as getWorkerState, x as getType } from './chunk-mock-date.c543fa3e.js';
5
5
 
6
6
  const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
7
7
  const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
@@ -1,10 +1,10 @@
1
1
  import { ViteNodeRunner } from 'vite-node/client';
2
2
  import { isInternalRequest } from 'vite-node/utils';
3
3
  import { normalizePath } from 'vite';
4
- import { i as isNodeBuiltin } from './vendor-index.2e96c50b.js';
5
- import { g as getWorkerState, x as getType, H as getAllMockableProperties, d as getCurrentEnvironment } from './chunk-mock-date.a1c85759.js';
4
+ import { i as isNodeBuiltin } from './vendor-index.b0346fe4.js';
5
+ import { g as getWorkerState, x as getType, I as getAllMockableProperties, d as getCurrentEnvironment } from './chunk-mock-date.c543fa3e.js';
6
6
  import { existsSync, readdirSync } from 'node:fs';
7
- import { b as resolve, f as distDir, h as isAbsolute, d as dirname, j as join, c as basename, e as extname } from './chunk-utils-env.b861e3a0.js';
7
+ import { b as resolve, f as distDir, h as isAbsolute, d as dirname, j as join, c as basename, e as extname } from './chunk-utils-env.f4a39d2c.js';
8
8
  import c from 'picocolors';
9
9
 
10
10
  class RefTracker {
@@ -172,7 +172,7 @@ ${c.green(`vi.mock("${mockpath}", async () => {
172
172
  const mockPropertiesOf = (container, newContainer) => {
173
173
  const containerType = getType(container);
174
174
  const isModule = containerType === "Module" || !!container.__esModule;
175
- for (const { key: property, descriptor } of getAllMockableProperties(container)) {
175
+ for (const { key: property, descriptor } of getAllMockableProperties(container, isModule)) {
176
176
  if (!isModule && descriptor.get) {
177
177
  try {
178
178
  Object.defineProperty(newContainer, property, descriptor);
@@ -1,4 +1,4 @@
1
- import { g as getWorkerState } from './chunk-mock-date.a1c85759.js';
1
+ import { g as getWorkerState } from './chunk-mock-date.c543fa3e.js';
2
2
  import { s as safeSetTimeout } from './chunk-utils-timers.52534f96.js';
3
3
 
4
4
  const safeRandom = Math.random;