vitest 0.31.0 → 0.31.1

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.
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { startTests } from '@vitest/runner';
2
- import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-b7007192.js';
2
+ import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-ad1c3f45.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
package/dist/child.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import v8 from 'node:v8';
2
- import { c as createBirpc } from './vendor-index.7dcbfa46.js';
2
+ import { c as createBirpc } from './vendor-index.3982ff76.js';
3
3
  import { parseRegexp } from '@vitest/utils';
4
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.a08cff9c.js';
4
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.3e144152.js';
5
5
  import { a as rpcDone } from './vendor-rpc.4d3d7a54.js';
6
6
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
7
7
  import 'node:url';
@@ -1,6 +1,6 @@
1
1
  import { promises, existsSync } from 'node:fs';
2
2
  import { dirname } from 'pathe';
3
- import { c as createBirpc, i as isPrimitive } from './vendor-index.7dcbfa46.js';
3
+ import { c as createBirpc, i as isPrimitive } from './vendor-index.3982ff76.js';
4
4
  import require$$0$2 from 'stream';
5
5
  import require$$0 from 'zlib';
6
6
  import require$$0$1 from 'buffer';
@@ -3,7 +3,7 @@ import p from 'path';
3
3
  import require$$0$1 from 'util';
4
4
  import require$$0$3 from 'child_process';
5
5
  import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.c1e09929.js';
6
- import { o as onetime$1 } from './vendor-cli-api.de0530cb.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.d608f86b.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
@@ -37,7 +37,7 @@ import '@vitest/snapshot/manager';
37
37
  import 'vite-node/server';
38
38
  import './vendor-paths.84fc7a99.js';
39
39
  import 'node:v8';
40
- import './vendor-index.7dcbfa46.js';
40
+ import './vendor-index.3982ff76.js';
41
41
  import 'node:worker_threads';
42
42
  import 'tinypool';
43
43
  import 'node:perf_hooks';
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest, d as divider } from './vendor-cli-api.de0530cb.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.d608f86b.js';
5
5
  import './vendor-constants.538d9b49.js';
6
6
  import './vendor-coverage.c8fd34c3.js';
7
7
  import './vendor-index.75f2b63d.js';
@@ -31,7 +31,7 @@ import 'vite-node/server';
31
31
  import './vendor-paths.84fc7a99.js';
32
32
  import 'node:v8';
33
33
  import 'node:child_process';
34
- import './vendor-index.7dcbfa46.js';
34
+ import './vendor-index.3982ff76.js';
35
35
  import 'node:worker_threads';
36
36
  import 'node:os';
37
37
  import 'tinypool';
@@ -63,7 +63,23 @@ cli.command("dev [...filters]").action(watch);
63
63
  cli.command("bench [...filters]").action(benchmark);
64
64
  cli.command("typecheck [...filters]").action(typecheck);
65
65
  cli.command("[...filters]").action((filters, options) => start("test", filters, options));
66
- cli.parse();
66
+ try {
67
+ cli.parse();
68
+ } catch (originalError) {
69
+ const fullArguments = cli.rawArgs.join(" ");
70
+ const conflictingArgs = [];
71
+ for (const arg of cli.rawArgs) {
72
+ if (arg.startsWith("--") && !arg.includes(".") && fullArguments.includes(`${arg}.`)) {
73
+ const dotArgs = cli.rawArgs.filter((rawArg) => rawArg.startsWith(arg) && rawArg.includes("."));
74
+ conflictingArgs.push({ arg, dotArgs });
75
+ }
76
+ }
77
+ if (conflictingArgs.length === 0)
78
+ throw originalError;
79
+ const error = conflictingArgs.map(({ arg, dotArgs }) => `A boolean argument "${arg}" was used with dot notation arguments "${dotArgs.join(" ")}".
80
+ Please specify the "${arg}" argument with dot notation as well: "${arg}.enabled"`).join("\n");
81
+ throw new Error(error);
82
+ }
67
83
  async function runRelated(relatedFiles, argv) {
68
84
  argv.related = relatedFiles;
69
85
  argv.passWithNoTests ?? (argv.passWithNoTests = true);
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
- export { ConfigEnv, mergeConfig } from 'vite';
3
- import { a0 as ResolvedCoverageOptions, q as UserConfig$1, a3 as CoverageC8Options, a4 as CustomProviderOptions, a2 as CoverageIstanbulOptions, ag as HtmlOptions, ah as FileOptions, ai as CloverOptions, aj as CoberturaOptions, ak as HtmlSpaOptions, al as LcovOptions, am as LcovOnlyOptions, an as TeamcityOptions, ao as TextOptions, ap as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-b7007192.js';
1
+ import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
+ export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
+ import { a0 as ResolvedCoverageOptions, q as UserConfig, a3 as CoverageC8Options, a4 as CustomProviderOptions, a2 as CoverageIstanbulOptions, ag as HtmlOptions, ah as FileOptions, ai as CloverOptions, aj as CoberturaOptions, ak as HtmlSpaOptions, al as LcovOptions, am as LcovOnlyOptions, an as TeamcityOptions, ao as TextOptions, ap as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-ad1c3f45.js';
4
4
  import '@vitest/snapshot';
5
5
  import '@vitest/expect';
6
6
  import '@vitest/runner';
@@ -70,17 +70,14 @@ declare const config: {
70
70
  };
71
71
  slowTestThreshold: number;
72
72
  };
73
- declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
73
+ declare const configDefaults: Required<Pick<UserConfig, keyof typeof config>>;
74
74
 
75
- interface UserConfig extends UserConfig$2 {
76
- test?: UserConfig$2['test'] | undefined;
77
- }
78
- interface UserWorkspaceConfig extends UserConfig$2 {
79
- test?: ProjectConfig | undefined;
75
+ interface UserWorkspaceConfig extends UserConfig$1 {
76
+ test?: ProjectConfig;
80
77
  }
81
78
 
82
- type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
83
- type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
79
+ type UserConfigFn = (env: ConfigEnv) => UserConfig$1 | Promise<UserConfig$1>;
80
+ type UserConfigExport = UserConfig$1 | Promise<UserConfig$1> | UserConfigFn;
84
81
  type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
85
82
  type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
86
83
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
@@ -91,4 +88,4 @@ declare function defineWorkspace(config: (string | (UserProjectConfigExport & {
91
88
  extends?: string | undefined;
92
89
  }))[];
93
90
 
94
- export { UserConfig, UserConfigExport, UserConfigFn, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
91
+ export { UserConfigExport, UserConfigFn, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
@@ -1,4 +1,4 @@
1
- import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-b7007192.js';
1
+ import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-ad1c3f45.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
@@ -1,4 +1,4 @@
1
- import { Q as Environment } from './types-b7007192.js';
1
+ import { Q as Environment } from './types-ad1c3f45.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CancelReason } from '@vitest/runner';
2
2
  export { SequenceHooks, SequenceSetupFiles, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-b7007192.js';
4
- export { n as ApiConfig, G as ArgumentsType, D as Arrayable, z as Awaitable, a1 as BaseCoverageOptions, a8 as BenchFunction, a6 as Benchmark, a7 as BenchmarkResult, a5 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, K as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a3 as CoverageC8Options, a2 as CoverageIstanbulOptions, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule, _ as CoverageReporter, a4 as CustomProviderOptions, Q as Environment, E as EnvironmentOptions, O as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, L as ModuleCache, H as MutableArray, N as Nullable, S as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Y as ReportContext, x as ResolveIdFunction, a0 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-b7007192.js';
3
+ import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-ad1c3f45.js';
4
+ export { n as ApiConfig, G as ArgumentsType, D as Arrayable, z as Awaitable, a1 as BaseCoverageOptions, a8 as BenchFunction, a6 as Benchmark, a7 as BenchmarkResult, a5 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, K as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a3 as CoverageC8Options, a2 as CoverageIstanbulOptions, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule, _ as CoverageReporter, a4 as CustomProviderOptions, Q as Environment, E as EnvironmentOptions, O as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, L as ModuleCache, H as MutableArray, N as Nullable, S as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Y as ReportContext, x as ResolveIdFunction, a0 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-ad1c3f45.js';
5
5
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
6
6
  export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
7
7
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
@@ -328,7 +328,7 @@ interface VitestUtils {
328
328
  declare const vitest: VitestUtils;
329
329
  declare const vi: VitestUtils;
330
330
 
331
- declare function getRunningMode(): "watch" | "run";
331
+ declare function getRunningMode(): "run" | "watch";
332
332
  declare function isWatchMode(): boolean;
333
333
 
334
334
  interface TransformResultWithSource extends TransformResult {
package/dist/loader.js CHANGED
@@ -29,6 +29,7 @@ const BUILTIN_MODULES = new Set(builtinModules);
29
29
  * @typedef {Error & ErrnoExceptionFields} ErrnoException
30
30
  */
31
31
 
32
+
32
33
  const isWindows = process$1.platform === 'win32';
33
34
 
34
35
  const own$1 = {}.hasOwnProperty;
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as VitestRunMode, q as UserConfig, w as Vitest, a9 as MockFactory, aa as MockMap, ab as TestSequencer, ac as WorkspaceSpec } from './types-b7007192.js';
2
- export { af as TestSequencerConstructor, ad as VitestWorkspace, ae as startVitest } from './types-b7007192.js';
1
+ import { o as VitestRunMode, q as UserConfig, w as Vitest, a9 as MockFactory, aa as MockMap, ab as TestSequencer, ac as WorkspaceSpec } from './types-ad1c3f45.js';
2
+ export { af as TestSequencerConstructor, ad as VitestWorkspace, ae as startVitest } from './types-ad1c3f45.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.de0530cb.js';
2
- export { V as VitestExecutor } from './vendor-execute.a08cff9c.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.d608f86b.js';
2
+ export { V as VitestExecutor } from './vendor-execute.3e144152.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.js';
5
5
  import './vendor-coverage.c8fd34c3.js';
@@ -31,7 +31,7 @@ import 'vite-node/server';
31
31
  import './vendor-paths.84fc7a99.js';
32
32
  import 'node:v8';
33
33
  import 'node:child_process';
34
- import './vendor-index.7dcbfa46.js';
34
+ import './vendor-index.3982ff76.js';
35
35
  import 'node:worker_threads';
36
36
  import 'node:os';
37
37
  import 'tinypool';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
- import { a as ResolvedConfig } from './types-b7007192.js';
2
+ import { a as ResolvedConfig } from './types-ad1c3f45.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
@@ -268,7 +268,7 @@ declare class WorkspaceProject {
268
268
  globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
269
269
  isTargetFile(id: string, source?: string): Promise<boolean>;
270
270
  isInSourceTestFile(code: string): boolean;
271
- filterFiles(testFiles: string[], filters?: string[]): string[];
271
+ filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
272
272
  initBrowserServer(options: UserConfig): Promise<void>;
273
273
  setServer(options: UserConfig, server: ViteDevServer, params?: InitializeServerOptions): Promise<void>;
274
274
  report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
@@ -287,11 +287,12 @@ interface BrowserProvider {
287
287
  getSupportedBrowsers(): readonly string[];
288
288
  initialize(ctx: WorkspaceProject, options: BrowserProviderOptions): Awaitable$1<void>;
289
289
  openPage(url: string): Awaitable$1<void>;
290
+ catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
290
291
  close(): Awaitable$1<void>;
291
292
  }
292
293
  interface BrowserConfigOptions {
293
294
  /**
294
- * if running tests in the broweser should be the default
295
+ * if running tests in the browser should be the default
295
296
  *
296
297
  * @default false
297
298
  */
@@ -433,7 +434,7 @@ interface CliOptions extends UserConfig {
433
434
  *
434
435
  * Returns a Vitest instance if initialized successfully.
435
436
  */
436
- declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
437
+ declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
437
438
 
438
439
  type FileStatsCache = Pick<Stats, 'size'>;
439
440
  declare class FilesStatsCache {
@@ -706,6 +707,7 @@ declare class JUnitReporter implements Reporter {
706
707
  private baseLog;
707
708
  private logger;
708
709
  private _timeStart;
710
+ private fileFd?;
709
711
  onInit(ctx: Vitest): Promise<void>;
710
712
  writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
711
713
  writeErrorDetails(error: ErrorWithDiff): Promise<void>;
@@ -870,17 +872,19 @@ interface LinkMapper {
870
872
  assetPath(node: Node, name: string): string;
871
873
  }
872
874
 
873
- declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
874
- declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
875
- declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
876
- declare type BirpcFn<T> = PromisifyFn<T> & {
875
+ type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
876
+ type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
877
+ type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
878
+ type BirpcFn<T> = PromisifyFn<T> & {
877
879
  /**
878
880
  * Send event without asking for response
879
881
  */
880
882
  asEvent(...args: ArgumentsType<T>): void;
881
883
  };
882
- declare type BirpcReturn<RemoteFunctions> = {
884
+ type BirpcReturn<RemoteFunctions, LocalFunctions = {}> = {
883
885
  [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
886
+ } & {
887
+ $functions: LocalFunctions;
884
888
  };
885
889
 
886
890
  interface RuntimeRPC {
@@ -25,7 +25,7 @@ import { ViteNodeServer } from 'vite-node/server';
25
25
  import { d as distDir, r as rootDir } from './vendor-paths.84fc7a99.js';
26
26
  import v8 from 'node:v8';
27
27
  import { fork } from 'node:child_process';
28
- import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.7dcbfa46.js';
28
+ import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.3982ff76.js';
29
29
  import { MessageChannel } from 'node:worker_threads';
30
30
  import { cpus, hostname } from 'node:os';
31
31
  import Tinypool from 'tinypool';
@@ -60,7 +60,7 @@ function _mergeNamespaces(n, m) {
60
60
  return Object.freeze(n);
61
61
  }
62
62
 
63
- var version$1 = "0.31.0";
63
+ var version$1 = "0.31.1";
64
64
 
65
65
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
66
66
  async function ensurePackageInstalled(dependency, root) {
@@ -79,7 +79,7 @@ async function ensurePackageInstalled(dependency, root) {
79
79
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
80
80
  });
81
81
  if (install) {
82
- await (await import('./chunk-install-pkg.e0e70dba.js')).installPackage(dependency, { dev: true });
82
+ await (await import('./chunk-install-pkg.d1609923.js')).installPackage(dependency, { dev: true });
83
83
  process.stderr.write(c.yellow(`
84
84
  Package ${dependency} installed, re-run the command to start.
85
85
  `));
@@ -7301,10 +7301,22 @@ function createThreadsPool(ctx, { execArgv, env }) {
7301
7301
 
7302
7302
  function createBrowserPool(ctx) {
7303
7303
  const providers = /* @__PURE__ */ new Set();
7304
- const waitForTest = (id) => {
7304
+ const waitForTest = async (provider, id) => {
7305
7305
  const defer = createDefer();
7306
7306
  ctx.state.browserTestPromises.set(id, defer);
7307
- return defer;
7307
+ const off = provider.catchError((error) => {
7308
+ if (id !== "no-isolate") {
7309
+ Object.defineProperty(error, "VITEST_TEST_PATH", {
7310
+ value: id
7311
+ });
7312
+ }
7313
+ defer.reject(error);
7314
+ });
7315
+ try {
7316
+ return await defer;
7317
+ } finally {
7318
+ off();
7319
+ }
7308
7320
  };
7309
7321
  const runTests = async (project, files) => {
7310
7322
  var _a;
@@ -7328,14 +7340,14 @@ function createBrowserPool(ctx) {
7328
7340
  url.searchParams.append("path", path);
7329
7341
  url.searchParams.set("id", path);
7330
7342
  await provider.openPage(url.toString());
7331
- await waitForTest(path);
7343
+ await waitForTest(provider, path);
7332
7344
  }
7333
7345
  } else {
7334
7346
  const url = new URL("/", origin);
7335
7347
  url.searchParams.set("id", "no-isolate");
7336
7348
  paths.forEach((path) => url.searchParams.append("path", path));
7337
7349
  await provider.openPage(url.toString());
7338
- await waitForTest("no-isolate");
7350
+ await waitForTest(provider, "no-isolate");
7339
7351
  }
7340
7352
  };
7341
7353
  const runWorkspaceTests = async (specs) => {
@@ -9466,6 +9478,7 @@ class JUnitReporter {
9466
9478
  if (!existsSync(outputDirectory))
9467
9479
  await promises.mkdir(outputDirectory, { recursive: true });
9468
9480
  const fileFd = await promises.open(this.reportFile, "w+");
9481
+ this.fileFd = fileFd;
9469
9482
  this.baseLog = async (text) => await promises.writeFile(fileFd, `${text}
9470
9483
  `);
9471
9484
  } else {
@@ -9541,14 +9554,15 @@ class JUnitReporter {
9541
9554
  }
9542
9555
  }
9543
9556
  async onFinished(files = this.ctx.state.getFiles()) {
9557
+ var _a;
9544
9558
  await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
9545
9559
  const transformed = files.map((file) => {
9546
9560
  const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
9547
9561
  const stats2 = tasks.reduce(
9548
9562
  (stats3, task) => {
9549
- var _a, _b;
9563
+ var _a2, _b;
9550
9564
  return {
9551
- passed: stats3.passed + Number(((_a = task.result) == null ? void 0 : _a.state) === "pass"),
9565
+ passed: stats3.passed + Number(((_a2 = task.result) == null ? void 0 : _a2.state) === "pass"),
9552
9566
  failures: stats3.failures + Number(((_b = task.result) == null ? void 0 : _b.state) === "fail"),
9553
9567
  skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
9554
9568
  };
@@ -9596,6 +9610,7 @@ class JUnitReporter {
9596
9610
  });
9597
9611
  if (this.reportFile)
9598
9612
  this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
9613
+ await ((_a = this.fileFd) == null ? void 0 : _a.close());
9599
9614
  }
9600
9615
  }
9601
9616
 
@@ -9994,7 +10009,10 @@ class StateManager {
9994
10009
  catchError(err, type) {
9995
10010
  if (isAggregateError(err))
9996
10011
  return err.errors.forEach((error) => this.catchError(error, type));
9997
- err.type = type;
10012
+ if (err === Object(err))
10013
+ err.type = type;
10014
+ else
10015
+ err = { type, message: err };
9998
10016
  this.errorsSet.add(err);
9999
10017
  }
10000
10018
  clearErrors() {
@@ -11110,7 +11128,7 @@ createLogUpdate(process$1.stdout);
11110
11128
 
11111
11129
  createLogUpdate(process$1.stderr);
11112
11130
 
11113
- var version = "0.31.0";
11131
+ var version = "0.31.1";
11114
11132
 
11115
11133
  const comma = ','.charCodeAt(0);
11116
11134
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -11778,9 +11796,9 @@ async function makeTscErrorInfo(errInfo) {
11778
11796
  ];
11779
11797
  }
11780
11798
  async function getTsconfig(root, config) {
11781
- var _a;
11782
- const configName = ((_a = config.tsconfig) == null ? void 0 : _a.includes("jsconfig.json")) ? "jsconfig.json" : void 0;
11783
- const tsconfig = kn(config.tsconfig || root, configName);
11799
+ const configName = config.tsconfig ? basename(config.tsconfig) : void 0;
11800
+ const configSearchPath = config.tsconfig ? dirname(resolve$2(root, config.tsconfig)) : root;
11801
+ const tsconfig = kn(configSearchPath, configName);
11784
11802
  if (!tsconfig)
11785
11803
  throw new Error("no tsconfig.json found");
11786
11804
  const tempConfigPath = join(dirname(tsconfig.path), "tsconfig.vitest-temp.json");
@@ -12691,7 +12709,7 @@ async function createBrowserServer(project, options) {
12691
12709
  });
12692
12710
  await server.listen();
12693
12711
  await server.watcher.close();
12694
- (await import('./chunk-api-setup.df3106cd.js')).setup(project, server);
12712
+ (await import('./chunk-api-setup.86042fed.js')).setup(project, server);
12695
12713
  return server;
12696
12714
  }
12697
12715
 
@@ -12723,6 +12741,14 @@ class PlaywrightBrowserProvider {
12723
12741
  });
12724
12742
  return this.cachedBrowser;
12725
12743
  }
12744
+ catchError(cb) {
12745
+ var _a;
12746
+ (_a = this.cachedBrowser) == null ? void 0 : _a.on("pageerror", cb);
12747
+ return () => {
12748
+ var _a2;
12749
+ (_a2 = this.cachedBrowser) == null ? void 0 : _a2.off("pageerror", cb);
12750
+ };
12751
+ }
12726
12752
  async openPage(url) {
12727
12753
  const browserInstance = await this.openBrowser();
12728
12754
  await browserInstance.goto(url);
@@ -12780,6 +12806,11 @@ class WebdriverBrowserProvider {
12780
12806
  const browserInstance = await this.openBrowser();
12781
12807
  await browserInstance.url(url);
12782
12808
  }
12809
+ // TODO
12810
+ catchError(_cb) {
12811
+ return () => {
12812
+ };
12813
+ }
12783
12814
  async close() {
12784
12815
  var _a, _b, _c;
12785
12816
  await Promise.all([
@@ -13132,9 +13163,9 @@ class WorkspaceProject {
13132
13163
  return this.ctx.reporters;
13133
13164
  }
13134
13165
  async globTestFiles(filters = []) {
13135
- const { dir, root } = this.config;
13136
- const testFiles = await this.globAllTestFiles(this.config, dir || root);
13137
- return this.filterFiles(testFiles, filters);
13166
+ const dir = this.config.dir || this.config.root;
13167
+ const testFiles = await this.globAllTestFiles(this.config, dir);
13168
+ return this.filterFiles(testFiles, filters, dir);
13138
13169
  }
13139
13170
  async globAllTestFiles(config, cwd) {
13140
13171
  const { include, exclude, includeSource } = config;
@@ -13178,11 +13209,17 @@ class WorkspaceProject {
13178
13209
  isInSourceTestFile(code) {
13179
13210
  return code.includes("import.meta.vitest");
13180
13211
  }
13181
- filterFiles(testFiles, filters = []) {
13212
+ filterFiles(testFiles, filters = [], dir) {
13182
13213
  if (filters.length && process.platform === "win32")
13183
13214
  filters = filters.map((f) => toNamespacedPath(f));
13184
- if (filters.length)
13185
- return testFiles.filter((i) => filters.some((f) => i.includes(f)));
13215
+ if (filters.length) {
13216
+ return testFiles.filter((t) => {
13217
+ const testFile = relative(dir, t);
13218
+ return filters.some((f) => {
13219
+ return testFile.includes(f) || testFile.includes(relative(dir, f));
13220
+ });
13221
+ });
13222
+ }
13186
13223
  return testFiles;
13187
13224
  }
13188
13225
  async initBrowserServer(options) {
@@ -13213,9 +13250,10 @@ class WorkspaceProject {
13213
13250
  return this.ctx.report(name, ...args);
13214
13251
  }
13215
13252
  async typecheck(filters = []) {
13216
- const { dir, root } = this.config;
13253
+ const dir = this.config.dir || this.config.root;
13217
13254
  const { include, exclude } = this.config.typecheck;
13218
- const testsFilesList = this.filterFiles(await this.globFiles(include, exclude, dir || root), filters);
13255
+ const testFiles = await this.globFiles(include, exclude, dir);
13256
+ const testsFilesList = this.filterFiles(testFiles, filters, dir);
13219
13257
  const checker = new Typechecker(this, testsFilesList);
13220
13258
  this.typechecker = checker;
13221
13259
  checker.onParseEnd(async ({ files, sourceErrors }) => {
@@ -13521,10 +13559,13 @@ class Vitest {
13521
13559
  await this.typecheck(filters);
13522
13560
  return;
13523
13561
  }
13524
- await this.report("onInit", this);
13525
- await this.initCoverageProvider();
13526
- await ((_a = this.coverageProvider) == null ? void 0 : _a.clean(this.config.coverage.clean));
13527
- await this.initBrowserProviders();
13562
+ try {
13563
+ await this.initCoverageProvider();
13564
+ await ((_a = this.coverageProvider) == null ? void 0 : _a.clean(this.config.coverage.clean));
13565
+ await this.initBrowserProviders();
13566
+ } finally {
13567
+ await this.report("onInit", this);
13568
+ }
13528
13569
  const files = await this.filterTestsBySource(
13529
13570
  await this.globTestFiles(filters)
13530
13571
  );
@@ -14036,7 +14077,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14036
14077
  try {
14037
14078
  await ctx.setServer(options, server, userConfig);
14038
14079
  if (options.api && options.watch)
14039
- (await import('./chunk-api-setup.df3106cd.js')).setup(ctx);
14080
+ (await import('./chunk-api-setup.86042fed.js')).setup(ctx);
14040
14081
  } catch (err) {
14041
14082
  await ctx.logger.printError(err, true);
14042
14083
  process.exit(1);
@@ -20347,19 +20388,20 @@ var index = /*#__PURE__*/_mergeNamespaces({
20347
20388
  }, [prompts]);
20348
20389
 
20349
20390
  const keys = [
20350
- ["a", "rerun all tests"],
20391
+ [["a", "return"], "rerun all tests"],
20392
+ ["r", "rerun current pattern tests"],
20351
20393
  ["f", "rerun only failed tests"],
20352
20394
  ["u", "update snapshot"],
20353
20395
  ["p", "filter by a filename"],
20354
20396
  ["t", "filter by a test name regex pattern"],
20355
20397
  ["q", "quit"]
20356
20398
  ];
20357
- const cancelKeys = ["space", "c", ...keys.map((key) => key[0])];
20399
+ const cancelKeys = ["space", "c", ...keys.map((key) => key[0]).flat()];
20358
20400
  function printShortcutsHelp() {
20359
20401
  stdout().write(
20360
20402
  `
20361
20403
  ${c.bold(" Watch Usage")}
20362
- ${keys.map((i) => c.dim(" press ") + c.reset(c.bold(i[0])) + c.dim(` to ${i[1]}`)).join("\n")}
20404
+ ${keys.map((i) => c.dim(" press ") + c.reset([i[0]].flat().map(c.bold).join(", ")) + c.dim(` to ${i[1]}`)).join("\n")}
20363
20405
  `
20364
20406
  );
20365
20407
  }
@@ -20389,6 +20431,8 @@ function registerConsoleShortcuts(ctx) {
20389
20431
  return ctx.updateSnapshot();
20390
20432
  if (name === "a" || name === "return")
20391
20433
  return ctx.changeNamePattern("");
20434
+ if (name === "r")
20435
+ return ctx.rerunFiles();
20392
20436
  if (name === "f")
20393
20437
  return ctx.rerunFailed();
20394
20438
  if (name === "t")
@@ -20442,7 +20486,7 @@ function registerConsoleShortcuts(ctx) {
20442
20486
  on();
20443
20487
  }
20444
20488
 
20445
- async function startVitest(mode, cliFilters, options, viteOverrides) {
20489
+ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
20446
20490
  var _a;
20447
20491
  process.env.TEST = "true";
20448
20492
  process.env.VITEST = "true";
@@ -7,7 +7,7 @@ import { g as getWorkerState, a as getCurrentEnvironment } from './vendor-global
7
7
  import { d as distDir } from './vendor-paths.84fc7a99.js';
8
8
  import { existsSync, readdirSync } from 'node:fs';
9
9
  import { getColors, getType } from '@vitest/utils';
10
- import { e as getAllMockableProperties } from './vendor-index.7dcbfa46.js';
10
+ import { e as getAllMockableProperties } from './vendor-index.3982ff76.js';
11
11
  import { spyOn } from '@vitest/spy';
12
12
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
13
13
 
@@ -95,18 +95,27 @@ class AggregateErrorPonyfill extends Error {
95
95
  }
96
96
 
97
97
  const DEFAULT_TIMEOUT = 6e4;
98
+ function defaultSerialize(i) {
99
+ return i;
100
+ }
101
+ const defaultDeserialize = defaultSerialize;
102
+ const { setTimeout } = globalThis;
98
103
  function createBirpc(functions, options) {
99
104
  const {
100
105
  post,
101
106
  on,
102
107
  eventNames = [],
103
- serialize = (i) => i,
104
- deserialize = (i) => i,
108
+ serialize = defaultSerialize,
109
+ deserialize = defaultDeserialize,
110
+ resolver,
105
111
  timeout = DEFAULT_TIMEOUT
106
112
  } = options;
107
113
  const rpcPromiseMap = /* @__PURE__ */ new Map();
114
+ let _promise;
108
115
  const rpc = new Proxy({}, {
109
116
  get(_, method) {
117
+ if (method === "$functions")
118
+ return functions;
110
119
  const sendEvent = (...args) => {
111
120
  post(serialize({ m: method, a: args, t: "q" }));
112
121
  };
@@ -114,7 +123,8 @@ function createBirpc(functions, options) {
114
123
  sendEvent.asEvent = sendEvent;
115
124
  return sendEvent;
116
125
  }
117
- const sendCall = (...args) => {
126
+ const sendCall = async (...args) => {
127
+ await _promise;
118
128
  return new Promise((resolve, reject) => {
119
129
  const id = nanoid();
120
130
  rpcPromiseMap.set(id, { resolve, reject });
@@ -131,25 +141,35 @@ function createBirpc(functions, options) {
131
141
  return sendCall;
132
142
  }
133
143
  });
134
- on(async (data, ...extra) => {
144
+ _promise = on(async (data, ...extra) => {
135
145
  const msg = deserialize(data);
136
146
  if (msg.t === "q") {
137
147
  const { m: method, a: args } = msg;
138
148
  let result, error;
139
- try {
140
- result = await functions[method].apply(rpc, args);
141
- } catch (e) {
142
- error = e;
149
+ const fn = resolver ? resolver(method, functions[method]) : functions[method];
150
+ if (!fn) {
151
+ error = new Error(`[birpc] function "${method}" not found`);
152
+ } else {
153
+ try {
154
+ result = await fn.apply(rpc, args);
155
+ } catch (e) {
156
+ error = e;
157
+ }
143
158
  }
144
- if (msg.i)
159
+ if (msg.i) {
160
+ if (error && options.onError)
161
+ options.onError(error, method, args);
145
162
  post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
163
+ }
146
164
  } else {
147
165
  const { i: ack, r: result, e: error } = msg;
148
166
  const promise = rpcPromiseMap.get(ack);
149
- if (error)
150
- promise?.reject(error);
151
- else
152
- promise?.resolve(result);
167
+ if (promise) {
168
+ if (error)
169
+ promise.reject(error);
170
+ else
171
+ promise.resolve(result);
172
+ }
153
173
  rpcPromiseMap.delete(ack);
154
174
  }
155
175
  });
package/dist/worker.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { performance } from 'node:perf_hooks';
2
- import { c as createBirpc } from './vendor-index.7dcbfa46.js';
2
+ import { c as createBirpc } from './vendor-index.3982ff76.js';
3
3
  import { workerId } from 'tinypool';
4
4
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
5
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.a08cff9c.js';
5
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.3e144152.js';
6
6
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
7
7
  import { a as rpcDone } from './vendor-rpc.4d3d7a54.js';
8
8
  import '@vitest/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.31.0",
4
+ "version": "0.31.1",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "dependencies": {
132
- "@types/chai": "^4.3.4",
132
+ "@types/chai": "^4.3.5",
133
133
  "@types/chai-subset": "^1.3.3",
134
134
  "@types/node": "*",
135
135
  "acorn": "^8.8.2",
@@ -144,22 +144,22 @@
144
144
  "picocolors": "^1.0.0",
145
145
  "std-env": "^3.3.2",
146
146
  "strip-literal": "^1.0.1",
147
- "tinybench": "^2.4.0",
147
+ "tinybench": "^2.5.0",
148
148
  "tinypool": "^0.5.0",
149
149
  "vite": "^3.0.0 || ^4.0.0",
150
150
  "why-is-node-running": "^2.2.2",
151
- "@vitest/expect": "0.31.0",
152
- "@vitest/runner": "0.31.0",
153
- "vite-node": "0.31.0",
154
- "@vitest/spy": "0.31.0",
155
- "@vitest/utils": "0.31.0",
156
- "@vitest/snapshot": "0.31.0"
151
+ "@vitest/runner": "0.31.1",
152
+ "vite-node": "0.31.1",
153
+ "@vitest/expect": "0.31.1",
154
+ "@vitest/spy": "0.31.1",
155
+ "@vitest/utils": "0.31.1",
156
+ "@vitest/snapshot": "0.31.1"
157
157
  },
158
158
  "devDependencies": {
159
- "@ampproject/remapping": "^2.2.0",
159
+ "@ampproject/remapping": "^2.2.1",
160
160
  "@antfu/install-pkg": "^0.1.1",
161
161
  "@edge-runtime/vm": "2.1.2",
162
- "@jridgewell/trace-mapping": "^0.3.17",
162
+ "@jridgewell/trace-mapping": "^0.3.18",
163
163
  "@sinonjs/fake-timers": "^10.0.2",
164
164
  "@types/diff": "^5.0.3",
165
165
  "@types/estree": "^1.0.1",
@@ -169,7 +169,7 @@
169
169
  "@types/micromatch": "^4.0.2",
170
170
  "@types/prompts": "^2.4.4",
171
171
  "@types/sinonjs__fake-timers": "^8.1.2",
172
- "birpc": "0.2.3",
172
+ "birpc": "0.2.11",
173
173
  "chai-subset": "^1.6.0",
174
174
  "cli-truncate": "^3.1.0",
175
175
  "event-target-polyfill": "^0.0.3",
@@ -179,19 +179,19 @@
179
179
  "find-up": "^6.3.0",
180
180
  "flatted": "^3.2.7",
181
181
  "get-tsconfig": "^4.5.0",
182
- "happy-dom": "^8.9.0",
183
- "jsdom": "^21.1.1",
182
+ "happy-dom": "^9.10.7",
183
+ "jsdom": "^21.1.2",
184
184
  "log-update": "^5.0.1",
185
185
  "micromatch": "^4.0.5",
186
186
  "mlly": "^1.2.0",
187
187
  "p-limit": "^4.0.0",
188
- "pkg-types": "^1.0.2",
189
- "playwright": "^1.32.2",
188
+ "pkg-types": "^1.0.3",
189
+ "playwright": "^1.33.0",
190
190
  "pretty-format": "^27.5.1",
191
191
  "prompts": "^2.4.2",
192
192
  "safaridriver": "^0.0.4",
193
193
  "strip-ansi": "^7.0.1",
194
- "webdriverio": "^8.6.9",
194
+ "webdriverio": "^8.9.0",
195
195
  "ws": "^8.13.0"
196
196
  },
197
197
  "scripts": {