vitest 0.0.120 → 0.0.124

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,11 +1,11 @@
1
- import { g as globalApis } from './constants-22bbd600.js';
2
- import { i as index } from './index-ea959009.js';
1
+ import { g as globalApis } from './constants-8b3a9b31.js';
2
+ import { i as index } from './index-7f52a6d6.js';
3
3
  import 'url';
4
- import './index-090545ef.js';
4
+ import './index-9fdde2e8.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './vi-67a5a3b3.js';
8
+ import './vi-56df0b20.js';
9
9
  import './_commonjsHelpers-c9e3b764.js';
10
10
  import './jest-mock-038a01b3.js';
11
11
  import 'chai';
@@ -1,4 +1,4 @@
1
- import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-090545ef.js';
1
+ import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1, e as ensurePackageInstalled } from './index-9fdde2e8.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
@@ -7,10 +7,10 @@ import require$$0 from 'os';
7
7
  import require$$0$1 from 'util';
8
8
  import require$$0$2 from 'stream';
9
9
  import require$$2 from 'events';
10
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-22bbd600.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-8b3a9b31.js';
11
11
  import MagicString from './magic-string.es-94000aea.js';
12
12
  import { performance } from 'perf_hooks';
13
- import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-a295cb37.js';
13
+ import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-aeba6bd6.js';
14
14
  import { o as onetime, s as signalExit } from './index-648e7ab2.js';
15
15
  import { createRequire } from 'module';
16
16
  import { pathToFileURL } from 'url';
@@ -6840,7 +6840,7 @@ const MocksPlugin = () => {
6840
6840
  if (m) {
6841
6841
  return {
6842
6842
  code: m.toString(),
6843
- map: m.generateMap()
6843
+ map: m.generateMap({ hires: true })
6844
6844
  };
6845
6845
  }
6846
6846
  }
@@ -7058,9 +7058,9 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
7058
7058
  await this.printTaskErrors(failedTests, errorDivider);
7059
7059
  }
7060
7060
  const executionTime = this.end - this.start;
7061
- const threadTime = tests.reduce((acc, test) => {
7061
+ const threadTime = files.reduce((acc, test) => {
7062
7062
  var _a;
7063
- return acc + (((_a = test.result) == null ? void 0 : _a.end) ? test.result.end - test.result.start : 0);
7063
+ return acc + (((_a = test.result) == null ? void 0 : _a.duration) || 0) + (test.collectDuration || 0);
7064
7064
  }, 0);
7065
7065
  const padTitle = (str) => c.dim(`${str.padStart(10)} `);
7066
7066
  const time = (time2) => {
@@ -7618,10 +7618,9 @@ function renderTree(tasks, options, level = 0) {
7618
7618
  suffix += c.dim(` (${getTests(task).length})`);
7619
7619
  if (task.mode === "skip" || task.mode === "todo")
7620
7620
  suffix += ` ${c.dim(c.gray("[skipped]"))}`;
7621
- if ((_a = task.result) == null ? void 0 : _a.end) {
7622
- const duration = task.result.end - task.result.start;
7623
- if (duration > DURATION_LONG)
7624
- suffix += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
7621
+ if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
7622
+ if (task.result.duration > DURATION_LONG)
7623
+ suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
7625
7624
  }
7626
7625
  let name = task.name;
7627
7626
  if (level === 0)
@@ -7946,7 +7945,7 @@ var __spreadValues = (a, b) => {
7946
7945
  };
7947
7946
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7948
7947
  function resolveConfig(options, viteConfig) {
7949
- var _a, _b;
7948
+ var _a, _b, _c, _d;
7950
7949
  if (options.dom)
7951
7950
  options.environment = "happy-dom";
7952
7951
  const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
@@ -7955,9 +7954,10 @@ function resolveConfig(options, viteConfig) {
7955
7954
  resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
7956
7955
  resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
7957
7956
  resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
7957
+ resolved.fallbackCJS = ((_c = resolved.deps) == null ? void 0 : _c.fallbackCJS) ?? true;
7958
+ resolved.interpretDefault = ((_d = resolved.deps) == null ? void 0 : _d.interpretDefault) ?? true;
7958
7959
  resolved.environment = resolved.environment || "node";
7959
7960
  resolved.threads = resolved.threads ?? true;
7960
- resolved.interpretDefault = resolved.interpretDefault ?? true;
7961
7961
  resolved.clearMocks = resolved.clearMocks ?? false;
7962
7962
  resolved.restoreMocks = resolved.restoreMocks ?? false;
7963
7963
  resolved.mockReset = resolved.mockReset ?? false;
@@ -7980,6 +7980,8 @@ function resolveConfig(options, viteConfig) {
7980
7980
  resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
7981
7981
  if (resolved.api === true)
7982
7982
  resolved.api = defaultPort;
7983
+ if (options.findRelatedTests)
7984
+ resolved.findRelatedTests = toArray(options.findRelatedTests).map((file) => resolve(resolved.root, file));
7983
7985
  return resolved;
7984
7986
  }
7985
7987
 
@@ -8343,6 +8345,12 @@ async function createVitest(options, viteOverrides = {}) {
8343
8345
  const root = resolve(options.root || process.cwd());
8344
8346
  const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
8345
8347
  let haveStarted = false;
8348
+ async function UIPlugin() {
8349
+ if (!options.open)
8350
+ return;
8351
+ await ensurePackageInstalled("@vitest/ui");
8352
+ return (await import('@vitest/ui')).default();
8353
+ }
8346
8354
  const config = {
8347
8355
  root,
8348
8356
  logLevel: "error",
@@ -8357,29 +8365,26 @@ async function createVitest(options, viteOverrides = {}) {
8357
8365
  await ctx.setServer(options, server2);
8358
8366
  haveStarted = true;
8359
8367
  if (options.api)
8360
- (await import('./setup-c9c7cb5b.js')).setup(ctx);
8368
+ (await import('./setup-e485f26d.js')).setup(ctx);
8361
8369
  }
8362
8370
  },
8363
- MocksPlugin()
8371
+ MocksPlugin(),
8372
+ await UIPlugin()
8364
8373
  ],
8365
8374
  server: {
8366
- open: options.open,
8367
- strictPort: true
8375
+ open: options.open ? "/__vitest__/" : void 0,
8376
+ strictPort: true,
8377
+ preTransformRequests: false
8368
8378
  },
8369
8379
  build: {
8370
8380
  sourcemap: true
8371
- },
8372
- optimizeDeps: {
8373
- exclude: [
8374
- "vitest"
8375
- ]
8376
8381
  }
8377
8382
  };
8378
8383
  const server = await createServer(mergeConfig(config, viteOverrides));
8379
8384
  await server.pluginContainer.buildStart({});
8380
8385
  if (options.api === true)
8381
8386
  options.api = defaultPort;
8382
- if (options.open && !options.api)
8387
+ if (options.open && typeof options.api !== "number")
8383
8388
  options.api = defaultPort;
8384
8389
  if (typeof options.api === "number")
8385
8390
  await server.listen(options.api);
@@ -1,4 +1,4 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-67a5a3b3.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-56df0b20.js';
2
2
  import chai, { assert, should } from 'chai';
3
3
  import { s as spies, a as spyOn, f as fn } from './jest-mock-038a01b3.js';
4
4
 
@@ -249,13 +249,6 @@ const index = {
249
249
  ..._path
250
250
  };
251
251
 
252
- const isWindows = process.platform === "win32";
253
- function toArray(array) {
254
- array = array || [];
255
- if (Array.isArray(array))
256
- return array;
257
- return [array];
258
- }
259
252
  function notNullish(v) {
260
253
  return v != null;
261
254
  }
@@ -267,32 +260,20 @@ function mergeSlashes(str) {
267
260
  }
268
261
  const noop = () => {
269
262
  };
270
- function partitionSuiteChildren(suite) {
271
- let tasksGroup = [];
272
- const tasksGroups = [];
273
- for (const c2 of suite.tasks) {
274
- if (tasksGroup.length === 0 || c2.computeMode === tasksGroup[0].computeMode) {
275
- tasksGroup.push(c2);
276
- } else {
277
- tasksGroups.push(tasksGroup);
278
- tasksGroup = [c2];
279
- }
280
- }
281
- if (tasksGroup.length > 0)
282
- tasksGroups.push(tasksGroup);
283
- return tasksGroups;
263
+ function toArray(array) {
264
+ array = array || [];
265
+ if (Array.isArray(array))
266
+ return array;
267
+ return [array];
284
268
  }
285
269
  function getTests(suite) {
286
- return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
287
- }
288
- function getTasks(tasks) {
289
- return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
270
+ return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
290
271
  }
291
272
  function getSuites(suite) {
292
273
  return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
293
274
  }
294
275
  function hasTests(suite) {
295
- return toArray(suite).some((s) => s.tasks.some((c2) => c2.type === "test" || hasTests(c2)));
276
+ return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
296
277
  }
297
278
  function hasFailed(suite) {
298
279
  return toArray(suite).some((s) => {
@@ -310,6 +291,23 @@ function getNames(task) {
310
291
  }
311
292
  return names;
312
293
  }
294
+
295
+ const isWindows = process.platform === "win32";
296
+ function partitionSuiteChildren(suite) {
297
+ let tasksGroup = [];
298
+ const tasksGroups = [];
299
+ for (const c2 of suite.tasks) {
300
+ if (tasksGroup.length === 0 || c2.concurrent === tasksGroup[0].concurrent) {
301
+ tasksGroup.push(c2);
302
+ } else {
303
+ tasksGroups.push(tasksGroup);
304
+ tasksGroup = [c2];
305
+ }
306
+ }
307
+ if (tasksGroup.length > 0)
308
+ tasksGroups.push(tasksGroup);
309
+ return tasksGroups;
310
+ }
313
311
  function getFullName(task) {
314
312
  return getNames(task).join(c.dim(" > "));
315
313
  }
@@ -365,4 +363,4 @@ function toFilePath(id, root) {
365
363
  return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
366
364
  }
367
365
 
368
- export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x, isWindows as y, getTasks as z };
366
+ export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { OptionsReceived, Plugin } from 'pretty-format';
1
2
  import { Formatter } from 'picocolors/types';
2
3
  import { ViteDevServer } from 'vite';
3
4
  import { RawSourceMap } from 'source-map-js';
4
- import { OptionsReceived } from 'pretty-format';
5
5
  import { MessagePort } from 'worker_threads';
6
+ import { SpyImpl } from 'tinyspy';
6
7
  export { Spy, SpyFn } from 'tinyspy';
7
8
  export { assert, default as chai, should } from 'chai';
8
9
 
@@ -85,9 +86,9 @@ declare type MatcherState = {
85
86
  equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
86
87
  expand?: boolean;
87
88
  expectedAssertionsNumber?: number | null;
88
- expectedAssertionsNumberError?: Error;
89
+ expectedAssertionsNumberError?: Error | null;
89
90
  isExpectingAssertions?: boolean;
90
- isExpectingAssertionsError?: Error;
91
+ isExpectingAssertionsError?: Error | null;
91
92
  isNot: boolean;
92
93
  promise: string;
93
94
  suppressedErrors: Array<Error>;
@@ -378,20 +379,18 @@ declare type ChainableFunction<T extends string, Args extends any[], R = any> =
378
379
 
379
380
  declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
380
381
  declare type TaskState = RunMode | 'pass' | 'fail';
381
- declare type ComputeMode = 'serial' | 'concurrent';
382
382
  interface TaskBase {
383
383
  id: string;
384
384
  name: string;
385
385
  mode: RunMode;
386
- computeMode: ComputeMode;
386
+ concurrent?: boolean;
387
387
  suite?: Suite;
388
388
  file?: File;
389
389
  result?: TaskResult;
390
390
  }
391
391
  interface TaskResult {
392
392
  state: TaskState;
393
- start: number;
394
- end?: number;
393
+ duration?: number;
395
394
  error?: unknown;
396
395
  }
397
396
  declare type TaskResultPack = [id: string, result: TaskResult | undefined];
@@ -401,6 +400,7 @@ interface Suite extends TaskBase {
401
400
  }
402
401
  interface File extends Suite {
403
402
  filepath: string;
403
+ collectDuration?: number;
404
404
  }
405
405
  interface Test extends TaskBase {
406
406
  type: 'test';
@@ -528,6 +528,20 @@ interface InlineConfig {
528
528
  * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
529
529
  */
530
530
  inline?: (string | RegExp)[];
531
+ /**
532
+ * Interpret CJS module's default as named exports
533
+ *
534
+ * @default true
535
+ */
536
+ interpretDefault?: boolean;
537
+ /**
538
+ * When a dependency is a valid ESM package, try to guess the cjs version based on the path.
539
+ * This will significantly improve the performance in huge repo, but might potentially
540
+ * cause some misalignment if a package have different logic in ESM and CJS mode.
541
+ *
542
+ * @default true
543
+ */
544
+ fallbackCJS?: boolean;
531
545
  };
532
546
  /**
533
547
  * Register apis globally
@@ -581,7 +595,6 @@ interface InlineConfig {
581
595
  * @default available CPUs
582
596
  */
583
597
  minThreads?: number;
584
- interpretDefault?: boolean;
585
598
  /**
586
599
  * Default timeout of a test in milliseconds
587
600
  *
@@ -677,13 +690,20 @@ interface UserConfig extends InlineConfig {
677
690
  * Pass with no tests
678
691
  */
679
692
  passWithNoTests?: boolean;
693
+ /**
694
+ * Run tests that cover a list of source files
695
+ */
696
+ findRelatedTests?: string[] | string;
680
697
  }
681
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
698
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'findRelatedTests'> {
682
699
  config?: string;
683
700
  filters?: string[];
684
701
  testNamePattern?: RegExp;
702
+ findRelatedTests?: string[];
685
703
  depsInline: (string | RegExp)[];
686
704
  depsExternal: (string | RegExp)[];
705
+ fallbackCJS: boolean;
706
+ interpretDefault: boolean;
687
707
  coverage: ResolvedC8Options;
688
708
  snapshotOptions: SnapshotStateOptions;
689
709
  }
@@ -704,9 +724,9 @@ interface WorkerRPC {
704
724
  snapshotSaved: (snapshot: SnapshotResult) => void;
705
725
  }
706
726
 
707
- declare const suite: ChainableFunction<"concurrent" | "skip" | "only" | "todo", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
727
+ declare const suite: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
708
728
  declare const test: TestCollector;
709
- declare const describe: ChainableFunction<"concurrent" | "skip" | "only" | "todo", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
729
+ declare const describe: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
710
730
  declare const it: TestCollector;
711
731
 
712
732
  declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
@@ -782,6 +802,7 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
782
802
  };
783
803
  declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
784
804
  declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
805
+ declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = JestMockCompat<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
785
806
  interface MockWithArgs<T extends MockableFunction> extends JestMockCompatFn<ArgumentsOf<T>, ReturnType<T>> {
786
807
  new (...args: ConstructorArgumentsOf<T>): T;
787
808
  (...args: ArgumentsOf<T>): ReturnType<T>;
@@ -876,6 +897,11 @@ interface WebSocketHandlers {
876
897
  getFiles(): File[];
877
898
  getConfig(): ResolvedConfig;
878
899
  getSourceCode(id: string): Promise<string>;
900
+ getModuleGraph(id: string): Promise<{
901
+ graph: Record<string, string[]>;
902
+ externalized: string[];
903
+ inlined: string[];
904
+ }>;
879
905
  rerun(files: string[]): Promise<void>;
880
906
  }
881
907
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onTaskUpdate'> {
@@ -891,23 +917,29 @@ declare module 'vite' {
891
917
  test?: VitestInlineConfig;
892
918
  }
893
919
  }
920
+ interface AsymmetricMatchersContaining {
921
+ stringContaining(expected: string): void;
922
+ objectContaining(expected: any): ObjectContaining;
923
+ arrayContaining(expected: unknown[]): ArrayContaining;
924
+ stringMatching(expected: string | RegExp): StringMatching;
925
+ }
894
926
  declare global {
895
927
  namespace Chai {
896
- interface ExpectStatic {
928
+ interface ExpectStatic extends AsymmetricMatchersContaining {
897
929
  extend(expects: MatchersObject): void;
898
- stringContaining(expected: string): void;
930
+ assertions(expected: number): void;
931
+ hasAssertions(): void;
899
932
  anything(): Anything;
900
- objectContaining(expected: any): ObjectContaining;
901
933
  any(constructor: unknown): Any;
902
- arrayContaining(expected: any): ArrayContaining;
903
- stringMatching(expected: RegExp): StringMatching;
904
- assertions(expected: number): void;
934
+ addSnapshotSerializer(plugin: Plugin): void;
935
+ not: AsymmetricMatchersContaining;
905
936
  }
906
- interface Assertion {
907
- chaiEqual(expected: any): void;
908
- toMatchSnapshot(message?: string): Assertion;
909
- toMatchInlineSnapshot(snapshot?: string, message?: string): Assertion;
910
- matchSnapshot(message?: string): Assertion;
937
+ interface JestAssertions {
938
+ toMatchSnapshot(message?: string): void;
939
+ toMatchInlineSnapshot(snapshot?: string, message?: string): void;
940
+ toThrowErrorMatchingSnapshot(message?: string): void;
941
+ toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
942
+ matchSnapshot(message?: string): void;
911
943
  toEqual(expected: any): void;
912
944
  toStrictEqual(expected: any): void;
913
945
  toBe(expected: any): void;
@@ -953,7 +985,15 @@ declare global {
953
985
  toHaveNthReturnedWith(nthCall: number, value: any): void;
954
986
  nthReturnedWith(nthCall: number, value: any): void;
955
987
  }
988
+ type Promisify<O> = {
989
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
990
+ };
991
+ interface Assertion extends JestAssertions {
992
+ resolves: Promisify<Assertion>;
993
+ rejects: Promisify<Assertion>;
994
+ chaiEqual(expected: any): void;
995
+ }
956
996
  }
957
997
  }
958
998
 
959
- export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
999
+ export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-67a5a3b3.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-ea959009.js';
1
+ export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-56df0b20.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-7f52a6d6.js';
3
3
  export { f as fn, s as spies, a as spyOn } from './jest-mock-038a01b3.js';
4
4
  export { assert, default as chai, should } from 'chai';
5
- import './index-090545ef.js';
5
+ import './index-9fdde2e8.js';
6
6
  import 'url';
7
7
  import 'tty';
8
8
  import 'local-pkg';
package/dist/node.d.ts CHANGED
@@ -125,20 +125,18 @@ interface UserConsoleLog {
125
125
 
126
126
  declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
127
127
  declare type TaskState = RunMode | 'pass' | 'fail';
128
- declare type ComputeMode = 'serial' | 'concurrent';
129
128
  interface TaskBase {
130
129
  id: string;
131
130
  name: string;
132
131
  mode: RunMode;
133
- computeMode: ComputeMode;
132
+ concurrent?: boolean;
134
133
  suite?: Suite;
135
134
  file?: File;
136
135
  result?: TaskResult;
137
136
  }
138
137
  interface TaskResult {
139
138
  state: TaskState;
140
- start: number;
141
- end?: number;
139
+ duration?: number;
142
140
  error?: unknown;
143
141
  }
144
142
  declare type TaskResultPack = [id: string, result: TaskResult | undefined];
@@ -148,6 +146,7 @@ interface Suite extends TaskBase {
148
146
  }
149
147
  interface File extends Suite {
150
148
  filepath: string;
149
+ collectDuration?: number;
151
150
  }
152
151
  interface Test extends TaskBase {
153
152
  type: 'test';
@@ -237,6 +236,20 @@ interface InlineConfig {
237
236
  * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
238
237
  */
239
238
  inline?: (string | RegExp)[];
239
+ /**
240
+ * Interpret CJS module's default as named exports
241
+ *
242
+ * @default true
243
+ */
244
+ interpretDefault?: boolean;
245
+ /**
246
+ * When a dependency is a valid ESM package, try to guess the cjs version based on the path.
247
+ * This will significantly improve the performance in huge repo, but might potentially
248
+ * cause some misalignment if a package have different logic in ESM and CJS mode.
249
+ *
250
+ * @default true
251
+ */
252
+ fallbackCJS?: boolean;
240
253
  };
241
254
  /**
242
255
  * Register apis globally
@@ -290,7 +303,6 @@ interface InlineConfig {
290
303
  * @default available CPUs
291
304
  */
292
305
  minThreads?: number;
293
- interpretDefault?: boolean;
294
306
  /**
295
307
  * Default timeout of a test in milliseconds
296
308
  *
@@ -386,13 +398,20 @@ interface UserConfig extends InlineConfig {
386
398
  * Pass with no tests
387
399
  */
388
400
  passWithNoTests?: boolean;
401
+ /**
402
+ * Run tests that cover a list of source files
403
+ */
404
+ findRelatedTests?: string[] | string;
389
405
  }
390
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
406
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'findRelatedTests'> {
391
407
  config?: string;
392
408
  filters?: string[];
393
409
  testNamePattern?: RegExp;
410
+ findRelatedTests?: string[];
394
411
  depsInline: (string | RegExp)[];
395
412
  depsExternal: (string | RegExp)[];
413
+ fallbackCJS: boolean;
414
+ interpretDefault: boolean;
396
415
  coverage: ResolvedC8Options;
397
416
  snapshotOptions: SnapshotStateOptions;
398
417
  }
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { c as createVitest } from './index-df5396e4.js';
2
- import './index-090545ef.js';
1
+ export { c as createVitest } from './index-0963bf06.js';
2
+ import './index-9fdde2e8.js';
3
3
  import 'url';
4
4
  import 'tty';
5
5
  import 'local-pkg';
@@ -11,10 +11,10 @@ import 'os';
11
11
  import 'util';
12
12
  import 'stream';
13
13
  import 'events';
14
- import './constants-22bbd600.js';
14
+ import './constants-8b3a9b31.js';
15
15
  import './magic-string.es-94000aea.js';
16
16
  import 'perf_hooks';
17
- import './diff-a295cb37.js';
17
+ import './diff-aeba6bd6.js';
18
18
  import './index-648e7ab2.js';
19
19
  import './_commonjsHelpers-c9e3b764.js';
20
20
  import 'assert';
@@ -9,11 +9,15 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import require$$7 from 'url';
12
- import { A as API_PATH } from './constants-22bbd600.js';
13
- import './index-090545ef.js';
12
+ import { A as API_PATH } from './constants-8b3a9b31.js';
13
+ import { s as shouldExternalize } from './externalize-2f63779d.js';
14
+ import './index-9fdde2e8.js';
14
15
  import 'tty';
15
16
  import 'local-pkg';
16
17
  import 'path';
18
+ import 'module';
19
+ import 'assert';
20
+ import 'util';
17
21
 
18
22
  /*! (c) 2020 Andrea Giammarchi */
19
23
 
@@ -4276,6 +4280,35 @@ function setup(ctx) {
4276
4280
  },
4277
4281
  getConfig() {
4278
4282
  return ctx.config;
4283
+ },
4284
+ async getModuleGraph(id) {
4285
+ const graph = {};
4286
+ function clearId(id2) {
4287
+ return (id2 == null ? void 0 : id2.replace(/\?v=\w+$/, "")) || "";
4288
+ }
4289
+ function get(mod, seen = new Set()) {
4290
+ if (!mod || !mod.id || seen.has(mod))
4291
+ return;
4292
+ seen.add(mod);
4293
+ const mods = Array.from(mod.importedModules).filter((i) => i.id && !i.id.includes("/vitest/dist/"));
4294
+ graph[clearId(mod.id)] = mods.map((i) => clearId(i.id));
4295
+ mods.forEach((m) => get(m, seen));
4296
+ }
4297
+ get(ctx.server.moduleGraph.getModuleById(id));
4298
+ const externalized = [];
4299
+ const inlined = [];
4300
+ await Promise.all(Object.keys(graph).map(async (i) => {
4301
+ const rewrote = await shouldExternalize(i, ctx.config);
4302
+ if (rewrote)
4303
+ externalized.push(rewrote);
4304
+ else
4305
+ inlined.push(i);
4306
+ }));
4307
+ return {
4308
+ graph,
4309
+ externalized,
4310
+ inlined
4311
+ };
4279
4312
  }
4280
4313
  },
4281
4314
  post(msg) {