vitest 0.12.7 → 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.
Files changed (23) hide show
  1. package/dist/{chunk-api-setup.2f2df7e0.js → chunk-api-setup.2405c167.js} +107 -51
  2. package/dist/{chunk-constants.3570739f.js → chunk-constants.e8bc5d35.js} +1 -1
  3. package/dist/{chunk-defaults.7d81a6ca.js → chunk-defaults.a3120857.js} +1 -1
  4. package/dist/{chunk-install-pkg.fd8d1022.js → chunk-install-pkg.73b84ae1.js} +1 -1
  5. package/dist/{chunk-integrations-globals.36dc71fa.js → chunk-integrations-globals.6e996fa7.js} +7 -7
  6. package/dist/{chunk-runtime-chain.5021a6b6.js → chunk-runtime-chain.d2ed2f76.js} +21 -10
  7. package/dist/{chunk-runtime-mocker.42fa71a8.js → chunk-runtime-mocker.13651a82.js} +4 -4
  8. package/dist/chunk-runtime-rpc.d3d38fc1.js +15 -0
  9. package/dist/{chunk-utils-global.2fab7e5c.js → chunk-utils-global.eb9e6d32.js} +34 -2
  10. package/dist/{chunk-utils-timers.da6ac0a6.js → chunk-utils-source-map.6b6c39c8.js} +14 -11
  11. package/dist/{chunk-vite-node-externalize.0aac0c8e.js → chunk-vite-node-externalize.464ab3dd.js} +36 -27
  12. package/dist/{chunk-vite-node-utils.9975fd9e.js → chunk-vite-node-utils.eec5d968.js} +5 -2
  13. package/dist/cli.js +7 -7
  14. package/dist/entry.js +6 -6
  15. package/dist/index.d.ts +61 -10
  16. package/dist/index.js +4 -4
  17. package/dist/node.d.ts +56 -0
  18. package/dist/node.js +8 -8
  19. package/dist/{vendor-entry.7d6cc1fd.js → vendor-entry.3113977a.js} +17 -14
  20. package/dist/{vendor-index.6c69a0a8.js → vendor-index.40be925a.js} +0 -0
  21. package/dist/worker.js +5 -5
  22. package/package.json +37 -37
  23. package/dist/chunk-runtime-rpc.47bae3f9.js +0 -7
@@ -2,30 +2,30 @@ import { Buffer } from 'buffer';
2
2
  import path$a from 'path';
3
3
  import childProcess from 'child_process';
4
4
  import process$1 from 'process';
5
- import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.6c69a0a8.js';
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, 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, A as ensurePackageInstalled, B as stdout } from './chunk-utils-global.2fab7e5c.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.3570739f.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.9975fd9e.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.7d81a6ca.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.da6ac0a6.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.7";
28
+ var version = "0.12.10";
29
29
 
30
30
  function stripFinalNewline(input) {
31
31
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -8198,9 +8198,12 @@ function createFakePool(ctx) {
8198
8198
  invalidates,
8199
8199
  id: 1
8200
8200
  };
8201
- await worker[name](data, { transferList: [workerPort] });
8202
- port.close();
8203
- workerPort.close();
8201
+ try {
8202
+ await worker[name](data, { transferList: [workerPort] });
8203
+ } finally {
8204
+ port.close();
8205
+ workerPort.close();
8206
+ }
8204
8207
  };
8205
8208
  };
8206
8209
  return {
@@ -8226,7 +8229,7 @@ function createWorkerPool(ctx) {
8226
8229
  return async (files, invalidates) => {
8227
8230
  let id = 0;
8228
8231
  const config = ctx.getSerializableConfig();
8229
- await Promise.all(files.map(async (file) => {
8232
+ const results = await Promise.allSettled(files.map(async (file) => {
8230
8233
  const { workerPort, port } = createChannel(ctx);
8231
8234
  const data = {
8232
8235
  port: workerPort,
@@ -8235,10 +8238,16 @@ function createWorkerPool(ctx) {
8235
8238
  invalidates,
8236
8239
  id: ++id
8237
8240
  };
8238
- await pool.run(data, { transferList: [workerPort], name });
8239
- port.close();
8240
- workerPort.close();
8241
+ try {
8242
+ await pool.run(data, { transferList: [workerPort], name });
8243
+ } finally {
8244
+ port.close();
8245
+ workerPort.close();
8246
+ }
8241
8247
  }));
8248
+ const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
8249
+ if (errors.length > 0)
8250
+ throw new AggregateErrorPonyfill(errors, "Errors occurred while running tests. For more information, see serialized error.");
8242
8251
  };
8243
8252
  };
8244
8253
  return {
@@ -9224,7 +9233,7 @@ const createListRenderer = (_tasks, options) => {
9224
9233
  start() {
9225
9234
  if (timer)
9226
9235
  return this;
9227
- timer = setInterval(update, 200);
9236
+ timer = safeSetInterval(update, 200);
9228
9237
  return this;
9229
9238
  },
9230
9239
  update(_tasks2) {
@@ -9234,7 +9243,7 @@ const createListRenderer = (_tasks, options) => {
9234
9243
  },
9235
9244
  async stop() {
9236
9245
  if (timer) {
9237
- clearInterval(timer);
9246
+ safeClearInterval(timer);
9238
9247
  timer = void 0;
9239
9248
  }
9240
9249
  log.clear();
@@ -9333,7 +9342,7 @@ const createDotRenderer = (_tasks, options) => {
9333
9342
  start() {
9334
9343
  if (timer)
9335
9344
  return this;
9336
- timer = setInterval(update, 200);
9345
+ timer = safeSetInterval(update, 200);
9337
9346
  return this;
9338
9347
  },
9339
9348
  update(_tasks2) {
@@ -9343,7 +9352,7 @@ const createDotRenderer = (_tasks, options) => {
9343
9352
  },
9344
9353
  async stop() {
9345
9354
  if (timer) {
9346
- clearInterval(timer);
9355
+ safeClearInterval(timer);
9347
9356
  timer = void 0;
9348
9357
  }
9349
9358
  log.clear();
@@ -9380,7 +9389,7 @@ class DotReporter extends BaseReporter {
9380
9389
  var _a;
9381
9390
  (_a = this.renderer) == null ? void 0 : _a.stop();
9382
9391
  this.renderer = void 0;
9383
- await new Promise((resolve) => setTimeout$1(resolve, 10));
9392
+ await new Promise((resolve) => safeSetTimeout(resolve, 10));
9384
9393
  }
9385
9394
  async onWatcherRerun(files, trigger) {
9386
9395
  await this.stopListRender();
@@ -9569,7 +9578,7 @@ function yamlString(str) {
9569
9578
  return `"${str.replace(/"/g, '\\"')}"`;
9570
9579
  }
9571
9580
  function tapString(str) {
9572
- return str.replace(/#/g, "?").replace(/^[0-9]+/, "?");
9581
+ return str.replace(/\\/g, "\\\\").replace(/#/g, "\\#").replace(/\n/g, " ");
9573
9582
  }
9574
9583
  class TapReporter {
9575
9584
  onInit(ctx) {
@@ -10029,7 +10038,7 @@ function resolveConfig(options, viteConfig) {
10029
10038
  resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
10030
10039
  if (process.env.VITEST_MIN_THREADS)
10031
10040
  resolved.minThreads = parseInt(process.env.VITEST_MIN_THREADS);
10032
- resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => normalize(resolveModule(file, { paths: [resolved.root] })));
10041
+ resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => normalize(resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)));
10033
10042
  resolved.api = resolveApiConfig(options);
10034
10043
  if (options.related)
10035
10044
  resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
@@ -10308,7 +10317,7 @@ class Vitest {
10308
10317
  async setServer(options, server) {
10309
10318
  var _a, _b;
10310
10319
  (_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
10311
- clearTimeout$1(this._rerunTimer);
10320
+ safeClearTimeout(this._rerunTimer);
10312
10321
  this.restartsCount += 1;
10313
10322
  (_b = this.pool) == null ? void 0 : _b.close();
10314
10323
  this.pool = void 0;
@@ -10485,12 +10494,12 @@ class Vitest {
10485
10494
  }
10486
10495
  async scheduleRerun(triggerId) {
10487
10496
  const currentCount = this.restartsCount;
10488
- clearTimeout$1(this._rerunTimer);
10497
+ safeClearTimeout(this._rerunTimer);
10489
10498
  await this.runningPromise;
10490
- clearTimeout$1(this._rerunTimer);
10499
+ safeClearTimeout(this._rerunTimer);
10491
10500
  if (this.restartsCount !== currentCount)
10492
10501
  return;
10493
- this._rerunTimer = setTimeout$1(async () => {
10502
+ this._rerunTimer = safeSetTimeout(async () => {
10494
10503
  if (this.changedTests.size === 0) {
10495
10504
  this.invalidates.clear();
10496
10505
  return;
@@ -10580,7 +10589,7 @@ class Vitest {
10580
10589
  return this.closingPromise;
10581
10590
  }
10582
10591
  async exit(force = false) {
10583
- setTimeout$1(() => {
10592
+ safeSetTimeout(() => {
10584
10593
  console.warn(`close timed out after ${CLOSE_TIMEOUT}ms`);
10585
10594
  process.exit();
10586
10595
  }, CLOSE_TIMEOUT).unref();
@@ -10958,7 +10967,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10958
10967
  await ctx.setServer(options, server);
10959
10968
  haveStarted = true;
10960
10969
  if (options.api && options.watch)
10961
- (await import('./chunk-api-setup.2f2df7e0.js')).setup(ctx);
10970
+ (await import('./chunk-api-setup.2405c167.js')).setup(ctx);
10962
10971
  if (!options.watch)
10963
10972
  await server.watcher.close();
10964
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, C as extname$2, d as dirname$2 } from './chunk-utils-global.2fab7e5c.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';
@@ -8845,6 +8845,9 @@ const isWindows = process.platform === "win32";
8845
8845
  function slash(str) {
8846
8846
  return str.replace(/\\/g, "/");
8847
8847
  }
8848
+ function mergeSlashes(str) {
8849
+ return str.replace(/\/\//g, "/");
8850
+ }
8848
8851
  function normalizeRequestId(id, base) {
8849
8852
  if (base && id.startsWith(base))
8850
8853
  id = `/${id.slice(base.length)}`;
@@ -8979,7 +8982,7 @@ ${getStack()}`), 2e3);
8979
8982
  if (importer && importer.startsWith("mock:"))
8980
8983
  importer = importer.slice(5);
8981
8984
  const { id: id2 } = await this.options.resolveId(dep, importer) || {};
8982
- dep = id2 && isAbsolute$2(id2) ? `/@fs/${id2}` : id2 || dep;
8985
+ dep = id2 && isAbsolute$2(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
8983
8986
  }
8984
8987
  return dep;
8985
8988
  };
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.2fab7e5c.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.0aac0c8e.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';
7
7
  import 'buffer';
8
8
  import 'child_process';
9
9
  import 'process';
10
- import './vendor-index.6c69a0a8.js';
10
+ import './vendor-index.40be925a.js';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import 'fs';
13
13
  import 'assert';
@@ -16,17 +16,17 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.3570739f.js';
19
+ import './chunk-constants.e8bc5d35.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.9975fd9e.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.7d81a6ca.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.da6ac0a6.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.7d6cc1fd.js';
1
+ export { r as run } from './vendor-entry.3113977a.js';
2
2
  import 'fs';
3
- import './chunk-utils-global.2fab7e5c.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.5021a6b6.js';
7
+ import './chunk-runtime-chain.d2ed2f76.js';
8
8
  import 'chai';
9
9
  import './vendor-_commonjsHelpers.addc3445.js';
10
- import './chunk-runtime-rpc.47bae3f9.js';
11
- import './chunk-utils-timers.da6ac0a6.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.7d81a6ca.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.5021a6b6.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.47bae3f9.js';
5
- import './chunk-utils-global.2fab7e5c.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.da6ac0a6.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,10 +1,10 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.0aac0c8e.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.42fa71a8.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';
6
6
  import 'process';
7
- import './vendor-index.6c69a0a8.js';
7
+ import './vendor-index.40be925a.js';
8
8
  import './vendor-_commonjsHelpers.addc3445.js';
9
9
  import 'fs';
10
10
  import 'assert';
@@ -13,20 +13,20 @@ import 'stream';
13
13
  import 'util';
14
14
  import 'url';
15
15
  import 'os';
16
- import './chunk-utils-global.2fab7e5c.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.3570739f.js';
20
+ import './chunk-constants.e8bc5d35.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.9975fd9e.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.7d81a6ca.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.da6ac0a6.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, H as clone, F as getType, l as relative, I as partitionSuiteChildren, J as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.2fab7e5c.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.5021a6b6.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.47bae3f9.js';
7
- import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.da6ac0a6.js';
8
- import { t as takeCoverage } from './chunk-defaults.7d81a6ca.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,
@@ -281,19 +281,22 @@ function getWindowKeys(global, win) {
281
281
  }));
282
282
  return keys;
283
283
  }
284
+ function isClassLikeName(name) {
285
+ return name[0] === name[0].toUpperCase();
286
+ }
284
287
  function populateGlobal(global, win, options = {}) {
285
288
  const { bindFunctions = false } = options;
286
289
  const keys = getWindowKeys(global, win);
287
290
  const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
288
291
  const overrideObject = /* @__PURE__ */ new Map();
289
292
  for (const key of keys) {
290
- const bindedFunction = bindFunctions && typeof win[key] === "function" && win[key].bind(win);
293
+ const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
291
294
  Object.defineProperty(global, key, {
292
295
  get() {
293
296
  if (overrideObject.has(key))
294
297
  return overrideObject.get(key);
295
- if (bindedFunction)
296
- return bindedFunction;
298
+ if (boundFunction)
299
+ return boundFunction;
297
300
  return win[key];
298
301
  },
299
302
  set(v) {
@@ -432,7 +435,7 @@ async function setupGlobalEnv(config) {
432
435
  if (isNode)
433
436
  await setupConsoleLogSpy();
434
437
  if (config.globals)
435
- (await import('./chunk-integrations-globals.36dc71fa.js')).registerApiGlobally();
438
+ (await import('./chunk-integrations-globals.6e996fa7.js')).registerApiGlobally();
436
439
  }
437
440
  function setupDefines(defines) {
438
441
  for (const key in defines)
@@ -448,8 +451,8 @@ async function setupConsoleLogSpy() {
448
451
  function schedule(taskId) {
449
452
  const timer = timers.get(taskId);
450
453
  const { stdoutTime, stderrTime } = timer;
451
- clearTimeout(timer.timer);
452
- timer.timer = setTimeout(() => {
454
+ safeClearTimeout(timer.timer);
455
+ timer.timer = safeSetTimeout(() => {
453
456
  if (stderrTime < stdoutTime) {
454
457
  sendStderr(taskId);
455
458
  sendStdout(taskId);
@@ -832,13 +835,13 @@ let updateTimer;
832
835
  let previousUpdate;
833
836
  function updateTask(task) {
834
837
  packs.set(task.id, task.result);
835
- clearTimeout(updateTimer);
836
- updateTimer = setTimeout(() => {
838
+ safeClearTimeout(updateTimer);
839
+ updateTimer = safeSetTimeout(() => {
837
840
  previousUpdate = sendTasksUpdate();
838
841
  }, 10);
839
842
  }
840
843
  async function sendTasksUpdate() {
841
- clearTimeout(updateTimer);
844
+ safeClearTimeout(updateTimer);
842
845
  await previousUpdate;
843
846
  if (packs.size) {
844
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.2fab7e5c.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.9975fd9e.js';
3
- import { d as distDir } from './chunk-constants.3570739f.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.42fa71a8.js';
5
- import { r as rpc } from './chunk-runtime-rpc.47bae3f9.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';