vitest 0.12.9 → 0.12.10

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.
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.317f59c6.js';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.eec5d968.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.9e9c5c75.js';
13
- import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.b1b3dfa6.js';
12
+ import { A as API_PATH } from './chunk-constants.e8bc5d35.js';
13
+ import { j as interpretSourcePos, b as parseStacktrace } from './chunk-utils-source-map.6b6c39c8.js';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-utils-global.2529a727.js';
16
+ import './chunk-utils-global.eb9e6d32.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'path';
@@ -3268,6 +3268,7 @@ function initAsClient(websocket, address, protocols, options) {
3268
3268
 
3269
3269
  if (opts.followRedirects) {
3270
3270
  if (websocket._redirects === 0) {
3271
+ websocket._originalSecure = isSecure;
3271
3272
  websocket._originalHost = parsedUrl.host;
3272
3273
 
3273
3274
  const headers = options && options.headers;
@@ -3283,18 +3284,21 @@ function initAsClient(websocket, address, protocols, options) {
3283
3284
  options.headers[key.toLowerCase()] = value;
3284
3285
  }
3285
3286
  }
3286
- } else if (
3287
- websocket.listenerCount('redirect') === 0 &&
3288
- parsedUrl.host !== websocket._originalHost
3289
- ) {
3290
- //
3291
- // Match curl 7.77.0 behavior and drop the following headers. These
3292
- // headers are also dropped when following a redirect to a subdomain.
3293
- //
3294
- delete opts.headers.authorization;
3295
- delete opts.headers.cookie;
3296
- delete opts.headers.host;
3297
- opts.auth = undefined;
3287
+ } else if (websocket.listenerCount('redirect') === 0) {
3288
+ const isSameHost = parsedUrl.host === websocket._originalHost;
3289
+
3290
+ if (!isSameHost || (websocket._originalSecure && !isSecure)) {
3291
+ //
3292
+ // Match curl 7.77.0 behavior and drop the following headers. These
3293
+ // headers are also dropped when following a redirect to a subdomain.
3294
+ //
3295
+ delete opts.headers.authorization;
3296
+ delete opts.headers.cookie;
3297
+
3298
+ if (!isSameHost) delete opts.headers.host;
3299
+
3300
+ opts.auth = undefined;
3301
+ }
3298
3302
  }
3299
3303
 
3300
3304
  //
@@ -3386,6 +3390,11 @@ function initAsClient(websocket, address, protocols, options) {
3386
3390
 
3387
3391
  req = websocket._req = null;
3388
3392
 
3393
+ if (res.headers.upgrade.toLowerCase() !== 'websocket') {
3394
+ abortHandshake$1(websocket, socket, 'Invalid Upgrade header');
3395
+ return;
3396
+ }
3397
+
3389
3398
  const digest = createHash$1('sha1')
3390
3399
  .update(key + GUID$1)
3391
3400
  .digest('base64');
@@ -4071,21 +4080,36 @@ class WebSocketServer extends EventEmitter {
4071
4080
  handleUpgrade(req, socket, head, cb) {
4072
4081
  socket.on('error', socketOnError);
4073
4082
 
4074
- const key =
4075
- req.headers['sec-websocket-key'] !== undefined
4076
- ? req.headers['sec-websocket-key']
4077
- : false;
4083
+ const key = req.headers['sec-websocket-key'];
4078
4084
  const version = +req.headers['sec-websocket-version'];
4079
4085
 
4080
- if (
4081
- req.method !== 'GET' ||
4082
- req.headers.upgrade.toLowerCase() !== 'websocket' ||
4083
- !key ||
4084
- !keyRegex.test(key) ||
4085
- (version !== 8 && version !== 13) ||
4086
- !this.shouldHandle(req)
4087
- ) {
4088
- return abortHandshake(socket, 400);
4086
+ if (req.method !== 'GET') {
4087
+ const message = 'Invalid HTTP method';
4088
+ abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
4089
+ return;
4090
+ }
4091
+
4092
+ if (req.headers.upgrade.toLowerCase() !== 'websocket') {
4093
+ const message = 'Invalid Upgrade header';
4094
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4095
+ return;
4096
+ }
4097
+
4098
+ if (!key || !keyRegex.test(key)) {
4099
+ const message = 'Missing or invalid Sec-WebSocket-Key header';
4100
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4101
+ return;
4102
+ }
4103
+
4104
+ if (version !== 8 && version !== 13) {
4105
+ const message = 'Missing or invalid Sec-WebSocket-Version header';
4106
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4107
+ return;
4108
+ }
4109
+
4110
+ if (!this.shouldHandle(req)) {
4111
+ abortHandshake(socket, 400);
4112
+ return;
4089
4113
  }
4090
4114
 
4091
4115
  const secWebSocketProtocol = req.headers['sec-websocket-protocol'];
@@ -4095,7 +4119,9 @@ class WebSocketServer extends EventEmitter {
4095
4119
  try {
4096
4120
  protocols = subprotocol.parse(secWebSocketProtocol);
4097
4121
  } catch (err) {
4098
- return abortHandshake(socket, 400);
4122
+ const message = 'Invalid Sec-WebSocket-Protocol header';
4123
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4124
+ return;
4099
4125
  }
4100
4126
  }
4101
4127
 
@@ -4120,7 +4146,10 @@ class WebSocketServer extends EventEmitter {
4120
4146
  extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
4121
4147
  }
4122
4148
  } catch (err) {
4123
- return abortHandshake(socket, 400);
4149
+ const message =
4150
+ 'Invalid or unacceptable Sec-WebSocket-Extensions header';
4151
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4152
+ return;
4124
4153
  }
4125
4154
  }
4126
4155
 
@@ -4287,7 +4316,7 @@ function emitClose(server) {
4287
4316
  }
4288
4317
 
4289
4318
  /**
4290
- * Handle premature socket errors.
4319
+ * Handle socket errors.
4291
4320
  *
4292
4321
  * @private
4293
4322
  */
@@ -4305,27 +4334,54 @@ function socketOnError() {
4305
4334
  * @private
4306
4335
  */
4307
4336
  function abortHandshake(socket, code, message, headers) {
4308
- if (socket.writable) {
4309
- message = message || http.STATUS_CODES[code];
4310
- headers = {
4311
- Connection: 'close',
4312
- 'Content-Type': 'text/html',
4313
- 'Content-Length': Buffer.byteLength(message),
4314
- ...headers
4315
- };
4337
+ //
4338
+ // The socket is writable unless the user destroyed or ended it before calling
4339
+ // `server.handleUpgrade()` or in the `verifyClient` function, which is a user
4340
+ // error. Handling this does not make much sense as the worst that can happen
4341
+ // is that some of the data written by the user might be discarded due to the
4342
+ // call to `socket.end()` below, which triggers an `'error'` event that in
4343
+ // turn causes the socket to be destroyed.
4344
+ //
4345
+ message = message || http.STATUS_CODES[code];
4346
+ headers = {
4347
+ Connection: 'close',
4348
+ 'Content-Type': 'text/html',
4349
+ 'Content-Length': Buffer.byteLength(message),
4350
+ ...headers
4351
+ };
4316
4352
 
4317
- socket.write(
4318
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` +
4319
- Object.keys(headers)
4320
- .map((h) => `${h}: ${headers[h]}`)
4321
- .join('\r\n') +
4322
- '\r\n\r\n' +
4323
- message
4324
- );
4325
- }
4353
+ socket.once('finish', socket.destroy);
4326
4354
 
4327
- socket.removeListener('error', socketOnError);
4328
- socket.destroy();
4355
+ socket.end(
4356
+ `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` +
4357
+ Object.keys(headers)
4358
+ .map((h) => `${h}: ${headers[h]}`)
4359
+ .join('\r\n') +
4360
+ '\r\n\r\n' +
4361
+ message
4362
+ );
4363
+ }
4364
+
4365
+ /**
4366
+ * Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
4367
+ * one listener for it, otherwise call `abortHandshake()`.
4368
+ *
4369
+ * @param {WebSocketServer} server The WebSocket server
4370
+ * @param {http.IncomingMessage} req The request object
4371
+ * @param {(net.Socket|tls.Socket)} socket The socket of the upgrade request
4372
+ * @param {Number} code The HTTP response status code
4373
+ * @param {String} message The HTTP response body
4374
+ * @private
4375
+ */
4376
+ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
4377
+ if (server.listenerCount('wsClientError')) {
4378
+ const err = new Error(message);
4379
+ Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
4380
+
4381
+ server.emit('wsClientError', err, socket, req);
4382
+ } else {
4383
+ abortHandshake(socket, code, message);
4384
+ }
4329
4385
  }
4330
4386
 
4331
4387
  function setup(ctx) {
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { h as resolve } from './chunk-utils-global.2529a727.js';
2
+ import { l as resolve } from './chunk-utils-global.eb9e6d32.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, h as resolve } from './chunk-utils-global.2529a727.js';
4
+ import { t as toArray, l as resolve } from './chunk-utils-global.eb9e6d32.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}/**"];
@@ -1,20 +1,20 @@
1
- import { g as globalApis } from './chunk-constants.9e9c5c75.js';
2
- import { i as index } from './vendor-entry.e4d01a65.js';
1
+ import { g as globalApis } from './chunk-constants.e8bc5d35.js';
2
+ import { i as index } from './vendor-entry.3113977a.js';
3
3
  import 'url';
4
- import './chunk-utils-global.2529a727.js';
4
+ import './chunk-utils-global.eb9e6d32.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
- import './chunk-runtime-chain.67ecb3a0.js';
9
+ import './chunk-runtime-chain.d2ed2f76.js';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.5050afd6.js';
13
- import './chunk-utils-timers.b1b3dfa6.js';
12
+ import './chunk-runtime-rpc.d3d38fc1.js';
13
+ import './chunk-utils-source-map.6b6c39c8.js';
14
14
  import './chunk-integrations-spy.bee66426.js';
15
15
  import 'tinyspy';
16
16
  import 'util';
17
- import './chunk-defaults.0fce304d.js';
17
+ import './chunk-defaults.a3120857.js';
18
18
  import 'module';
19
19
 
20
20
  function registerApiGlobally() {
@@ -1,9 +1,9 @@
1
1
  import chai$1, { expect as expect$1, AssertionError, util } from 'chai';
2
2
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
- import { r as rpc } from './chunk-runtime-rpc.5050afd6.js';
4
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.2529a727.js';
3
+ import { r as rpc } from './chunk-runtime-rpc.d3d38fc1.js';
4
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, e as safeSetTimeout, f as safeClearTimeout, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.eb9e6d32.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.b1b3dfa6.js';
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 } from './chunk-utils-source-map.6b6c39c8.js';
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
8
8
  import require$$0, { format } from 'util';
9
9
 
@@ -329,7 +329,7 @@ const hasPropertyInObject = (object, key) => {
329
329
  return false;
330
330
  return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
331
331
  };
332
- const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
332
+ const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !Array.isArray(a) && !(a instanceof Date);
333
333
  const subsetEquality = (object, subset) => {
334
334
  const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object2, subset2) => {
335
335
  if (!isObjectWithKeys(subset2))
@@ -1223,7 +1223,7 @@ const JestChaiExpect = (chai, utils) => {
1223
1223
  } else if (received === -Infinity && expected === -Infinity) {
1224
1224
  pass = true;
1225
1225
  } else {
1226
- expectedDiff = Math.pow(10, -precision) / 2;
1226
+ expectedDiff = 10 ** -precision / 2;
1227
1227
  receivedDiff = Math.abs(expected - received);
1228
1228
  pass = receivedDiff < expectedDiff;
1229
1229
  }
@@ -1717,7 +1717,8 @@ const getMatcherState = (assertion) => {
1717
1717
  utils: jestUtils,
1718
1718
  promise,
1719
1719
  equals,
1720
- suppressedErrors: []
1720
+ suppressedErrors: [],
1721
+ snapshotState: getSnapshotClient().snapshotState
1721
1722
  });
1722
1723
  return {
1723
1724
  state: matcherState,
@@ -1838,8 +1839,8 @@ function withTimeout(fn, timeout = getDefaultTestTimeout(), isHook = false) {
1838
1839
  return (...args) => {
1839
1840
  return Promise.race([fn(...args), new Promise((resolve, reject) => {
1840
1841
  var _a;
1841
- const timer = setTimeout(() => {
1842
- clearTimeout(timer);
1842
+ const timer = safeSetTimeout(() => {
1843
+ safeClearTimeout(timer);
1843
1844
  reject(new Error(makeTimeoutMsg(isHook, timeout)));
1844
1845
  }, timeout);
1845
1846
  (_a = timer.unref) == null ? void 0 : _a.call(timer);
@@ -4850,6 +4851,16 @@ class VitestUtils {
4850
4851
  resetModules();
4851
4852
  return this;
4852
4853
  }
4854
+ async dynamicImportSettled() {
4855
+ const state = getWorkerState();
4856
+ const promises = [];
4857
+ for (const mod of state.moduleCache.values()) {
4858
+ if (mod.promise)
4859
+ promises.push(mod.promise);
4860
+ }
4861
+ await Promise.allSettled(promises);
4862
+ await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve());
4863
+ }
4853
4864
  }
4854
4865
  const vitest = new VitestUtils();
4855
4866
  const vi = vitest;
@@ -1,8 +1,8 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.317f59c6.js';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.eec5d968.js';
2
2
  import { normalizePath } from 'vite';
3
- import { a as getWorkerState, E as isWindows, F as mergeSlashes, d as dirname, h as resolve, f as basename, G as getType, H as getAllProperties, s as slash } from './chunk-utils-global.2529a727.js';
3
+ import { a as getWorkerState, J as isWindows, K as mergeSlashes, d as dirname, l as resolve, k as basename, L as getType, M as getAllProperties, s as slash } from './chunk-utils-global.eb9e6d32.js';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { d as distDir } from './chunk-constants.9e9c5c75.js';
5
+ import { d as distDir } from './chunk-constants.e8bc5d35.js';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -0,0 +1,15 @@
1
+ import { a as getWorkerState, w as withSafeTimers } from './chunk-utils-global.eb9e6d32.js';
2
+
3
+ const rpc = () => {
4
+ const { rpc: rpc2 } = getWorkerState();
5
+ return new Proxy(rpc2, {
6
+ get(target, p, handler) {
7
+ const sendCall = Reflect.get(target, p, handler);
8
+ const safeSendCall = (...args) => withSafeTimers(() => sendCall(...args));
9
+ safeSendCall.asEvent = sendCall.asEvent;
10
+ return safeSendCall;
11
+ }
12
+ });
13
+ };
14
+
15
+ export { rpc as r };
@@ -385,6 +385,32 @@ function getNames(task) {
385
385
  return names;
386
386
  }
387
387
 
388
+ const {
389
+ setTimeout: safeSetTimeout,
390
+ setInterval: safeSetInterval,
391
+ clearInterval: safeClearInterval,
392
+ clearTimeout: safeClearTimeout
393
+ } = globalThis;
394
+ function withSafeTimers(fn) {
395
+ const currentSetTimeout = globalThis.setTimeout;
396
+ const currentSetInterval = globalThis.setInterval;
397
+ const currentClearInterval = globalThis.clearInterval;
398
+ const currentClearTimeout = globalThis.clearTimeout;
399
+ try {
400
+ globalThis.setTimeout = safeSetTimeout;
401
+ globalThis.setInterval = safeSetInterval;
402
+ globalThis.clearInterval = safeClearInterval;
403
+ globalThis.clearTimeout = safeClearTimeout;
404
+ const result = fn();
405
+ return result;
406
+ } finally {
407
+ globalThis.setTimeout = currentSetTimeout;
408
+ globalThis.setInterval = currentSetInterval;
409
+ globalThis.clearInterval = currentClearInterval;
410
+ globalThis.clearTimeout = currentClearTimeout;
411
+ }
412
+ }
413
+
388
414
  const isNode = typeof process !== "undefined" && typeof process.platform !== "undefined";
389
415
  const isWindows = isNode && process.platform === "win32";
390
416
  function partitionSuiteChildren(suite) {
@@ -477,4 +503,4 @@ class AggregateErrorPonyfill extends Error {
477
503
  }
478
504
  }
479
505
 
480
- export { AggregateErrorPonyfill as A, ensurePackageInstalled as B, stdout as C, extname as D, isWindows as E, mergeSlashes as F, getType as G, getAllProperties as H, clone as I, partitionSuiteChildren as J, hasTests as K, getWorkerState as a, getNames as b, assertTypes as c, dirname as d, notNullish as e, basename as f, getCallLastIndex as g, resolve as h, isObject as i, join as j, isAbsolute as k, relative as l, isNode 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 };
506
+ export { AggregateErrorPonyfill as A, safeSetInterval as B, safeClearInterval as C, normalize as D, deepMerge as E, toNamespacedPath as F, ensurePackageInstalled as G, stdout as H, extname as I, isWindows as J, mergeSlashes as K, getType as L, getAllProperties as M, clone as N, partitionSuiteChildren as O, hasTests as P, getWorkerState as a, getNames as b, assertTypes as c, dirname as d, safeSetTimeout as e, safeClearTimeout as f, getCallLastIndex as g, notNullish as h, isObject as i, join as j, basename as k, resolve as l, isAbsolute as m, noop as n, relative as o, picocolors as p, isNode as q, resetModules as r, slash as s, toArray as t, getTests as u, getFullName as v, withSafeTimers as w, hasFailed as x, hasFailedSnapshot as y, getSuites as z };
@@ -1,9 +1,4 @@
1
- import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.2529a727.js';
2
-
3
- const setTimeout$1 = globalThis.setTimeout;
4
- const setInterval = globalThis.setInterval;
5
- const clearInterval = globalThis.clearInterval;
6
- const clearTimeout = globalThis.clearTimeout;
1
+ import { s as slash, h as notNullish, p as picocolors } from './chunk-utils-global.eb9e6d32.js';
7
2
 
8
3
  var build = {};
9
4
 
@@ -5765,6 +5760,11 @@ Diff.prototype = {
5765
5760
  oldLen = oldString.length;
5766
5761
  var editLength = 1;
5767
5762
  var maxEditLength = newLen + oldLen;
5763
+
5764
+ if (options.maxEditLength) {
5765
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
5766
+ }
5767
+
5768
5768
  var bestPath = [{
5769
5769
  newPos: -1,
5770
5770
  components: []
@@ -5829,15 +5829,13 @@ Diff.prototype = {
5829
5829
  editLength++;
5830
5830
  } // Performs the length of edit iteration. Is a bit fugly as this has to support the
5831
5831
  // sync and async mode which is never fun. Loops over execEditLength until a value
5832
- // is produced.
5832
+ // is produced, or until the edit length exceeds options.maxEditLength (if given),
5833
+ // in which case it will return undefined.
5833
5834
 
5834
5835
 
5835
5836
  if (callback) {
5836
5837
  (function exec() {
5837
5838
  setTimeout(function () {
5838
- // This should not happen, but we want to be safe.
5839
-
5840
- /* istanbul ignore next */
5841
5839
  if (editLength > maxEditLength) {
5842
5840
  return callback();
5843
5841
  }
@@ -6236,6 +6234,11 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
6236
6234
  }
6237
6235
 
6238
6236
  var diff = diffLines(oldStr, newStr, options);
6237
+
6238
+ if (!diff) {
6239
+ return;
6240
+ }
6241
+
6239
6242
  diff.push({
6240
6243
  value: '',
6241
6244
  lines: []
@@ -7425,4 +7428,4 @@ var matcherUtils = /*#__PURE__*/Object.freeze({
7425
7428
  diff: diff
7426
7429
  });
7427
7430
 
7428
- export { posToNumber as a, parseStacktrace as b, setTimeout$1 as c, clearTimeout as d, stripAnsi as e, format_1 as f, getOriginalPos as g, stringWidth as h, ansiStyles as i, sliceAnsi as j, setInterval as k, lineSplitRE as l, matcherUtils as m, numberToPos as n, clearInterval as o, plugins_1 as p, cliTruncate as q, interpretSourcePos as r, stringify as s, unifiedDiff as u };
7431
+ export { posToNumber as a, parseStacktrace as b, stripAnsi as c, stringWidth as d, ansiStyles as e, format_1 as f, getOriginalPos as g, sliceAnsi as h, cliTruncate as i, interpretSourcePos as j, lineSplitRE as l, matcherUtils as m, numberToPos as n, plugins_1 as p, stringify as s, unifiedDiff as u };
@@ -5,27 +5,27 @@ import process$1 from 'process';
5
5
  import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.40be925a.js';
6
6
  import url, { fileURLToPath, pathToFileURL } from 'url';
7
7
  import require$$0, { constants as constants$5, cpus, hostname } from 'os';
8
- import { j as join, f as basename, d as dirname, h as resolve, A as AggregateErrorPonyfill, p as picocolors, s as slash$2, k as isAbsolute, l as relative, m as isNode, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, x as normalize, n as noop$1, y as deepMerge, z as toNamespacedPath, g as getCallLastIndex, e as notNullish, B as ensurePackageInstalled, C as stdout } from './chunk-utils-global.2529a727.js';
8
+ import { j as join, k as basename, d as dirname, l as resolve, A as AggregateErrorPonyfill, p as picocolors, s as slash$2, m as isAbsolute, o as relative, q as isNode, u as getTests, v as getFullName, x as hasFailed, y as hasFailedSnapshot, z as getSuites, B as safeSetInterval, C as safeClearInterval, e as safeSetTimeout, t as toArray, D as normalize, n as noop$1, f as safeClearTimeout, E as deepMerge, F as toNamespacedPath, g as getCallLastIndex, h as notNullish, G as ensurePackageInstalled, H as stdout } from './chunk-utils-global.eb9e6d32.js';
9
9
  import { createServer, mergeConfig } from 'vite';
10
10
  import fs$8, { promises, existsSync, readFileSync } from 'fs';
11
- import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.9e9c5c75.js';
11
+ import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.e8bc5d35.js';
12
12
  import readline from 'readline';
13
13
  import require$$0$1 from 'util';
14
14
  import require$$0$2 from 'stream';
15
15
  import require$$2 from 'events';
16
16
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.317f59c6.js';
17
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.eec5d968.js';
18
18
  import createDebug from 'debug';
19
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.0fce304d.js';
19
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.a3120857.js';
20
20
  import { MessageChannel } from 'worker_threads';
21
21
  import { Tinypool } from 'tinypool';
22
22
  import { performance } from 'perf_hooks';
23
- import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.b1b3dfa6.js';
23
+ import { c as stripAnsi, d as stringWidth, e as ansiStyles, h as sliceAnsi, i as cliTruncate, b as parseStacktrace, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.6b6c39c8.js';
24
24
  import { resolveModule } from 'local-pkg';
25
25
  import MagicString from './chunk-magic-string.41232190.js';
26
26
  import { p as prompts } from './vendor-index.405e58ef.js';
27
27
 
28
- var version = "0.12.9";
28
+ var version = "0.12.10";
29
29
 
30
30
  function stripFinalNewline(input) {
31
31
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -9233,7 +9233,7 @@ const createListRenderer = (_tasks, options) => {
9233
9233
  start() {
9234
9234
  if (timer)
9235
9235
  return this;
9236
- timer = setInterval(update, 200);
9236
+ timer = safeSetInterval(update, 200);
9237
9237
  return this;
9238
9238
  },
9239
9239
  update(_tasks2) {
@@ -9243,7 +9243,7 @@ const createListRenderer = (_tasks, options) => {
9243
9243
  },
9244
9244
  async stop() {
9245
9245
  if (timer) {
9246
- clearInterval(timer);
9246
+ safeClearInterval(timer);
9247
9247
  timer = void 0;
9248
9248
  }
9249
9249
  log.clear();
@@ -9342,7 +9342,7 @@ const createDotRenderer = (_tasks, options) => {
9342
9342
  start() {
9343
9343
  if (timer)
9344
9344
  return this;
9345
- timer = setInterval(update, 200);
9345
+ timer = safeSetInterval(update, 200);
9346
9346
  return this;
9347
9347
  },
9348
9348
  update(_tasks2) {
@@ -9352,7 +9352,7 @@ const createDotRenderer = (_tasks, options) => {
9352
9352
  },
9353
9353
  async stop() {
9354
9354
  if (timer) {
9355
- clearInterval(timer);
9355
+ safeClearInterval(timer);
9356
9356
  timer = void 0;
9357
9357
  }
9358
9358
  log.clear();
@@ -9389,7 +9389,7 @@ class DotReporter extends BaseReporter {
9389
9389
  var _a;
9390
9390
  (_a = this.renderer) == null ? void 0 : _a.stop();
9391
9391
  this.renderer = void 0;
9392
- await new Promise((resolve) => setTimeout$1(resolve, 10));
9392
+ await new Promise((resolve) => safeSetTimeout(resolve, 10));
9393
9393
  }
9394
9394
  async onWatcherRerun(files, trigger) {
9395
9395
  await this.stopListRender();
@@ -9578,7 +9578,7 @@ function yamlString(str) {
9578
9578
  return `"${str.replace(/"/g, '\\"')}"`;
9579
9579
  }
9580
9580
  function tapString(str) {
9581
- return str.replace(/#/g, "?").replace(/^[0-9]+/, "?");
9581
+ return str.replace(/\\/g, "\\\\").replace(/#/g, "\\#").replace(/\n/g, " ");
9582
9582
  }
9583
9583
  class TapReporter {
9584
9584
  onInit(ctx) {
@@ -10317,7 +10317,7 @@ class Vitest {
10317
10317
  async setServer(options, server) {
10318
10318
  var _a, _b;
10319
10319
  (_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
10320
- clearTimeout$1(this._rerunTimer);
10320
+ safeClearTimeout(this._rerunTimer);
10321
10321
  this.restartsCount += 1;
10322
10322
  (_b = this.pool) == null ? void 0 : _b.close();
10323
10323
  this.pool = void 0;
@@ -10494,12 +10494,12 @@ class Vitest {
10494
10494
  }
10495
10495
  async scheduleRerun(triggerId) {
10496
10496
  const currentCount = this.restartsCount;
10497
- clearTimeout$1(this._rerunTimer);
10497
+ safeClearTimeout(this._rerunTimer);
10498
10498
  await this.runningPromise;
10499
- clearTimeout$1(this._rerunTimer);
10499
+ safeClearTimeout(this._rerunTimer);
10500
10500
  if (this.restartsCount !== currentCount)
10501
10501
  return;
10502
- this._rerunTimer = setTimeout$1(async () => {
10502
+ this._rerunTimer = safeSetTimeout(async () => {
10503
10503
  if (this.changedTests.size === 0) {
10504
10504
  this.invalidates.clear();
10505
10505
  return;
@@ -10589,7 +10589,7 @@ class Vitest {
10589
10589
  return this.closingPromise;
10590
10590
  }
10591
10591
  async exit(force = false) {
10592
- setTimeout$1(() => {
10592
+ safeSetTimeout(() => {
10593
10593
  console.warn(`close timed out after ${CLOSE_TIMEOUT}ms`);
10594
10594
  process.exit();
10595
10595
  }, CLOSE_TIMEOUT).unref();
@@ -10967,7 +10967,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10967
10967
  await ctx.setServer(options, server);
10968
10968
  haveStarted = true;
10969
10969
  if (options.api && options.watch)
10970
- (await import('./chunk-api-setup.010a6158.js')).setup(ctx);
10970
+ (await import('./chunk-api-setup.2405c167.js')).setup(ctx);
10971
10971
  if (!options.watch)
10972
10972
  await server.watcher.close();
10973
10973
  }
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { k as isAbsolute$2, h as resolve, j as join$2, D as extname$2, d as dirname$2 } from './chunk-utils-global.2529a727.js';
4
+ import { m as isAbsolute$2, l as resolve, j as join$2, I as extname$2, d as dirname$2 } from './chunk-utils-global.eb9e6d32.js';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.2529a727.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.42b0363f.js';
2
+ import { p as picocolors } from './chunk-utils-global.eb9e6d32.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.464ab3dd.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -16,17 +16,17 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.9e9c5c75.js';
19
+ import './chunk-constants.e8bc5d35.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.317f59c6.js';
21
+ import './chunk-vite-node-utils.eec5d968.js';
22
22
  import 'module';
23
23
  import 'vm';
24
24
  import 'debug';
25
- import './chunk-defaults.0fce304d.js';
25
+ import './chunk-defaults.a3120857.js';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
28
  import 'perf_hooks';
29
- import './chunk-utils-timers.b1b3dfa6.js';
29
+ import './chunk-utils-source-map.6b6c39c8.js';
30
30
  import './chunk-magic-string.41232190.js';
31
31
  import './vendor-index.405e58ef.js';
32
32
 
package/dist/entry.js CHANGED
@@ -1,17 +1,17 @@
1
- export { r as run } from './vendor-entry.e4d01a65.js';
1
+ export { r as run } from './vendor-entry.3113977a.js';
2
2
  import 'fs';
3
- import './chunk-utils-global.2529a727.js';
3
+ import './chunk-utils-global.eb9e6d32.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import './chunk-runtime-chain.67ecb3a0.js';
7
+ import './chunk-runtime-chain.d2ed2f76.js';
8
8
  import 'chai';
9
9
  import './vendor-_commonjsHelpers.addc3445.js';
10
- import './chunk-runtime-rpc.5050afd6.js';
11
- import './chunk-utils-timers.b1b3dfa6.js';
10
+ import './chunk-runtime-rpc.d3d38fc1.js';
11
+ import './chunk-utils-source-map.6b6c39c8.js';
12
12
  import './chunk-integrations-spy.bee66426.js';
13
13
  import 'tinyspy';
14
14
  import 'util';
15
- import './chunk-defaults.0fce304d.js';
15
+ import './chunk-defaults.a3120857.js';
16
16
  import 'module';
17
17
  import 'url';
package/dist/index.d.ts CHANGED
@@ -1265,6 +1265,53 @@ declare namespace jestMatcherUtils {
1265
1265
  };
1266
1266
  }
1267
1267
 
1268
+ /**
1269
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1270
+ *
1271
+ * This source code is licensed under the MIT license found in the
1272
+ * LICENSE file in the root directory of this source tree.
1273
+ */
1274
+
1275
+ interface SnapshotReturnOptions {
1276
+ actual: string;
1277
+ count: number;
1278
+ expected?: string;
1279
+ key: string;
1280
+ pass: boolean;
1281
+ }
1282
+ interface SaveStatus {
1283
+ deleted: boolean;
1284
+ saved: boolean;
1285
+ }
1286
+ declare class SnapshotState {
1287
+ testFilePath: string;
1288
+ snapshotPath: string;
1289
+ private _counters;
1290
+ private _dirty;
1291
+ private _updateSnapshot;
1292
+ private _snapshotData;
1293
+ private _initialData;
1294
+ private _inlineSnapshots;
1295
+ private _uncheckedKeys;
1296
+ private _snapshotFormat;
1297
+ added: number;
1298
+ expand: boolean;
1299
+ matched: number;
1300
+ unmatched: number;
1301
+ updated: number;
1302
+ constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1303
+ markSnapshotsAsCheckedForTest(testName: string): void;
1304
+ private _getInlineSnapshotStack;
1305
+ private _addSnapshot;
1306
+ clear(): void;
1307
+ save(): Promise<SaveStatus>;
1308
+ getUncheckedCount(): number;
1309
+ getUncheckedKeys(): Array<string>;
1310
+ removeUncheckedKeys(): void;
1311
+ match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
1312
+ pack(): Promise<SnapshotResult>;
1313
+ }
1314
+
1268
1315
  declare type Tester = (a: any, b: any) => boolean | undefined;
1269
1316
  interface MatcherState {
1270
1317
  assertionCalls: number;
@@ -1279,6 +1326,7 @@ interface MatcherState {
1279
1326
  isExpectingAssertionsError?: Error | null;
1280
1327
  isNot: boolean;
1281
1328
  promise: string;
1329
+ snapshotState: SnapshotState;
1282
1330
  suppressedErrors: Array<Error>;
1283
1331
  testPath?: string;
1284
1332
  utils: typeof jestMatcherUtils & {
@@ -1400,16 +1448,13 @@ declare global {
1400
1448
 
1401
1449
  declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
1402
1450
  declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
1403
- interface BirpcFn<T> {
1404
- /**
1405
- * Call the remote function and wait for the result.
1406
- */
1407
- (...args: ArgumentsType<T>): Promise<Awaited<ReturnType$1<T>>>;
1451
+ declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
1452
+ declare type BirpcFn<T> = PromisifyFn<T> & {
1408
1453
  /**
1409
1454
  * Send event without asking for response
1410
1455
  */
1411
1456
  asEvent(...args: ArgumentsType<T>): void;
1412
- }
1457
+ };
1413
1458
  declare type BirpcReturn<RemoteFunctions> = {
1414
1459
  [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1415
1460
  };
@@ -1530,10 +1575,10 @@ declare const test: TestAPI<{}>;
1530
1575
  declare const describe: SuiteAPI<{}>;
1531
1576
  declare const it: TestAPI<{}>;
1532
1577
 
1533
- declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
1534
- declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undefined) => void;
1535
- declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
1536
- declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
1578
+ declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number) => void;
1579
+ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number) => void;
1580
+ declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number) => void;
1581
+ declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number) => void;
1537
1582
 
1538
1583
  /**
1539
1584
  * A simple wrapper for converting callback style to promise
@@ -1651,6 +1696,12 @@ declare class VitestUtils {
1651
1696
  */
1652
1697
  stubGlobal(name: string | symbol | number, value: any): this;
1653
1698
  resetModules(): this;
1699
+ /**
1700
+ * Wait for all imports to load.
1701
+ * Useful, if you have a synchronous call that starts
1702
+ * importing a module, that you cannot wait otherwise.
1703
+ */
1704
+ dynamicImportSettled(): Promise<void>;
1654
1705
  }
1655
1706
  declare const vitest: VitestUtils;
1656
1707
  declare const vi: VitestUtils;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.67ecb3a0.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.d2ed2f76.js';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.addc3445.js';
4
- import './chunk-runtime-rpc.5050afd6.js';
5
- import './chunk-utils-global.2529a727.js';
4
+ import './chunk-runtime-rpc.d3d38fc1.js';
5
+ import './chunk-utils-global.eb9e6d32.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-timers.b1b3dfa6.js';
10
+ import './chunk-utils-source-map.6b6c39c8.js';
11
11
  import './chunk-integrations-spy.bee66426.js';
12
12
  import 'tinyspy';
13
13
  import 'util';
package/dist/node.d.ts CHANGED
@@ -646,6 +646,14 @@ interface SnapshotStateOptions {
646
646
  snapshotFormat?: OptionsReceived;
647
647
  resolveSnapshotPath?: (path: string, extension: string) => string;
648
648
  }
649
+ interface SnapshotMatchOptions {
650
+ testName: string;
651
+ received: unknown;
652
+ key?: string;
653
+ inlineSnapshot?: string;
654
+ isInline: boolean;
655
+ error?: Error;
656
+ }
649
657
  interface SnapshotResult {
650
658
  filepath: string;
651
659
  added: number;
@@ -1076,6 +1084,53 @@ declare namespace jestMatcherUtils {
1076
1084
  };
1077
1085
  }
1078
1086
 
1087
+ /**
1088
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1089
+ *
1090
+ * This source code is licensed under the MIT license found in the
1091
+ * LICENSE file in the root directory of this source tree.
1092
+ */
1093
+
1094
+ interface SnapshotReturnOptions {
1095
+ actual: string;
1096
+ count: number;
1097
+ expected?: string;
1098
+ key: string;
1099
+ pass: boolean;
1100
+ }
1101
+ interface SaveStatus {
1102
+ deleted: boolean;
1103
+ saved: boolean;
1104
+ }
1105
+ declare class SnapshotState {
1106
+ testFilePath: string;
1107
+ snapshotPath: string;
1108
+ private _counters;
1109
+ private _dirty;
1110
+ private _updateSnapshot;
1111
+ private _snapshotData;
1112
+ private _initialData;
1113
+ private _inlineSnapshots;
1114
+ private _uncheckedKeys;
1115
+ private _snapshotFormat;
1116
+ added: number;
1117
+ expand: boolean;
1118
+ matched: number;
1119
+ unmatched: number;
1120
+ updated: number;
1121
+ constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1122
+ markSnapshotsAsCheckedForTest(testName: string): void;
1123
+ private _getInlineSnapshotStack;
1124
+ private _addSnapshot;
1125
+ clear(): void;
1126
+ save(): Promise<SaveStatus>;
1127
+ getUncheckedCount(): number;
1128
+ getUncheckedKeys(): Array<string>;
1129
+ removeUncheckedKeys(): void;
1130
+ match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
1131
+ pack(): Promise<SnapshotResult>;
1132
+ }
1133
+
1079
1134
  declare type Tester = (a: any, b: any) => boolean | undefined;
1080
1135
  interface MatcherState {
1081
1136
  assertionCalls: number;
@@ -1090,6 +1145,7 @@ interface MatcherState {
1090
1145
  isExpectingAssertionsError?: Error | null;
1091
1146
  isNot: boolean;
1092
1147
  promise: string;
1148
+ snapshotState: SnapshotState;
1093
1149
  suppressedErrors: Array<Error>;
1094
1150
  testPath?: string;
1095
1151
  utils: typeof jestMatcherUtils & {
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.42b0363f.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.f99f69c3.js';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.464ab3dd.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.13651a82.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
@@ -13,20 +13,20 @@ import 'stream';
13
13
  import 'util';
14
14
  import 'url';
15
15
  import 'os';
16
- import './chunk-utils-global.2529a727.js';
16
+ import './chunk-utils-global.eb9e6d32.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'vite';
20
- import './chunk-constants.9e9c5c75.js';
20
+ import './chunk-constants.e8bc5d35.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.317f59c6.js';
22
+ import './chunk-vite-node-utils.eec5d968.js';
23
23
  import 'module';
24
24
  import 'vm';
25
25
  import 'debug';
26
- import './chunk-defaults.0fce304d.js';
26
+ import './chunk-defaults.a3120857.js';
27
27
  import 'worker_threads';
28
28
  import 'tinypool';
29
29
  import 'perf_hooks';
30
- import './chunk-utils-timers.b1b3dfa6.js';
30
+ import './chunk-utils-source-map.6b6c39c8.js';
31
31
  import './chunk-magic-string.41232190.js';
32
32
  import './vendor-index.405e58ef.js';
@@ -1,12 +1,12 @@
1
1
  import { promises } from 'fs';
2
- import { m as isNode, a as getWorkerState, t as toArray, I as clone, G as getType, l as relative, J as partitionSuiteChildren, K as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.2529a727.js';
2
+ import { q as isNode, a as getWorkerState, f as safeClearTimeout, e as safeSetTimeout, t as toArray, N as clone, L as getType, o as relative, O as partitionSuiteChildren, P as hasTests, x as hasFailed, v as getFullName, r as resetModules } from './chunk-utils-global.eb9e6d32.js';
3
3
  import { importModule } from 'local-pkg';
4
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.67ecb3a0.js';
4
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.d2ed2f76.js';
5
5
  import chai, { assert, should, util } from 'chai';
6
- import { r as rpc } from './chunk-runtime-rpc.5050afd6.js';
7
- import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.b1b3dfa6.js';
8
- import { t as takeCoverage } from './chunk-defaults.0fce304d.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.d3d38fc1.js';
7
+ import { t as takeCoverage } from './chunk-defaults.a3120857.js';
9
8
  import { format } from 'util';
9
+ import { s as stringify } from './chunk-utils-source-map.6b6c39c8.js';
10
10
 
11
11
  var index = /*#__PURE__*/Object.freeze({
12
12
  __proto__: null,
@@ -435,7 +435,7 @@ async function setupGlobalEnv(config) {
435
435
  if (isNode)
436
436
  await setupConsoleLogSpy();
437
437
  if (config.globals)
438
- (await import('./chunk-integrations-globals.fda74a73.js')).registerApiGlobally();
438
+ (await import('./chunk-integrations-globals.6e996fa7.js')).registerApiGlobally();
439
439
  }
440
440
  function setupDefines(defines) {
441
441
  for (const key in defines)
@@ -451,8 +451,8 @@ async function setupConsoleLogSpy() {
451
451
  function schedule(taskId) {
452
452
  const timer = timers.get(taskId);
453
453
  const { stdoutTime, stderrTime } = timer;
454
- clearTimeout(timer.timer);
455
- timer.timer = setTimeout(() => {
454
+ safeClearTimeout(timer.timer);
455
+ timer.timer = safeSetTimeout(() => {
456
456
  if (stderrTime < stdoutTime) {
457
457
  sendStderr(taskId);
458
458
  sendStdout(taskId);
@@ -835,13 +835,13 @@ let updateTimer;
835
835
  let previousUpdate;
836
836
  function updateTask(task) {
837
837
  packs.set(task.id, task.result);
838
- clearTimeout(updateTimer);
839
- updateTimer = setTimeout(() => {
838
+ safeClearTimeout(updateTimer);
839
+ updateTimer = safeSetTimeout(() => {
840
840
  previousUpdate = sendTasksUpdate();
841
841
  }, 10);
842
842
  }
843
843
  async function sendTasksUpdate() {
844
- clearTimeout(updateTimer);
844
+ safeClearTimeout(updateTimer);
845
845
  await previousUpdate;
846
846
  if (packs.size) {
847
847
  const p = rpc().onTaskUpdate(Array.from(packs));
package/dist/worker.js CHANGED
@@ -1,8 +1,8 @@
1
- import { h as resolve, a as getWorkerState } from './chunk-utils-global.2529a727.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.317f59c6.js';
3
- import { d as distDir } from './chunk-constants.9e9c5c75.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.f99f69c3.js';
5
- import { r as rpc } from './chunk-runtime-rpc.5050afd6.js';
1
+ import { l as resolve, a as getWorkerState } from './chunk-utils-global.eb9e6d32.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.eec5d968.js';
3
+ import { d as distDir } from './chunk-constants.e8bc5d35.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.13651a82.js';
5
+ import { r as rpc } from './chunk-runtime-rpc.d3d38fc1.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
package/package.json CHANGED
@@ -1,32 +1,29 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.12.9",
4
+ "version": "0.12.10",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/antfu",
9
+ "homepage": "https://github.com/vitest-dev/vitest#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/vitest-dev/vitest.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/vitest-dev/vitest/issues"
16
+ },
6
17
  "keywords": [
7
18
  "vite",
8
19
  "vite-node",
9
20
  "test",
10
21
  "jest"
11
22
  ],
12
- "homepage": "https://github.com/vitest-dev/vitest#readme",
13
- "bugs": {
14
- "url": "https://github.com/vitest-dev/vitest/issues"
15
- },
16
- "license": "MIT",
17
- "author": "Anthony Fu <anthonyfu117@hotmail.com>",
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/vitest-dev/vitest.git"
21
- },
22
- "funding": "https://github.com/sponsors/antfu",
23
- "main": "./dist/index.js",
24
- "module": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
26
23
  "exports": {
27
24
  ".": {
28
- "import": "./dist/index.js",
29
- "types": "./dist/index.d.ts"
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
30
27
  },
31
28
  "./*": "./*",
32
29
  "./globals": {
@@ -36,23 +33,29 @@
36
33
  "types": "./importMeta.d.ts"
37
34
  },
38
35
  "./node": {
39
- "import": "./dist/node.js",
40
- "types": "./dist/node.d.ts"
36
+ "types": "./dist/node.d.ts",
37
+ "import": "./dist/node.js"
41
38
  },
42
39
  "./config": {
40
+ "types": "./config.d.ts",
43
41
  "import": "./dist/config.js",
44
- "require": "./dist/config.cjs",
45
- "types": "./config.d.ts"
42
+ "require": "./dist/config.cjs"
46
43
  }
47
44
  },
45
+ "main": "./dist/index.js",
46
+ "module": "./dist/index.js",
47
+ "types": "./dist/index.d.ts",
48
+ "bin": {
49
+ "vitest": "./vitest.mjs"
50
+ },
48
51
  "files": [
49
52
  "dist",
50
53
  "bin",
51
54
  "*.d.ts",
52
55
  "*.mjs"
53
56
  ],
54
- "bin": {
55
- "vitest": "./vitest.mjs"
57
+ "engines": {
58
+ "node": ">=v14.16.0"
56
59
  },
57
60
  "peerDependencies": {
58
61
  "@vitest/ui": "*",
@@ -82,7 +85,7 @@
82
85
  "local-pkg": "^0.4.1",
83
86
  "tinypool": "^0.1.3",
84
87
  "tinyspy": "^0.3.2",
85
- "vite": "^2.9.8"
88
+ "vite": "^2.9.9"
86
89
  },
87
90
  "devDependencies": {
88
91
  "@antfu/install-pkg": "^0.1.0",
@@ -91,21 +94,21 @@
91
94
  "@types/jsdom": "^16.2.14",
92
95
  "@types/micromatch": "^4.0.2",
93
96
  "@types/natural-compare": "^1.4.1",
94
- "@types/node": "^17.0.33",
97
+ "@types/node": "^17.0.35",
95
98
  "@types/prompts": "^2.4.0",
96
99
  "@types/sinonjs__fake-timers": "^8.1.2",
97
- "@vitest/ui": "0.12.9",
98
- "birpc": "^0.2.2",
99
- "c8": "^7.11.2",
100
+ "@vitest/ui": "0.12.10",
101
+ "birpc": "^0.2.3",
102
+ "c8": "^7.11.3",
100
103
  "cac": "^6.7.12",
101
104
  "chai-subset": "^1.6.0",
102
105
  "cli-truncate": "^3.1.0",
103
- "diff": "^5.0.0",
106
+ "diff": "^5.1.0",
104
107
  "execa": "^6.1.0",
105
108
  "fast-glob": "^3.2.11",
106
109
  "find-up": "^6.3.0",
107
110
  "flatted": "^3.2.5",
108
- "happy-dom": "^3.2.0",
111
+ "happy-dom": "^4.1.0",
109
112
  "jsdom": "^19.0.0",
110
113
  "log-update": "^5.0.1",
111
114
  "magic-string": "^0.26.2",
@@ -117,15 +120,12 @@
117
120
  "pkg-types": "^0.3.2",
118
121
  "pretty-format": "^27.5.1",
119
122
  "prompts": "^2.4.2",
120
- "rollup": "^2.73.0",
123
+ "rollup": "^2.74.1",
121
124
  "source-map-js": "^1.0.2",
122
125
  "strip-ansi": "^7.0.1",
123
- "typescript": "^4.6.4",
124
- "vite-node": "0.12.9",
125
- "ws": "^8.6.0"
126
- },
127
- "engines": {
128
- "node": ">=v14.16.0"
126
+ "typescript": "^4.7.2",
127
+ "vite-node": "0.12.10",
128
+ "ws": "^8.7.0"
129
129
  },
130
130
  "scripts": {
131
131
  "build": "rimraf dist && rollup -c",
@@ -1,7 +0,0 @@
1
- import { a as getWorkerState } from './chunk-utils-global.2529a727.js';
2
-
3
- const rpc = () => {
4
- return getWorkerState().rpc;
5
- };
6
-
7
- export { rpc as r };