vitest 0.15.1 → 0.15.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.
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.c0a0e1b3.mjs';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.1bbdb2c1.mjs';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -1,12 +1,12 @@
1
1
  import { g as globalApis } from './chunk-constants.7b9cfc82.mjs';
2
- import { i as index } from './vendor-entry.7ec02ea2.mjs';
2
+ import { i as index } from './vendor-entry.efeeaa5c.mjs';
3
3
  import 'url';
4
4
  import './chunk-utils-global.79a8b1cc.mjs';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
- import './chunk-runtime-chain.ce7f4b92.mjs';
9
+ import './chunk-runtime-chain.7103058b.mjs';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
12
  import './chunk-runtime-rpc.5e78af38.mjs';
@@ -737,7 +737,7 @@ class SnapshotState {
737
737
  this._uncheckedKeys.delete(uncheckedKey);
738
738
  });
739
739
  }
740
- _getInlineSnapshotStack(stacks) {
740
+ _inferInlineSnapshotStack(stacks) {
741
741
  const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
742
742
  if (promiseIndex !== -1)
743
743
  return stacks[promiseIndex + 3];
@@ -750,11 +750,12 @@ class SnapshotState {
750
750
  const error = options.error || new Error("Unknown error");
751
751
  const stacks = parseStacktrace(error, true);
752
752
  stacks.forEach((i) => i.file = slash(i.file));
753
- const stack = this._getInlineSnapshotStack(stacks);
753
+ const stack = this._inferInlineSnapshotStack(stacks);
754
754
  if (!stack) {
755
755
  throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
756
756
  ${JSON.stringify(stacks)}`);
757
757
  }
758
+ stack.column--;
758
759
  this._inlineSnapshots.push(__spreadValues$3({
759
760
  snapshot: receivedSerialized
760
761
  }, stack));
@@ -921,6 +922,10 @@ class SnapshotClient {
921
922
  clearTest() {
922
923
  this.test = void 0;
923
924
  }
925
+ skipTestSnapshots(test) {
926
+ var _a;
927
+ (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(test.name);
928
+ }
924
929
  assert(options) {
925
930
  const {
926
931
  test = this.test,
@@ -1854,7 +1859,9 @@ function createExpect(test) {
1854
1859
  }
1855
1860
  const globalExpect = createExpect();
1856
1861
  Object.defineProperty(globalThis, GLOBAL_EXPECT, {
1857
- value: globalExpect
1862
+ value: globalExpect,
1863
+ writable: true,
1864
+ configurable: true
1858
1865
  });
1859
1866
 
1860
1867
  const collectorContext = {
@@ -1,4 +1,4 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.c0a0e1b3.mjs';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.1bbdb2c1.mjs';
2
2
  import { normalizePath } from 'vite';
3
3
  import { a as getWorkerState, J as isWindows, K as mergeSlashes, d as dirname, m as resolve, l as basename, L as getType, M as getAllProperties, s as slash } from './chunk-utils-global.79a8b1cc.mjs';
4
4
  import { existsSync, readdirSync } from 'fs';
@@ -12,7 +12,7 @@ import require$$0$1 from 'util';
12
12
  import require$$0$2 from 'stream';
13
13
  import require$$2 from 'events';
14
14
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
15
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.c0a0e1b3.mjs';
15
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.1bbdb2c1.mjs';
16
16
  import createDebug from 'debug';
17
17
  import { MessageChannel } from 'worker_threads';
18
18
  import { createHash } from 'crypto';
@@ -26,7 +26,7 @@ import childProcess from 'child_process';
26
26
  import MagicString from './chunk-magic-string.efe26975.mjs';
27
27
  import { p as prompts } from './vendor-index.98e769c1.mjs';
28
28
 
29
- var version = "0.15.1";
29
+ var version = "0.15.2";
30
30
 
31
31
  class EndError extends Error {
32
32
  constructor(value) {
@@ -6866,7 +6866,8 @@ class ViteNodeServer {
6866
6866
  async resolveId(id, importer) {
6867
6867
  if (importer && !importer.startsWith(this.server.config.root))
6868
6868
  importer = join(this.server.config.root, importer);
6869
- return this.server.pluginContainer.resolveId(id, importer, { ssr: true });
6869
+ const mode = importer && this.getTransformMode(importer) || "ssr";
6870
+ return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
6870
6871
  }
6871
6872
  async fetchModule(id) {
6872
6873
  if (!this.fetchPromiseMap.has(id)) {
@@ -7045,8 +7046,7 @@ function createPool(ctx) {
7045
7046
  const pool = new Tinypool(options);
7046
7047
  const runWithFiles = (name) => {
7047
7048
  let id = 0;
7048
- const config = ctx.getSerializableConfig();
7049
- async function runFiles(files, invalidates = []) {
7049
+ async function runFiles(config, files, invalidates = []) {
7050
7050
  const { workerPort, port } = createChannel(ctx);
7051
7051
  const workerId = ++id;
7052
7052
  const data = {
@@ -7065,6 +7065,7 @@ function createPool(ctx) {
7065
7065
  }
7066
7066
  }
7067
7067
  return async (files, invalidates) => {
7068
+ const config = ctx.getSerializableConfig();
7068
7069
  if (config.shard) {
7069
7070
  const { index, count } = config.shard;
7070
7071
  const shardSize = Math.ceil(files.length / count);
@@ -7080,9 +7081,9 @@ function createPool(ctx) {
7080
7081
  }).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ file }) => file);
7081
7082
  }
7082
7083
  if (!ctx.config.threads) {
7083
- await runFiles(files);
7084
+ await runFiles(config, files);
7084
7085
  } else {
7085
- const results = await Promise.allSettled(files.map((file) => runFiles([file], invalidates)));
7086
+ const results = await Promise.allSettled(files.map((file) => runFiles(config, [file], invalidates)));
7086
7087
  const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
7087
7088
  if (errors.length > 0)
7088
7089
  throw new AggregateErrorPonyfill(errors, "Errors occurred while running tests. For more information, see serialized error.");
@@ -10936,7 +10937,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10936
10937
  await ctx.setServer(options, server);
10937
10938
  haveStarted = true;
10938
10939
  if (options.api && options.watch)
10939
- (await import('./chunk-api-setup.ff687d0e.mjs')).setup(ctx);
10940
+ (await import('./chunk-api-setup.8cd5e92a.mjs')).setup(ctx);
10940
10941
  } catch (err) {
10941
10942
  ctx.printError(err, true);
10942
10943
  process.exit(1);
@@ -8727,7 +8727,7 @@ function moduleResolve(specifier, base, conditions) {
8727
8727
  const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
8728
8728
  const DEFAULT_URL = pathToFileURL(process.cwd());
8729
8729
  const DEFAULT_EXTENSIONS = [".mjs", ".cjs", ".js", ".json"];
8730
- const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND"]);
8730
+ const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND", "ERR_PACKAGE_PATH_NOT_EXPORTED"]);
8731
8731
  function _tryModuleResolve(id, url, conditions) {
8732
8732
  try {
8733
8733
  return moduleResolve(id, url, conditions);
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { p as picocolors } from './chunk-utils-global.79a8b1cc.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.105bc106.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.0ec89ad1.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -16,7 +16,7 @@ import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-utils.c0a0e1b3.mjs';
19
+ import './chunk-vite-node-utils.1bbdb2c1.mjs';
20
20
  import 'vm';
21
21
  import 'assert';
22
22
  import 'debug';
package/dist/entry.mjs CHANGED
@@ -1,10 +1,10 @@
1
- export { r as run } from './vendor-entry.7ec02ea2.mjs';
1
+ export { r as run } from './vendor-entry.efeeaa5c.mjs';
2
2
  import 'fs';
3
3
  import './chunk-utils-global.79a8b1cc.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import './chunk-runtime-chain.ce7f4b92.mjs';
7
+ import './chunk-runtime-chain.7103058b.mjs';
8
8
  import 'chai';
9
9
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
10
10
  import './chunk-runtime-rpc.5e78af38.mjs';
package/dist/index.d.ts CHANGED
@@ -1339,7 +1339,7 @@ declare class SnapshotState {
1339
1339
  updated: number;
1340
1340
  constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1341
1341
  markSnapshotsAsCheckedForTest(testName: string): void;
1342
- private _getInlineSnapshotStack;
1342
+ private _inferInlineSnapshotStack;
1343
1343
  private _addSnapshot;
1344
1344
  clear(): void;
1345
1345
  save(): Promise<SaveStatus>;
@@ -1583,10 +1583,10 @@ interface SpyInstanceFn<TArgs extends any[] = any, TReturns = any> extends SpyIn
1583
1583
  new (...args: TArgs): TReturns;
1584
1584
  }
1585
1585
  declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? SpyInstanceFn<ConstructorParameters<T>, R> : T;
1586
- declare type MockedFunction<T extends Procedure> = MockWithArgs<T> & {
1586
+ declare type MockedFunction<T extends Procedure> = SpyInstanceFn<Parameters<T>, ReturnType<T>> & {
1587
1587
  [K in keyof T]: T[K];
1588
1588
  };
1589
- declare type MockedFunctionDeep<T extends Procedure> = MockWithArgs<T> & MockedObjectDeep<T>;
1589
+ declare type MockedFunctionDeep<T extends Procedure> = SpyInstanceFn<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
1590
1590
  declare type MockedObject<T> = MaybeMockedConstructor<T> & {
1591
1591
  [K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
1592
1592
  } & {
@@ -1600,10 +1600,6 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
1600
1600
  declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
1601
1601
  declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
1602
1602
  declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
1603
- interface MockWithArgs<T extends Procedure> extends SpyInstanceFn<Parameters<T>, ReturnType<T>> {
1604
- new (...args: T extends new (...args: any) => any ? ConstructorParameters<T> : never): T;
1605
- (...args: Parameters<T>): ReturnType<T>;
1606
- }
1607
1603
  declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
1608
1604
  declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
1609
1605
  declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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.ce7f4b92.mjs';
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.7103058b.mjs';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
4
4
  import './chunk-runtime-rpc.5e78af38.mjs';
package/dist/node.d.ts CHANGED
@@ -1158,7 +1158,7 @@ declare class SnapshotState {
1158
1158
  updated: number;
1159
1159
  constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1160
1160
  markSnapshotsAsCheckedForTest(testName: string): void;
1161
- private _getInlineSnapshotStack;
1161
+ private _inferInlineSnapshotStack;
1162
1162
  private _addSnapshot;
1163
1163
  clear(): void;
1164
1164
  save(): Promise<SaveStatus>;
package/dist/node.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.105bc106.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.2f3cbfe5.mjs';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.0ec89ad1.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.d3ca0a4e.mjs';
3
3
  import './chunk-utils-global.79a8b1cc.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
@@ -17,7 +17,7 @@ import 'util';
17
17
  import 'stream';
18
18
  import 'events';
19
19
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
20
- import './chunk-vite-node-utils.c0a0e1b3.mjs';
20
+ import './chunk-vite-node-utils.1bbdb2c1.mjs';
21
21
  import 'vm';
22
22
  import 'assert';
23
23
  import 'debug';
@@ -1,7 +1,7 @@
1
1
  import { promises } from 'fs';
2
2
  import { t as isNode, a as getWorkerState, h as safeClearTimeout, f as safeSetTimeout, C as toArray, N as deepClone, L as getType, q as relative, O as partitionSuiteChildren, P as hasTests, v as hasFailed, e as getFullName, r as resetModules } from './chunk-utils-global.79a8b1cc.mjs';
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 globalExpect, 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, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.ce7f4b92.mjs';
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 globalExpect, 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, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.7103058b.mjs';
5
5
  import chai, { assert, should, util } from 'chai';
6
6
  import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
7
7
  import { t as takeCoverage, p as pLimit } from './chunk-defaults.dc6dc23d.mjs';
@@ -438,7 +438,7 @@ async function setupGlobalEnv(config) {
438
438
  if (isNode)
439
439
  await setupConsoleLogSpy();
440
440
  if (config.globals)
441
- (await import('./chunk-integrations-globals.df0878f4.mjs')).registerApiGlobally();
441
+ (await import('./chunk-integrations-globals.d0c363a6.mjs')).registerApiGlobally();
442
442
  }
443
443
  function setupDefines(defines) {
444
444
  for (const key in defines)
@@ -858,8 +858,10 @@ async function sendTasksUpdate() {
858
858
  }
859
859
  async function runTest(test) {
860
860
  var _a, _b;
861
- if (test.mode !== "run")
861
+ if (test.mode !== "run") {
862
+ getSnapshotClient().skipTestSnapshots(test);
862
863
  return;
864
+ }
863
865
  if (((_a = test.result) == null ? void 0 : _a.state) === "fail") {
864
866
  updateTask(test);
865
867
  return;
package/dist/worker.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { m as resolve, a as getWorkerState } from './chunk-utils-global.79a8b1cc.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.c0a0e1b3.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1bbdb2c1.mjs';
3
3
  import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.2f3cbfe5.mjs';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.d3ca0a4e.mjs';
5
5
  import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
6
6
  import 'tty';
7
7
  import 'local-pkg';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -84,7 +84,7 @@
84
84
  "debug": "^4.3.4",
85
85
  "local-pkg": "^0.4.1",
86
86
  "tinypool": "^0.1.3",
87
- "tinyspy": "^0.3.2",
87
+ "tinyspy": "^0.3.3",
88
88
  "vite": "^2.9.12"
89
89
  },
90
90
  "devDependencies": {
@@ -96,7 +96,7 @@
96
96
  "@types/natural-compare": "^1.4.1",
97
97
  "@types/prompts": "^2.4.0",
98
98
  "@types/sinonjs__fake-timers": "^8.1.2",
99
- "@vitest/ui": "0.15.1",
99
+ "@vitest/ui": "0.15.2",
100
100
  "birpc": "^0.2.3",
101
101
  "c8": "^7.11.3",
102
102
  "cac": "^6.7.12",
@@ -112,19 +112,19 @@
112
112
  "log-update": "^5.0.1",
113
113
  "magic-string": "^0.26.2",
114
114
  "micromatch": "^4.0.5",
115
- "mlly": "^0.5.2",
115
+ "mlly": "^0.5.3",
116
116
  "natural-compare": "^1.4.0",
117
117
  "p-limit": "^4.0.0",
118
118
  "pathe": "^0.2.0",
119
119
  "picocolors": "^1.0.0",
120
- "pkg-types": "^0.3.2",
120
+ "pkg-types": "^0.3.3",
121
121
  "pretty-format": "^27.5.1",
122
122
  "prompts": "^2.4.2",
123
- "rollup": "^2.75.6",
123
+ "rollup": "^2.75.7",
124
124
  "source-map-js": "^1.0.2",
125
125
  "strip-ansi": "^7.0.1",
126
- "typescript": "^4.7.3",
127
- "vite-node": "0.15.1",
126
+ "typescript": "^4.7.4",
127
+ "vite-node": "0.15.2",
128
128
  "ws": "^8.8.0"
129
129
  },
130
130
  "scripts": {