vitest 1.3.1 → 1.5.0
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 +4 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{integrations-globals.THajbSRg.js → integrations-globals.2J_Aii2q.js} +4 -4
- package/dist/chunks/{runtime-console.Iloo9fIt.js → runtime-console.kbFEN7E-.js} +16 -8
- package/dist/chunks/{runtime-runBaseTests.9RbsHRbU.js → runtime-runBaseTests.3fVSWBsC.js} +12 -10
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -4
- package/dist/node.d.ts +2 -2
- package/dist/node.js +7 -7
- package/dist/{reporters-MmQN-57K.d.ts → reporters-LqC_WI4d.d.ts} +233 -173
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +10 -5
- package/dist/{suite-UrZdHRff.d.ts → suite-ynYMzeLu.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +6 -0
- package/dist/vendor/{base.Z38YsPLm.js → base.BjeeYg4o.js} +2 -2
- package/dist/vendor/{base.N3JkKp7j.js → base.Xt0Omgh7.js} +9 -3
- package/dist/vendor/{cac.wWT9ELdg.js → cac.qnW6GNL2.js} +258 -129
- package/dist/vendor/{constants.K-Wf1PUy.js → constants.5J7I254_.js} +2 -1
- package/dist/vendor/{execute.27Kk4lQF.js → execute.2_yoIC01.js} +1 -1
- package/dist/vendor/{index.9hqYxJUw.js → index.-ITFwqG_.js} +1 -1
- package/dist/vendor/{index.JZMafwT-.js → index.12jbrDSD.js} +1 -1
- package/dist/vendor/{index.c1V_jzyZ.js → index.kSaPvGW6.js} +69 -26
- package/dist/vendor/inspector.IgLX3ur5.js +54 -0
- package/dist/vendor/{setup-common.snyQUvE3.js → setup-common.A1De6efh.js} +8 -1
- package/dist/vendor/utils.0uYuCbzo.js +49 -0
- package/dist/vendor/{vi.C5mroSoP.js → vi.Fxjax7rQ.js} +37 -21
- package/dist/vendor/{vm.o1IruPAo.js → vm.I_IsyNig.js} +3 -3
- package/dist/worker.js +4 -26
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +11 -5
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +10 -10
- package/dist/workers/vmThreads.js +9 -9
- package/dist/workers.d.ts +6 -3
- package/dist/workers.js +10 -9
- package/package.json +12 -12
- package/dist/vendor/utils.GbToHGHI.js +0 -41
|
@@ -315,13 +315,15 @@ interface FakeTimerInstallOpts {
|
|
|
315
315
|
now?: number | Date | undefined;
|
|
316
316
|
|
|
317
317
|
/**
|
|
318
|
-
* An array with names of global methods and APIs to fake.
|
|
319
|
-
* For instance, `
|
|
318
|
+
* An array with names of global methods and APIs to fake.
|
|
319
|
+
* For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
|
|
320
|
+
* @default ['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date']
|
|
320
321
|
*/
|
|
321
322
|
toFake?: FakeMethod[] | undefined;
|
|
322
323
|
|
|
323
324
|
/**
|
|
324
|
-
* The maximum number of timers that will be run when calling runAll()
|
|
325
|
+
* The maximum number of timers that will be run when calling runAll()
|
|
326
|
+
* @default 10000
|
|
325
327
|
*/
|
|
326
328
|
loopLimit?: number | undefined;
|
|
327
329
|
|
|
@@ -338,12 +340,119 @@ interface FakeTimerInstallOpts {
|
|
|
338
340
|
advanceTimeDelta?: number | undefined;
|
|
339
341
|
|
|
340
342
|
/**
|
|
341
|
-
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
|
342
|
-
* default
|
|
343
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
|
344
|
+
* @default true
|
|
343
345
|
*/
|
|
344
346
|
shouldClearNativeTimers?: boolean | undefined;
|
|
345
347
|
}
|
|
346
348
|
|
|
349
|
+
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
350
|
+
type Pool = BuiltinPool | (string & {});
|
|
351
|
+
interface PoolOptions extends Record<string, unknown> {
|
|
352
|
+
/**
|
|
353
|
+
* Run tests in `node:worker_threads`.
|
|
354
|
+
*
|
|
355
|
+
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
356
|
+
*
|
|
357
|
+
* This pool is used by default.
|
|
358
|
+
*/
|
|
359
|
+
threads?: ThreadsOptions & WorkerContextOptions;
|
|
360
|
+
/**
|
|
361
|
+
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
362
|
+
*
|
|
363
|
+
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
364
|
+
*/
|
|
365
|
+
forks?: ForksOptions & WorkerContextOptions;
|
|
366
|
+
/**
|
|
367
|
+
* Run tests in isolated `node:vm`.
|
|
368
|
+
* Test files are run parallel using `node:worker_threads`.
|
|
369
|
+
*
|
|
370
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
371
|
+
*/
|
|
372
|
+
vmThreads?: ThreadsOptions & VmOptions;
|
|
373
|
+
/**
|
|
374
|
+
* Run tests in isolated `node:vm`.
|
|
375
|
+
*
|
|
376
|
+
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
377
|
+
*
|
|
378
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
379
|
+
*/
|
|
380
|
+
vmForks?: ForksOptions & VmOptions;
|
|
381
|
+
}
|
|
382
|
+
interface ThreadsOptions {
|
|
383
|
+
/** Minimum amount of threads to use */
|
|
384
|
+
minThreads?: number;
|
|
385
|
+
/** Maximum amount of threads to use */
|
|
386
|
+
maxThreads?: number;
|
|
387
|
+
/**
|
|
388
|
+
* Run tests inside a single thread.
|
|
389
|
+
*
|
|
390
|
+
* @default false
|
|
391
|
+
*/
|
|
392
|
+
singleThread?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Use Atomics to synchronize threads
|
|
395
|
+
*
|
|
396
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
397
|
+
*
|
|
398
|
+
* @default false
|
|
399
|
+
*/
|
|
400
|
+
useAtomics?: boolean;
|
|
401
|
+
}
|
|
402
|
+
interface ForksOptions {
|
|
403
|
+
/** Minimum amount of child processes to use */
|
|
404
|
+
minForks?: number;
|
|
405
|
+
/** Maximum amount of child processes to use */
|
|
406
|
+
maxForks?: number;
|
|
407
|
+
/**
|
|
408
|
+
* Run tests inside a single fork.
|
|
409
|
+
*
|
|
410
|
+
* @default false
|
|
411
|
+
*/
|
|
412
|
+
singleFork?: boolean;
|
|
413
|
+
}
|
|
414
|
+
interface WorkerContextOptions {
|
|
415
|
+
/**
|
|
416
|
+
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
417
|
+
*
|
|
418
|
+
* @default true
|
|
419
|
+
*/
|
|
420
|
+
isolate?: boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
423
|
+
*
|
|
424
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
425
|
+
*
|
|
426
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
427
|
+
*
|
|
428
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
429
|
+
*
|
|
430
|
+
* @default [] // no execution arguments are passed
|
|
431
|
+
*/
|
|
432
|
+
execArgv?: string[];
|
|
433
|
+
}
|
|
434
|
+
interface VmOptions {
|
|
435
|
+
/**
|
|
436
|
+
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
437
|
+
* If you see memory leaks, try to tinker this value.
|
|
438
|
+
*/
|
|
439
|
+
memoryLimit?: string | number;
|
|
440
|
+
/** Isolation is always enabled */
|
|
441
|
+
isolate?: true;
|
|
442
|
+
/**
|
|
443
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
444
|
+
*
|
|
445
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
446
|
+
*
|
|
447
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
448
|
+
*
|
|
449
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
450
|
+
*
|
|
451
|
+
* @default [] // no execution arguments are passed
|
|
452
|
+
*/
|
|
453
|
+
execArgv?: string[];
|
|
454
|
+
}
|
|
455
|
+
|
|
347
456
|
interface ParsedFile extends File {
|
|
348
457
|
start: number;
|
|
349
458
|
end: number;
|
|
@@ -463,61 +572,6 @@ declare class Logger {
|
|
|
463
572
|
printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
|
|
464
573
|
}
|
|
465
574
|
|
|
466
|
-
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
467
|
-
workspaceConfigPath: string;
|
|
468
|
-
extends?: string;
|
|
469
|
-
}
|
|
470
|
-
declare class WorkspaceProject {
|
|
471
|
-
path: string | number;
|
|
472
|
-
ctx: Vitest;
|
|
473
|
-
options?: InitializeProjectOptions | undefined;
|
|
474
|
-
configOverride: Partial<ResolvedConfig> | undefined;
|
|
475
|
-
config: ResolvedConfig;
|
|
476
|
-
server: ViteDevServer;
|
|
477
|
-
vitenode: ViteNodeServer;
|
|
478
|
-
runner: ViteNodeRunner;
|
|
479
|
-
browser?: ViteDevServer;
|
|
480
|
-
typechecker?: Typechecker;
|
|
481
|
-
closingPromise: Promise<unknown> | undefined;
|
|
482
|
-
browserProvider: BrowserProvider | undefined;
|
|
483
|
-
browserState: {
|
|
484
|
-
files: string[];
|
|
485
|
-
resolve: () => void;
|
|
486
|
-
reject: (v: unknown) => void;
|
|
487
|
-
} | undefined;
|
|
488
|
-
testFilesList: string[] | null;
|
|
489
|
-
private _globalSetups;
|
|
490
|
-
private _provided;
|
|
491
|
-
constructor(path: string | number, ctx: Vitest, options?: InitializeProjectOptions | undefined);
|
|
492
|
-
getName(): string;
|
|
493
|
-
isCore(): boolean;
|
|
494
|
-
provide: (key: string, value: unknown) => void;
|
|
495
|
-
getProvidedContext(): ProvidedContext;
|
|
496
|
-
initializeGlobalSetup(): Promise<void>;
|
|
497
|
-
teardownGlobalSetup(): Promise<void>;
|
|
498
|
-
get logger(): Logger;
|
|
499
|
-
getModulesByFilepath(file: string): Set<vite.ModuleNode>;
|
|
500
|
-
getModuleById(id: string): vite.ModuleNode | undefined;
|
|
501
|
-
getSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
502
|
-
getBrowserSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
503
|
-
get reporters(): Reporter[];
|
|
504
|
-
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
505
|
-
globAllTestFiles(include: string[], exclude: string[], includeSource: string[] | undefined, cwd: string): Promise<string[]>;
|
|
506
|
-
isTestFile(id: string): boolean | null;
|
|
507
|
-
globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
|
|
508
|
-
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
509
|
-
isInSourceTestFile(code: string): boolean;
|
|
510
|
-
filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
|
|
511
|
-
initBrowserServer(configFile: string | undefined): Promise<void>;
|
|
512
|
-
static createBasicProject(ctx: Vitest): WorkspaceProject;
|
|
513
|
-
static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
|
|
514
|
-
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
515
|
-
isBrowserEnabled(): boolean;
|
|
516
|
-
getSerializableConfig(): ResolvedConfig;
|
|
517
|
-
close(): Promise<unknown>;
|
|
518
|
-
initBrowserProvider(): Promise<void>;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
575
|
interface BrowserProviderInitializationOptions {
|
|
522
576
|
browser: string;
|
|
523
577
|
options?: BrowserProviderOptions;
|
|
@@ -599,111 +653,59 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
599
653
|
api: ApiConfig;
|
|
600
654
|
}
|
|
601
655
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Run tests in `node:worker_threads`.
|
|
607
|
-
*
|
|
608
|
-
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
609
|
-
*
|
|
610
|
-
* This pool is used by default.
|
|
611
|
-
*/
|
|
612
|
-
threads?: ThreadsOptions & WorkerContextOptions;
|
|
613
|
-
/**
|
|
614
|
-
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
615
|
-
*
|
|
616
|
-
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
617
|
-
*/
|
|
618
|
-
forks?: ForksOptions & WorkerContextOptions;
|
|
619
|
-
/**
|
|
620
|
-
* Run tests in isolated `node:vm`.
|
|
621
|
-
* Test files are run parallel using `node:worker_threads`.
|
|
622
|
-
*
|
|
623
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
624
|
-
*/
|
|
625
|
-
vmThreads?: ThreadsOptions & VmOptions;
|
|
626
|
-
/**
|
|
627
|
-
* Run tests in isolated `node:vm`.
|
|
628
|
-
*
|
|
629
|
-
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
630
|
-
*
|
|
631
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
632
|
-
*/
|
|
633
|
-
vmForks?: ForksOptions & VmOptions;
|
|
634
|
-
}
|
|
635
|
-
interface ThreadsOptions {
|
|
636
|
-
/** Minimum amount of threads to use */
|
|
637
|
-
minThreads?: number;
|
|
638
|
-
/** Maximum amount of threads to use */
|
|
639
|
-
maxThreads?: number;
|
|
640
|
-
/**
|
|
641
|
-
* Run tests inside a single thread.
|
|
642
|
-
*
|
|
643
|
-
* @default false
|
|
644
|
-
*/
|
|
645
|
-
singleThread?: boolean;
|
|
646
|
-
/**
|
|
647
|
-
* Use Atomics to synchronize threads
|
|
648
|
-
*
|
|
649
|
-
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
650
|
-
*
|
|
651
|
-
* @default false
|
|
652
|
-
*/
|
|
653
|
-
useAtomics?: boolean;
|
|
654
|
-
}
|
|
655
|
-
interface ForksOptions {
|
|
656
|
-
/** Minimum amount of child processes to use */
|
|
657
|
-
minForks?: number;
|
|
658
|
-
/** Maximum amount of child processes to use */
|
|
659
|
-
maxForks?: number;
|
|
660
|
-
/**
|
|
661
|
-
* Run tests inside a single fork.
|
|
662
|
-
*
|
|
663
|
-
* @default false
|
|
664
|
-
*/
|
|
665
|
-
singleFork?: boolean;
|
|
666
|
-
}
|
|
667
|
-
interface WorkerContextOptions {
|
|
668
|
-
/**
|
|
669
|
-
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
670
|
-
*
|
|
671
|
-
* @default true
|
|
672
|
-
*/
|
|
673
|
-
isolate?: boolean;
|
|
674
|
-
/**
|
|
675
|
-
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
676
|
-
*
|
|
677
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
678
|
-
*
|
|
679
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
680
|
-
*
|
|
681
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
682
|
-
*
|
|
683
|
-
* @default [] // no execution arguments are passed
|
|
684
|
-
*/
|
|
685
|
-
execArgv?: string[];
|
|
656
|
+
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
657
|
+
workspaceConfigPath: string;
|
|
658
|
+
extends?: string;
|
|
686
659
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
660
|
+
declare class WorkspaceProject {
|
|
661
|
+
path: string | number;
|
|
662
|
+
ctx: Vitest;
|
|
663
|
+
options?: InitializeProjectOptions | undefined;
|
|
664
|
+
configOverride: Partial<ResolvedConfig> | undefined;
|
|
665
|
+
config: ResolvedConfig;
|
|
666
|
+
server: ViteDevServer;
|
|
667
|
+
vitenode: ViteNodeServer;
|
|
668
|
+
runner: ViteNodeRunner;
|
|
669
|
+
browser?: ViteDevServer;
|
|
670
|
+
typechecker?: Typechecker;
|
|
671
|
+
closingPromise: Promise<unknown> | undefined;
|
|
672
|
+
browserProvider: BrowserProvider | undefined;
|
|
673
|
+
browserState: {
|
|
674
|
+
files: string[];
|
|
675
|
+
resolve: () => void;
|
|
676
|
+
reject: (v: unknown) => void;
|
|
677
|
+
} | undefined;
|
|
678
|
+
testFilesList: string[] | null;
|
|
679
|
+
private _globalSetups;
|
|
680
|
+
private _provided;
|
|
681
|
+
constructor(path: string | number, ctx: Vitest, options?: InitializeProjectOptions | undefined);
|
|
682
|
+
getName(): string;
|
|
683
|
+
isCore(): boolean;
|
|
684
|
+
provide: (key: string, value: unknown) => void;
|
|
685
|
+
getProvidedContext(): ProvidedContext;
|
|
686
|
+
initializeGlobalSetup(): Promise<void>;
|
|
687
|
+
teardownGlobalSetup(): Promise<void>;
|
|
688
|
+
get logger(): Logger;
|
|
689
|
+
getModulesByFilepath(file: string): Set<vite.ModuleNode>;
|
|
690
|
+
getModuleById(id: string): vite.ModuleNode | undefined;
|
|
691
|
+
getSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
692
|
+
getBrowserSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
693
|
+
get reporters(): Reporter[];
|
|
694
|
+
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
695
|
+
globAllTestFiles(include: string[], exclude: string[], includeSource: string[] | undefined, cwd: string): Promise<string[]>;
|
|
696
|
+
isTestFile(id: string): boolean | null;
|
|
697
|
+
globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
|
|
698
|
+
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
699
|
+
isInSourceTestFile(code: string): boolean;
|
|
700
|
+
filterFiles(testFiles: string[], filters: string[], dir: string): string[];
|
|
701
|
+
initBrowserServer(configFile: string | undefined): Promise<void>;
|
|
702
|
+
static createBasicProject(ctx: Vitest): WorkspaceProject;
|
|
703
|
+
static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
|
|
704
|
+
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
705
|
+
isBrowserEnabled(): boolean;
|
|
706
|
+
getSerializableConfig(): ResolvedConfig;
|
|
707
|
+
close(): Promise<unknown>;
|
|
708
|
+
initBrowserProvider(): Promise<void>;
|
|
707
709
|
}
|
|
708
710
|
|
|
709
711
|
type WorkspaceSpec = [project: WorkspaceProject, testFile: string];
|
|
@@ -846,7 +848,7 @@ declare class VitestCache {
|
|
|
846
848
|
getFileStats(key: string): {
|
|
847
849
|
size: number;
|
|
848
850
|
} | undefined;
|
|
849
|
-
static resolveCacheDir(root: string, dir
|
|
851
|
+
static resolveCacheDir(root: string, dir?: string, projectName?: string): string;
|
|
850
852
|
static clearCache(options: CliOptions): Promise<{
|
|
851
853
|
dir: string;
|
|
852
854
|
cleared: boolean;
|
|
@@ -870,12 +872,12 @@ declare class Vitest {
|
|
|
870
872
|
cache: VitestCache;
|
|
871
873
|
reporters: Reporter[];
|
|
872
874
|
coverageProvider: CoverageProvider | null | undefined;
|
|
873
|
-
browserProvider: BrowserProvider | undefined;
|
|
874
875
|
logger: Logger;
|
|
875
876
|
pool: ProcessPool | undefined;
|
|
876
877
|
vitenode: ViteNodeServer;
|
|
877
878
|
invalidates: Set<string>;
|
|
878
879
|
changedTests: Set<string>;
|
|
880
|
+
watchedTests: Set<string>;
|
|
879
881
|
filenamePattern?: string;
|
|
880
882
|
runningPromise?: Promise<void>;
|
|
881
883
|
closingPromise?: Promise<void>;
|
|
@@ -918,6 +920,10 @@ declare class Vitest {
|
|
|
918
920
|
private _rerunTimer;
|
|
919
921
|
private scheduleRerun;
|
|
920
922
|
getModuleProjects(filepath: string): WorkspaceProject[];
|
|
923
|
+
/**
|
|
924
|
+
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
925
|
+
*/
|
|
926
|
+
watchTests(tests: string[]): void;
|
|
921
927
|
private unregisterWatcher;
|
|
922
928
|
private registerWatcher;
|
|
923
929
|
/**
|
|
@@ -1193,6 +1199,7 @@ declare class TableReporter extends BaseReporter {
|
|
|
1193
1199
|
rendererOptions: TableRendererOptions;
|
|
1194
1200
|
onTestRemoved(trigger?: string): Promise<void>;
|
|
1195
1201
|
onCollected(): void;
|
|
1202
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1196
1203
|
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1197
1204
|
onWatcherStart(): Promise<void>;
|
|
1198
1205
|
stopListRender(): Promise<void>;
|
|
@@ -1636,6 +1643,10 @@ interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
|
1636
1643
|
ignoreClassMethods?: string[];
|
|
1637
1644
|
}
|
|
1638
1645
|
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1646
|
+
/**
|
|
1647
|
+
* Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
|
|
1648
|
+
*/
|
|
1649
|
+
ignoreEmptyLines?: boolean;
|
|
1639
1650
|
}
|
|
1640
1651
|
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1641
1652
|
/** Name of the module or path to a file to load the custom provider from */
|
|
@@ -1908,10 +1919,22 @@ interface SequenceOptions {
|
|
|
1908
1919
|
*/
|
|
1909
1920
|
sequencer?: TestSequencerConstructor;
|
|
1910
1921
|
/**
|
|
1911
|
-
* Should tests run in random order.
|
|
1922
|
+
* Should files and tests run in random order.
|
|
1912
1923
|
* @default false
|
|
1913
1924
|
*/
|
|
1914
|
-
shuffle?: boolean
|
|
1925
|
+
shuffle?: boolean | {
|
|
1926
|
+
/**
|
|
1927
|
+
* Should files run in random order. Long running tests will not start
|
|
1928
|
+
* earlier if you enable this option.
|
|
1929
|
+
* @default false
|
|
1930
|
+
*/
|
|
1931
|
+
files?: boolean;
|
|
1932
|
+
/**
|
|
1933
|
+
* Should tests run in random order.
|
|
1934
|
+
* @default false
|
|
1935
|
+
*/
|
|
1936
|
+
tests?: boolean;
|
|
1937
|
+
};
|
|
1915
1938
|
/**
|
|
1916
1939
|
* Should tests run in parallel.
|
|
1917
1940
|
* @default false
|
|
@@ -2371,7 +2394,7 @@ interface InlineConfig {
|
|
|
2371
2394
|
*
|
|
2372
2395
|
* Return `false` to ignore the log.
|
|
2373
2396
|
*/
|
|
2374
|
-
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') =>
|
|
2397
|
+
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => boolean | void;
|
|
2375
2398
|
/**
|
|
2376
2399
|
* Enable stack trace filtering. If absent, all stack trace frames
|
|
2377
2400
|
* will be shown.
|
|
@@ -2400,10 +2423,13 @@ interface InlineConfig {
|
|
|
2400
2423
|
maxConcurrency?: number;
|
|
2401
2424
|
/**
|
|
2402
2425
|
* Options for configuring cache policy.
|
|
2403
|
-
* @default { dir: 'node_modules/.vitest' }
|
|
2426
|
+
* @default { dir: 'node_modules/.vite/vitest' }
|
|
2404
2427
|
*/
|
|
2405
2428
|
cache?: false | {
|
|
2406
|
-
|
|
2429
|
+
/**
|
|
2430
|
+
* @deprecated Use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir\/vitest".
|
|
2431
|
+
*/
|
|
2432
|
+
dir: string;
|
|
2407
2433
|
};
|
|
2408
2434
|
/**
|
|
2409
2435
|
* Options for configuring the order of running tests.
|
|
@@ -2441,14 +2467,35 @@ interface InlineConfig {
|
|
|
2441
2467
|
*
|
|
2442
2468
|
* Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
|
|
2443
2469
|
*/
|
|
2444
|
-
inspect?: boolean;
|
|
2470
|
+
inspect?: boolean | string;
|
|
2445
2471
|
/**
|
|
2446
2472
|
* Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
|
|
2447
2473
|
* Provides similar experience as `--inspect-brk` Node CLI argument.
|
|
2448
2474
|
*
|
|
2449
2475
|
* Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
|
|
2450
2476
|
*/
|
|
2451
|
-
inspectBrk?: boolean;
|
|
2477
|
+
inspectBrk?: boolean | string;
|
|
2478
|
+
/**
|
|
2479
|
+
* Inspector options. If `--inspect` or `--inspect-brk` is enabled, these options will be passed to the inspector.
|
|
2480
|
+
*/
|
|
2481
|
+
inspector?: {
|
|
2482
|
+
/**
|
|
2483
|
+
* Enable inspector
|
|
2484
|
+
*/
|
|
2485
|
+
enabled?: boolean;
|
|
2486
|
+
/**
|
|
2487
|
+
* Port to run inspector on
|
|
2488
|
+
*/
|
|
2489
|
+
port?: number;
|
|
2490
|
+
/**
|
|
2491
|
+
* Host to run inspector on
|
|
2492
|
+
*/
|
|
2493
|
+
host?: string;
|
|
2494
|
+
/**
|
|
2495
|
+
* Wait for debugger to connect before running tests
|
|
2496
|
+
*/
|
|
2497
|
+
waitForDebugger?: boolean;
|
|
2498
|
+
};
|
|
2452
2499
|
/**
|
|
2453
2500
|
* Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
|
|
2454
2501
|
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
@@ -2478,6 +2525,12 @@ interface InlineConfig {
|
|
|
2478
2525
|
* @default false
|
|
2479
2526
|
*/
|
|
2480
2527
|
disableConsoleIntercept?: boolean;
|
|
2528
|
+
/**
|
|
2529
|
+
* Include "location" property inside the test definition
|
|
2530
|
+
*
|
|
2531
|
+
* @default false
|
|
2532
|
+
*/
|
|
2533
|
+
includeTaskLocation?: boolean;
|
|
2481
2534
|
}
|
|
2482
2535
|
interface TypecheckConfig {
|
|
2483
2536
|
/**
|
|
@@ -2563,6 +2616,10 @@ interface UserConfig extends InlineConfig {
|
|
|
2563
2616
|
* Additional exclude patterns
|
|
2564
2617
|
*/
|
|
2565
2618
|
cliExclude?: string[];
|
|
2619
|
+
/**
|
|
2620
|
+
* Override vite config's clearScreen from cli
|
|
2621
|
+
*/
|
|
2622
|
+
clearScreen?: boolean;
|
|
2566
2623
|
}
|
|
2567
2624
|
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude'> {
|
|
2568
2625
|
mode: VitestRunMode;
|
|
@@ -2586,6 +2643,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
2586
2643
|
count: number;
|
|
2587
2644
|
};
|
|
2588
2645
|
cache: {
|
|
2646
|
+
/**
|
|
2647
|
+
* @deprecated
|
|
2648
|
+
*/
|
|
2589
2649
|
dir: string;
|
|
2590
2650
|
} | false;
|
|
2591
2651
|
sequence: {
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { aS as BaseReporter, aJ as BasicReporter, a_ as BenchmarkBuiltinReporters, aZ as BenchmarkReportsMap, aV as BuiltinReporterOptions, aU as BuiltinReporters, aI as DefaultReporter, aK as DotReporter, aR as GithubActionsReporter, aQ as HangingProcessReporter, aO as JUnitReporter, aW as JsonAssertionResult, aL as JsonReporter, aX as JsonTestResult, aY as JsonTestResults, w as Reporter, aT as ReportersMap, aP as TapFlatReporter, aN as TapReporter, aM as VerboseReporter } from './reporters-
|
|
1
|
+
export { aS as BaseReporter, aJ as BasicReporter, a_ as BenchmarkBuiltinReporters, aZ as BenchmarkReportsMap, aV as BuiltinReporterOptions, aU as BuiltinReporters, aI as DefaultReporter, aK as DotReporter, aR as GithubActionsReporter, aQ as HangingProcessReporter, aO as JUnitReporter, aW as JsonAssertionResult, aL as JsonReporter, aX as JsonTestResult, aY as JsonTestResults, w as Reporter, aT as ReportersMap, aP as TapFlatReporter, aN as TapReporter, aM as VerboseReporter } from './reporters-LqC_WI4d.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
package/dist/reporters.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.
|
|
1
|
+
export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.kSaPvGW6.js';
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'pathe';
|
|
4
4
|
import './vendor/index.ir9i0ywP.js';
|
|
@@ -7,14 +7,14 @@ import '@vitest/runner/utils';
|
|
|
7
7
|
import '@vitest/utils';
|
|
8
8
|
import './vendor/global.CkGT_TMy.js';
|
|
9
9
|
import 'picocolors';
|
|
10
|
+
import './vendor/tasks.IknbGB2n.js';
|
|
10
11
|
import 'node:perf_hooks';
|
|
11
|
-
import './chunks/runtime-console.
|
|
12
|
+
import './chunks/runtime-console.kbFEN7E-.js';
|
|
12
13
|
import 'node:stream';
|
|
13
14
|
import 'node:console';
|
|
14
15
|
import 'node:path';
|
|
15
16
|
import './vendor/date.Ns1pGd_X.js';
|
|
16
|
-
import './vendor/base.
|
|
17
|
-
import './vendor/tasks.IknbGB2n.js';
|
|
17
|
+
import './vendor/base.Xt0Omgh7.js';
|
|
18
18
|
import '@vitest/utils/source-map';
|
|
19
19
|
import 'node:os';
|
|
20
20
|
import 'node:module';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig } from './reporters-
|
|
2
|
+
import { R as ResolvedConfig } from './reporters-LqC_WI4d.js';
|
|
3
3
|
import * as tinybench from 'tinybench';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-node';
|
|
@@ -23,6 +23,7 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
23
23
|
constructor(config: ResolvedConfig);
|
|
24
24
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
25
25
|
onBeforeRunFiles(): void;
|
|
26
|
+
onAfterRunFiles(): void;
|
|
26
27
|
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
27
28
|
onAfterRunTask(test: Task): void;
|
|
28
29
|
onCancel(_reason: CancelReason): void;
|
package/dist/runners.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.Fxjax7rQ.js';
|
|
3
3
|
import './vendor/index.ir9i0ywP.js';
|
|
4
4
|
import { r as rpc } from './vendor/rpc.joBhAkyK.js';
|
|
5
5
|
import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
|
|
@@ -13,7 +13,7 @@ import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
|
13
13
|
import '@vitest/snapshot';
|
|
14
14
|
import '@vitest/utils/error';
|
|
15
15
|
import '@vitest/utils/source-map';
|
|
16
|
-
import './vendor/base.
|
|
16
|
+
import './vendor/base.Xt0Omgh7.js';
|
|
17
17
|
import './vendor/date.Ns1pGd_X.js';
|
|
18
18
|
import '@vitest/spy';
|
|
19
19
|
import 'pathe';
|
|
@@ -36,6 +36,9 @@ class VitestTestRunner {
|
|
|
36
36
|
onBeforeRunFiles() {
|
|
37
37
|
this.snapshotClient.clear();
|
|
38
38
|
}
|
|
39
|
+
onAfterRunFiles() {
|
|
40
|
+
this.workerState.current = void 0;
|
|
41
|
+
}
|
|
39
42
|
async onAfterRunSuite(suite) {
|
|
40
43
|
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
41
44
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
@@ -50,12 +53,13 @@ class VitestTestRunner {
|
|
|
50
53
|
if (result)
|
|
51
54
|
await rpc().snapshotSaved(result);
|
|
52
55
|
}
|
|
56
|
+
this.workerState.current = suite.suite;
|
|
53
57
|
}
|
|
54
58
|
onAfterRunTask(test) {
|
|
55
59
|
this.snapshotClient.clearTest();
|
|
56
60
|
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
57
61
|
test.result.heap = process.memoryUsage().heapUsed;
|
|
58
|
-
this.workerState.current =
|
|
62
|
+
this.workerState.current = test.suite;
|
|
59
63
|
}
|
|
60
64
|
onCancel(_reason) {
|
|
61
65
|
this.cancelRun = true;
|
|
@@ -74,6 +78,7 @@ class VitestTestRunner {
|
|
|
74
78
|
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
|
|
75
79
|
await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
|
|
76
80
|
}
|
|
81
|
+
this.workerState.current = suite;
|
|
77
82
|
}
|
|
78
83
|
onBeforeTryTask(test) {
|
|
79
84
|
var _a, _b;
|
|
@@ -156,8 +161,8 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
156
161
|
else if (task.type === "suite")
|
|
157
162
|
benchmarkSuiteGroup.push(task);
|
|
158
163
|
}
|
|
159
|
-
|
|
160
|
-
await
|
|
164
|
+
for (const subSuite of benchmarkSuiteGroup)
|
|
165
|
+
await runBenchmarkSuite(subSuite, runner);
|
|
161
166
|
if (benchmarkGroup.length) {
|
|
162
167
|
const defer = createDefer();
|
|
163
168
|
suite.result = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Custom } from '@vitest/runner';
|
|
2
2
|
import '@vitest/runner/utils';
|
|
3
|
-
import { ap as BenchFunction, aq as BenchmarkAPI } from './reporters-
|
|
3
|
+
import { ap as BenchFunction, aq as BenchmarkAPI } from './reporters-LqC_WI4d.js';
|
|
4
4
|
import { Options } from 'tinybench';
|
|
5
5
|
|
|
6
6
|
declare function getBenchOptions(key: Custom): Options;
|
package/dist/suite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createTaskCollector, getCurrentSuite, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
2
2
|
export { createChainable } from '@vitest/runner/utils';
|
|
3
|
-
export { g as getBenchFn, a as getBenchOptions } from './suite-
|
|
4
|
-
import './reporters-
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './suite-ynYMzeLu.js';
|
|
4
|
+
import './reporters-LqC_WI4d.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
package/dist/utils.d.ts
CHANGED