vitest 5.0.5 → 5.1.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.
Files changed (62) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +6 -5
  3. package/dist/browser.js +6 -6
  4. package/dist/chunks/{base.CzXt2BO_.js → base.Cof-UHJf.js} +17 -21
  5. package/dist/chunks/{browser.d.FGQ9_rK6.d.ts → browser.d.C7tWgUvw.d.ts} +4 -3
  6. package/dist/chunks/{cac.CLrZKo1g.js → cac.BYbt0aJp.js} +30 -16
  7. package/dist/chunks/{cli-api.De07GUeT.js → cli-api.COfZo8lK.js} +5226 -4385
  8. package/dist/chunks/{config.d.QBNYCgFU.d.ts → config.d.B3YV4t0O.d.ts} +169 -93
  9. package/dist/chunks/{console.DtI4yxfN.js → console.CQZ877Hi.js} +6 -3
  10. package/dist/chunks/{constants.-juJ8b_4.js → constants.DLYM6cZY.js} +1 -1
  11. package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
  12. package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
  13. package/dist/chunks/{creator.C5g4egeG.js → creator.DHWmytIK.js} +11 -11
  14. package/dist/chunks/{doctor.BK86Cncq.js → doctor.B-oPbwps.js} +2 -2
  15. package/dist/chunks/{environment.d.BY56MoGs.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
  16. package/dist/chunks/{globals.CXEE6_2C.js → globals.ZKtKSkEf.js} +7 -6
  17. package/dist/chunks/{index.CK-t0WMg.js → index.Bi0NXYPf.js} +165 -62
  18. package/dist/chunks/{index.aTZaPVhf.js → index.CZzC1gGg.js} +299 -440
  19. package/dist/chunks/{index.1TqnEahn.js → index.Di8au7q4.js} +104 -72
  20. package/dist/chunks/{index.CoUIxZd4.js → index.w_oBZ9N8.js} +5 -5
  21. package/dist/chunks/{init-forks.CRxIPOJR.js → init-forks.BaDXQSD8.js} +1 -1
  22. package/dist/chunks/{init-threads.Dv3kwST_.js → init-threads.ZX_Vov0z.js} +1 -1
  23. package/dist/chunks/{init.PvxYpuCm.js → init.CO4AB7HZ.js} +4 -4
  24. package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
  25. package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
  26. package/dist/chunks/{nativeModuleMocker.BxrHJNAF.js → nativeModuleMocker.Dh5azSB4.js} +4 -3
  27. package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
  28. package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
  29. package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
  30. package/dist/chunks/{plugin.d.C8mmycim.d.ts → plugin.d.LRFSN46m.d.ts} +191 -32
  31. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  32. package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
  33. package/dist/chunks/{rpc.DpkUyY1N.js → rpc.Uhkwr2NM.js} +2 -2
  34. package/dist/chunks/{rpc.d.Cft1biqy.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
  35. package/dist/chunks/{run.BPv-BBRv.js → run.CjdgFZiW.js} +28 -7
  36. package/dist/chunks/{setup-common.HGAqWOnX.js → setup-common.CqAQCXzx.js} +2 -2
  37. package/dist/chunks/{source-map.DdKI5IHB.js → source-map.DakdQc29.js} +43 -37
  38. package/dist/chunks/{source-map.d.kzFtk_dj.d.ts → source-map.d.BkG8YK_3.d.ts} +2 -1
  39. package/dist/chunks/{task-utils.d.PFh2BV6Q.d.ts → task-utils.d.D-gFPNFi.d.ts} +2 -1
  40. package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
  41. package/dist/chunks/{vm.FGl2rw_t.js → vm.b4MbCAJQ.js} +27 -14
  42. package/dist/chunks/{worker.d.BH-r1bPu.d.ts → worker.d.CyJRpyfZ.d.ts} +3 -3
  43. package/dist/cli.js +3 -3
  44. package/dist/config.cjs +1 -1
  45. package/dist/config.d.ts +11 -11
  46. package/dist/config.js +1 -1
  47. package/dist/index.d.ts +21 -15
  48. package/dist/index.js +6 -5
  49. package/dist/module-evaluator.d.ts +3 -2
  50. package/dist/node.d.ts +30 -12
  51. package/dist/node.js +16 -14
  52. package/dist/runtime.d.ts +4 -4
  53. package/dist/runtime.js +5 -4
  54. package/dist/task-utils.js +10 -4
  55. package/dist/worker.d.ts +4 -4
  56. package/dist/worker.js +14 -13
  57. package/dist/workers/forks.js +15 -14
  58. package/dist/workers/runVmTests.js +16 -12
  59. package/dist/workers/threads.js +15 -14
  60. package/dist/workers/vmForks.js +11 -10
  61. package/dist/workers/vmThreads.js +11 -10
  62. package/package.json +17 -17
@@ -1,13 +1,13 @@
1
- import { DevEnvironment, IndexHtmlTransformContext, IndexHtmlTransformResult, ViteDevServer, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, TransformResult as TransformResult$1, InlineConfig as InlineConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
2
- import { aU as TaskMeta, U as UserConsoleLog, O as Suite, a as File, bi as SerializableRetry, T as TestError, g as TestAnnotation, h as TestArtifact, b0 as TestBenchmark, aJ as SerializedError, a0 as ImportDuration, m as Test, A as Awaitable, Y as CancelReason, P as ParsedStack, bj as BrowserTraceViewMode, a5 as BaselineData, o as ProvidedContext, b as SerializedConfig, bk as Arrayable, a2 as AfterSuiteRunMeta, aO as SnapshotStateOptions, aP as SnapshotSummary, aM as SnapshotResult, X as Task, bl as AsyncLeak, j as TaskResultPack, F as FileSpecification, l as SerializedRootConfig, L as LabelColor, c as SerializedDiffOptions, bg as SequenceSetupFiles, bf as SequenceHooks, bm as PrettyFormatOptions, C as Config, e as TestTagDefinition } from './config.d.QBNYCgFU.js';
1
+ import { DevEnvironment, IndexHtmlTransformContext, IndexHtmlTransformResult, ViteDevServer, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, ESTree, TransformResult as TransformResult$1, InlineConfig as InlineConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
2
+ import { aW as TaskMeta, U as UserConsoleLog, Q as Suite, a as File, bk as SerializableRetry, T as TestError, h as TestAnnotation, j as TestArtifact, b2 as TestBenchmark, aL as SerializedError, a1 as ImportDuration, n as Test, A as Awaitable, Z as CancelReason, P as ParsedStack, bl as BrowserTraceViewMode, bm as BrowserTraceViewRecordingMode, a6 as BaselineData, p as ProvidedContext, b as SerializedConfig, bn as Arrayable, a3 as AfterSuiteRunMeta, aQ as SnapshotStateOptions, aR as SnapshotSummary, aO as SnapshotResult, Y as Task, bo as AsyncLeak, k as TaskResultPack, F as FileSpecification, m as SerializedRootConfig, L as LabelColor, c as SerializedDiffOptions, bi as SequenceSetupFiles, bh as SequenceHooks, bp as PrettyFormatOptions, e as FakeTimersConfig, g as TestTagDefinition } from './config.d.B3YV4t0O.js';
3
3
  import { Writable } from 'node:stream';
4
- import { S as SerializedTestSpecification, B as BrowserTesterOptions, c as SourceModuleDiagnostic } from './browser.d.FGQ9_rK6.js';
4
+ import { S as SerializedTestSpecification, B as BrowserTesterOptions, c as SourceModuleDiagnostic } from './browser.d.C7tWgUvw.js';
5
5
  import * as chai from 'chai';
6
6
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
7
- import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.BH-r1bPu.js';
8
- import { O as OTELCarrier } from './rpc.d.Cft1biqy.js';
7
+ import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.CyJRpyfZ.js';
8
+ import { O as OTELCarrier } from './rpc.d.3FOhdFx8.js';
9
9
  import { MockedModule } from '@vitest/mocker';
10
- import { S as StackTraceParserOptions, a as RuntimeCoverageProviderModule } from './source-map.d.kzFtk_dj.js';
10
+ import { S as StackTraceParserOptions, a as RuntimeCoverageProviderModule } from './source-map.d.BkG8YK_3.js';
11
11
  import { CDPSession, BrowserCommands, MarkOptions } from 'vitest/browser';
12
12
  import path from 'node:path';
13
13
  import { Console } from 'node:console';
@@ -132,6 +132,10 @@ declare class TestCase extends ReportedTaskImplementation {
132
132
  */
133
133
  result(): TestResult;
134
134
  /**
135
+ * Individual results for every retry and repeat attempt.
136
+ */
137
+ attempts(): ReadonlyArray<TestAttempt>;
138
+ /**
135
139
  * Test annotations added via the `task.annotate` API during the test execution.
136
140
  */
137
141
  annotations(): ReadonlyArray<TestAnnotation>;
@@ -305,9 +309,27 @@ interface TaskOptions {
305
309
  readonly timeout: number | undefined;
306
310
  readonly mode: "run" | "only" | "skip" | "todo";
307
311
  }
308
- type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
312
+ type TestAttemptState = "skipped" | "failed" | "passed";
313
+ type TestSuiteState = TestAttemptState | "pending";
309
314
  type TestModuleState = TestSuiteState | "queued";
310
315
  type TestState = TestResult["state"];
316
+ /**
317
+ * The result of an individual test attempt.
318
+ */
319
+ interface TestAttempt {
320
+ /** The state after applying the test's expected failure option. */
321
+ readonly state: TestAttemptState;
322
+ /** Errors produced by this attempt. */
323
+ readonly errors: ReadonlyArray<TestError> | undefined;
324
+ /** How long in milliseconds the attempt took to run. */
325
+ readonly duration: number;
326
+ /** Time in milliseconds when the attempt started running. */
327
+ readonly startTime: number;
328
+ /** The zero-based retry index within the repeat. */
329
+ readonly retryIndex: number;
330
+ /** The zero-based repeat index. */
331
+ readonly repeatIndex: number;
332
+ }
311
333
  type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
312
334
  interface TestResultPending {
313
335
  /**
@@ -448,6 +470,7 @@ declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestM
448
470
  interface TestSpecificationOptions {
449
471
  testNamePattern?: RegExp;
450
472
  testIds?: string[];
473
+ testNames?: string[];
451
474
  testLines?: number[];
452
475
  testTagsFilter?: string[];
453
476
  }
@@ -481,6 +504,10 @@ declare class TestSpecification {
481
504
  */
482
505
  testIds: string[] | undefined;
483
506
  /**
507
+ * The full names of the tests inside of this specification to run, including the parent suites separated with `>`.
508
+ */
509
+ testNames: string[] | undefined;
510
+ /**
484
511
  * The tags of tests to run.
485
512
  */
486
513
  testTagsFilter: string[] | undefined;
@@ -544,14 +571,22 @@ type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
544
571
  interface _BrowserNames {}
545
572
  interface BrowserTraceViewOptions {
546
573
  /**
547
- * Enable Vitest trace view artifacts collection.
574
+ * @deprecated Use `mode` instead. `true` is the same as `mode: 'on'`.
575
+ */
576
+ enabled?: boolean;
577
+ /**
578
+ * How trace view records tests.
548
579
  *
549
- * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
580
+ * - `'on'`: every test gets a trace with a snapshot at every step, and Vitest UI shows steps live as tests run.
581
+ * - `'failure-only'`: only failed tests get a trace, with the full step timeline and a snapshot at the end.
582
+ * - `'off'`: no traces.
550
583
  *
551
- * @default false
584
+ * Takes precedence over `enabled`.
585
+ *
586
+ * @default 'failure-only'
552
587
  * @experimental
553
588
  */
554
- enabled?: boolean;
589
+ mode?: BrowserTraceViewRecordingMode;
555
590
  /**
556
591
  * Capture canvas pixels in trace view snapshots.
557
592
  *
@@ -559,7 +594,6 @@ interface BrowserTraceViewOptions {
559
594
  * In the trace viewer, this enables a weaker replay iframe sandbox because rrweb needs scripts to redraw canvas data.
560
595
  *
561
596
  * @default false
562
- * @experimental
563
597
  */
564
598
  recordCanvas?: boolean;
565
599
  /**
@@ -569,9 +603,17 @@ interface BrowserTraceViewOptions {
569
603
  * but can increase trace artifact size and does not preserve original image resource bytes.
570
604
  *
571
605
  * @default false
572
- * @experimental
573
606
  */
574
607
  inlineImages?: boolean;
608
+ /**
609
+ * Capture the accessibility tree alongside each trace view snapshot.
610
+ *
611
+ * The trace viewer's snapshot pane can then switch between "DOM" and "Aria" views.
612
+ *
613
+ * @default true
614
+ * @experimental
615
+ */
616
+ ariaSnapshot?: boolean;
575
617
  }
576
618
  type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
577
619
  interface BrowserInstanceOption extends Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
@@ -689,15 +731,16 @@ interface BrowserConfigOptions {
689
731
  snapshots?: boolean;
690
732
  };
691
733
  /**
734
+ * Records the actions, assertions, and marks of browser tests with DOM snapshots for the trace viewer.
692
735
  *
693
- * Enable Vitest trace view artifacts collection.
736
+ * - `'failure-only'`: records only failed tests.
737
+ * - `true` or `'on'`: records every test.
738
+ * - `false` or `'off'`: turns trace view off.
694
739
  *
695
- * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
696
- *
697
- * @default false
698
- * @experimental
740
+ * @default 'failure-only'
741
+ * @see {@link https://vitest.dev/guide/browser/trace-view}
699
742
  */
700
- traceView?: boolean | BrowserTraceViewOptions;
743
+ traceView?: boolean | BrowserTraceViewRecordingMode | BrowserTraceViewOptions;
701
744
  /**
702
745
  * Directory where screenshots will be saved when page.screenshot() is called
703
746
  * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
@@ -770,6 +813,19 @@ interface BrowserConfigOptions {
770
813
  * @default true
771
814
  */
772
815
  trackUnhandledErrors?: boolean;
816
+ /**
817
+ * Serve module mocks through an import map in the tester document instead of
818
+ * intercepting network requests.
819
+ *
820
+ * By default, Vitest checks once per browser whether it accepts an import map
821
+ * after a module has loaded (Chromium 133+, Safari 18.4+, Firefox 150+ with
822
+ * `dom.multiple_import_maps.enabled`, which the Playwright provider sets) and
823
+ * falls back to request interception otherwise. `true` fails in a browser that
824
+ * cannot, `false` always intercepts.
825
+ *
826
+ * @experimental
827
+ */
828
+ importMapMocks?: boolean;
773
829
  }
774
830
  interface BrowserCommandContext {
775
831
  testPath: string | undefined;
@@ -856,7 +912,7 @@ interface ProjectBrowser {
856
912
  close: () => Promise<void>;
857
913
  initBrowserProvider: (project: TestProject) => Promise<void>;
858
914
  closeBrowserProvider: (options?: BrowserProviderCloseOptions) => Promise<void>;
859
- parseStacktrace: (stack: string) => ParsedStack[];
915
+ parseStacktrace: (stack: string, options?: StackTraceParserOptions) => ParsedStack[];
860
916
  parseErrorStacktrace: (error: TestError, options?: StackTraceParserOptions) => ParsedStack[];
861
917
  registerCommand: <K extends keyof BrowserCommands>(name: K, cb: BrowserCommand<Parameters<BrowserCommands[K]>, ReturnType<BrowserCommands[K]>>) => void;
862
918
  triggerCommand: <K extends keyof BrowserCommands>(name: K, context: BrowserCommandContext, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
@@ -1110,7 +1166,6 @@ declare class TestProject {
1110
1166
  * Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
1111
1167
  */
1112
1168
  matchesTestGlob(moduleId: string, source?: () => string): boolean;
1113
- private filterFiles;
1114
1169
  /**
1115
1170
  * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
1116
1171
  * If the resources are needed again, create a new project.
@@ -1654,6 +1709,8 @@ interface LinkMapper {
1654
1709
  relativePath(source: ReportNode | string, target: ReportNode | string): string;
1655
1710
  assetPath(node: ReportNode, name: string): string;
1656
1711
  }
1712
+ /** color themes of the html report, `legacy` being the classic istanbul colors */
1713
+ type HtmlTheme = "light" | "dark" | "legacy";
1657
1714
  /** options accepted by {@link HtmlReport} */
1658
1715
  interface HtmlOptions {
1659
1716
  /** show extra logging while the report is generated */
@@ -1664,11 +1721,17 @@ interface HtmlOptions {
1664
1721
  subdir?: string;
1665
1722
  /** skip nodes with no coverage */
1666
1723
  skipEmpty?: boolean;
1724
+ /**
1725
+ * fixes the report's theme and hides the theme picker; when unset, viewers
1726
+ * pick a theme in the report, which otherwise follows their light/dark
1727
+ * preference, or the page embedding the report, like Vitest UI
1728
+ */
1729
+ theme?: HtmlTheme;
1667
1730
  }
1668
1731
 
1669
1732
  //#region src/reports/html-spa/index.d.ts
1670
1733
  /** options accepted by {@link HtmlSpaReport} */
1671
- interface HtmlSpaOptions extends HtmlOptions {
1734
+ interface HtmlSpaOptions extends Omit<HtmlOptions, "theme"> {
1672
1735
  /** the metrics to show in the report UI, defaults to lines, branches and functions */
1673
1736
  metricsToShow?: ("lines" | "branches" | "functions" | "statements")[];
1674
1737
  }
@@ -1766,7 +1829,7 @@ interface CoverageProvider {
1766
1829
  /** Called with coverage results after a single test file has been run */
1767
1830
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
1768
1831
  /** Callback called when test run starts */
1769
- onTestRunStart?: () => void | Promise<void>;
1832
+ onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => void | Promise<void>;
1770
1833
  /** Callback called when test run fails due to test failures */
1771
1834
  onTestFailure?: () => void | Promise<void>;
1772
1835
  /** Callback to generate final coverage results */
@@ -1783,6 +1846,24 @@ interface CoverageProvider {
1783
1846
  * @experimental
1784
1847
  */
1785
1848
  requiresTransform?: (id: string) => boolean;
1849
+ /**
1850
+ * Version of the coverage provider. Can be used as cache key in various caching mechanisms.
1851
+ * @experimental
1852
+ */
1853
+ version?: string;
1854
+ /**
1855
+ * Return data that should be stored with the transformed module in `fsModuleCache`,
1856
+ * e.g. data collected in `onFileTransform`. The data must be JSON serializable.
1857
+ * When the module is later loaded from `fsModuleCache`, `onFileTransform` is not called.
1858
+ * The data is passed to `restoreModuleCacheData` instead.
1859
+ * @experimental
1860
+ */
1861
+ getModuleCacheData?: (environment: DevEnvironment, id: string) => unknown;
1862
+ /**
1863
+ * Called with the data returned by `getModuleCacheData` when the module is loaded from `fsModuleCache`.
1864
+ * @experimental
1865
+ */
1866
+ restoreModuleCacheData?: (environment: DevEnvironment, id: string, data: unknown) => void;
1786
1867
  /** Callback that's called when the coverage is enabled via a programmatic `enableCoverage` API. */
1787
1868
  onEnabled?: () => void | Promise<void>;
1788
1869
  }
@@ -1939,6 +2020,18 @@ interface CoverageOptions {
1939
2020
  */
1940
2021
  ignoreClassMethods?: string[];
1941
2022
  /**
2023
+ * Filter to ignore code from coverage based on its AST node.
2024
+ * Called only for nodes that Vitest's built-in filters don't already ignore.
2025
+ * Return `'ignore-this-and-nested-nodes'` to also ignore all nodes inside the given node.
2026
+ * Supported only by `v8` provider.
2027
+ *
2028
+ * @example
2029
+ * ```ts
2030
+ * ignoreNode: (node, type) => type === 'statement' && node.type === 'DebuggerStatement'
2031
+ * ```
2032
+ */
2033
+ ignoreNode?: (node: ESTree.Node, type: "function" | "statement" | "branch") => boolean | "ignore-this-and-nested-nodes" | void;
2034
+ /**
1942
2035
  * Custom instrumenter factory to use instead of the default `@vitest/istanbul-lib-instrument`.
1943
2036
  *
1944
2037
  * The factory receives the same runtime coverage options Vitest passes to its
@@ -2054,9 +2147,31 @@ interface TestRunResult {
2054
2147
  unhandledErrors: unknown[];
2055
2148
  }
2056
2149
 
2150
+ interface ModuleDependency {
2151
+ /**
2152
+ * Absolute path of the file.
2153
+ */
2154
+ file: string;
2155
+ /**
2156
+ * Start time of the oldest run that recorded the file, in milliseconds since the epoch.
2157
+ * A change after this time was not seen by every test file that depends on the file.
2158
+ * It is not set when the dependency comes from the static module graph.
2159
+ */
2160
+ recordedAt?: number;
2161
+ }
2162
+ interface ModulesResolver {
2163
+ /**
2164
+ * Every file whose change can affect the test files of the run.
2165
+ */
2166
+ getDependencies(): Promise<ModuleDependency[]>;
2167
+ }
2057
2168
  interface VCSProviderOptions {
2058
2169
  root: string;
2059
2170
  changedSince?: string | boolean;
2171
+ /**
2172
+ * Resolves the dependencies of the test files of the run.
2173
+ */
2174
+ resolver: ModulesResolver;
2060
2175
  }
2061
2176
  interface VCSProvider {
2062
2177
  findChangedFiles(options: VCSProviderOptions): Promise<string[]>;
@@ -2075,7 +2190,8 @@ declare class SnapshotManager {
2075
2190
 
2076
2191
  interface CachedTestFileResult {
2077
2192
  /**
2078
- * The file has a known failure. Only a complete run of the file clears it.
2193
+ * The file has a known failure.
2194
+ * A complete run of the file clears it, or a run in which every known failed test passes.
2079
2195
  */
2080
2196
  failed: boolean;
2081
2197
  /**
@@ -2088,6 +2204,11 @@ interface CachedTestFileResult {
2088
2204
  * It is not set if the file never ran completely.
2089
2205
  */
2090
2206
  lastRun?: number;
2207
+ /**
2208
+ * Full names of the tests that failed in the last run of the file. `--last-failed` runs only these tests.
2209
+ * It is not set if the failure happened outside of tests, for example in a hook or during collection.
2210
+ */
2211
+ failedTests?: string[];
2091
2212
  }
2092
2213
 
2093
2214
  declare class VitestCache {
@@ -2269,6 +2390,12 @@ declare class StateManager {
2269
2390
  cancelFiles(files: FileSpecification[], project: TestProject): void;
2270
2391
  }
2271
2392
 
2393
+ type EventName = "add" | "addDir" | "change" | "unlink" | "unlinkDir";
2394
+ type TrackEventName = EventName | "any";
2395
+ type Track = (filepath: string, options?: {
2396
+ timeout?: number;
2397
+ type?: TrackEventName;
2398
+ }) => Promise<void>;
2272
2399
  declare class VitestWatcher {
2273
2400
  private vitest;
2274
2401
  /**
@@ -2280,6 +2407,7 @@ declare class VitestWatcher {
2280
2407
  */
2281
2408
  readonly changedTests: Set<string>;
2282
2409
  private readonly _onRerun;
2410
+ private trackers;
2283
2411
  constructor(vitest: Vitest);
2284
2412
  close(): void;
2285
2413
  unregisterWatcher: () => void;
@@ -2294,6 +2422,13 @@ declare class VitestWatcher {
2294
2422
  * @returns A value indicating whether rerun is needed (changedTests was mutated)
2295
2423
  */
2296
2424
  private handleFileChanged;
2425
+ createTracker(): {
2426
+ track: Track;
2427
+ stop: () => void;
2428
+ };
2429
+ private track;
2430
+ private handleTrackEvent;
2431
+ private resolveTrackEvent;
2297
2432
  }
2298
2433
  interface WatcherTriggerPattern {
2299
2434
  pattern: RegExp;
@@ -2645,6 +2780,10 @@ interface CliOptions extends UserConfig {
2645
2780
  */
2646
2781
  run?: boolean;
2647
2782
  /**
2783
+ * Run only the tests that failed in the last run
2784
+ */
2785
+ lastFailed?: boolean;
2786
+ /**
2648
2787
  * Removes colors from the console output
2649
2788
  */
2650
2789
  color?: boolean;
@@ -2675,6 +2814,12 @@ interface CliOptions extends UserConfig {
2675
2814
  configLoader?: InlineConfig$1 extends {
2676
2815
  configLoader?: infer T;
2677
2816
  } ? T : never;
2817
+ /**
2818
+ * Run only the tests whose recorded dependencies were modified since the last run of the test,
2819
+ * and the tests that failed in their last run. Requires `cache`.
2820
+ * @experimental
2821
+ */
2822
+ sinceLastRun?: boolean;
2678
2823
  }
2679
2824
  /**
2680
2825
  * Start Vitest programmatically
@@ -2833,6 +2978,7 @@ declare abstract class BaseReporter implements Reporter {
2833
2978
  onServerRestart(reason?: string): void;
2834
2979
  reportSummary(files: File[], errors: unknown[]): void;
2835
2980
  private printSourceFilterSummary;
2981
+ private printLastFailedSummary;
2836
2982
  reportTestSummary(files: File[], errors: unknown[], leakCount: number): void;
2837
2983
  /**
2838
2984
  * Surfaces the cost of re-creating a DOM environment for every test file:
@@ -3507,7 +3653,8 @@ interface DepsOptions {
3507
3653
  */
3508
3654
  interopDefault?: boolean;
3509
3655
  /**
3510
- * A list of directories relative to the config file that should be treated as module directories.
3656
+ * A list of directories that contain dependencies. A file is a dependency if its path includes `/<directory>/`.
3657
+ * `node_modules` is always included.
3511
3658
  *
3512
3659
  * @default ['node_modules']
3513
3660
  */
@@ -3885,7 +4032,7 @@ interface InlineConfig {
3885
4032
  /**
3886
4033
  * Options for @sinon/fake-timers
3887
4034
  */
3888
- fakeTimers?: Config;
4035
+ fakeTimers?: FakeTimersConfig;
3889
4036
  /**
3890
4037
  * Custom handler for console.log in tests.
3891
4038
  *
@@ -4204,13 +4351,25 @@ interface InlineConfig {
4204
4351
  */
4205
4352
  nodeLoader?: boolean;
4206
4353
  /**
4207
- * Custom provider for detecting changed files. Used with the `--changed` flag
4354
+ * Record `expect.poll`, `vi.waitFor`, and `vi.waitUntil` steps of each test and print them as a timeline when the test fails.
4355
+ * Steps of passing tests are dropped without being reported.
4356
+ *
4357
+ * This has no effect in browser mode, which records its steps with `browser.traceView`.
4358
+ * @default false
4359
+ */
4360
+ traceTimeline?: boolean;
4361
+ /**
4362
+ * Provider for detecting changed files. Used with the `--changed` flag
4208
4363
  * to determine which files have been modified.
4209
4364
  *
4210
- * By default, Vitest uses Git to detect changed files. You can provide a custom
4211
- * implementation of the `VCSProvider` interface to use a different version control system.
4365
+ * - `'git'` (default) compares the working tree with the `--changed` reference.
4366
+ * - `'mtime'` compares the modification time of every recorded dependency with the run
4367
+ * that recorded it. It requires `experimental.recordDependencies`. The test files that
4368
+ * failed in their last run also run.
4369
+ *
4370
+ * You can also provide a custom implementation of the `VCSProvider` interface.
4212
4371
  */
4213
- vcsProvider?: VCSProvider | string;
4372
+ vcsProvider?: "git" | "mtime" | VCSProvider | (string & {});
4214
4373
  /**
4215
4374
  * Record the modules that every test file loads in the cache and use the records
4216
4375
  * with `--changed` and `--related` instead of walking the module graph statically.
@@ -4576,5 +4735,5 @@ interface VitestPluginContext {
4576
4735
  experimental_defineCacheKeyGenerator: (callback: CacheKeyIdGenerator) => void;
4577
4736
  }
4578
4737
 
4579
- export { Logger as L, MinimalReporter as M, PluginHarness as P, DefaultReporter as a8, TapFlatReporter as aG, TapReporter as aH, TestCase as aJ, TestCollection as aK, TestModule as aM, TestSuite as aY, DotReporter as aa, GithubActionsReporter as ac, HangingProcessReporter as ae, JUnitReporter as ah, JsonReporter as ak, ReportersMap as az, VerboseReporter as b2, VitestPackageInstaller as b4, experimental_getRunnerTask as b7, startVitest as b8, Vitest as f, CoverageMap as h, TestProject as j, TestSpecification as m, BaseReporter as r };
4580
- export type { CacheKeyIdGeneratorContext as $, ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserProvider as D, BrowserProviderCloseOptions as E, FieldsWithDefaultValues as F, BrowserProviderOption as G, BrowserScript as H, InlineConfig as I, BrowserServerContribution as J, BrowserServerFactory as K, BrowserServerState as N, BrowserServerStateSession as O, BrowserTraceViewOptions as Q, ResolvedConfig as R, BuiltinEnvironment as S, TestProjectConfiguration as T, UserWorkspaceConfig as U, VitestPluginContext as V, WatcherTriggerPattern as W, BuiltinReporterOptions as X, BuiltinReporters as Y, CSSModuleScopeStrategy as Z, CacheKeyIdGenerator as _, UserProjectConfigFn as a, ToMatchScreenshotOptions as a$, CachedTestFileResult as a0, CoverageInstrumenter as a1, CoverageIstanbulOptions as a2, CoverageProvider as a3, CoverageProviderModule as a4, CoverageReporter as a5, CoverageV8Options as a6, CustomProviderOptions as a7, DepsOptimizationOptions as a9, ResolveSnapshotPathHandler as aA, ResolveSnapshotPathHandlerContext as aB, ResolvedBrowserOptions as aC, ResolvedProjectConfig as aD, SerializedTestProject as aE, SuiteNameTemplateVariables as aF, TaskOptions as aI, TestDiagnostic as aL, TestModuleState as aN, TestResult as aO, TestResultFailed as aP, TestResultPassed as aQ, TestResultPending as aR, TestResultSkipped as aS, TestRunEndReason as aT, TestRunResult as aU, TestSequencerConstructor as aV, TestSpecificationOptions as aW, TestState as aX, TestSuiteState as aZ, ToMatchScreenshotComparators as a_, EnvironmentOptions as ab, HTMLOptions as ad, InstrumenterOptions as af, JUnitOptions as ag, JsonAssertionResult as ai, JsonOptions as aj, JsonTestResult as al, JsonTestResults as am, ModuleDiagnostic as an, OnServerRestartHandler as ao, OnTestsRerunHandler as ap, ParentProjectBrowser as aq, Pool as ar, PoolRunnerInitializer as as, PoolTask as at, ProjectBrowser as au, ProjectConfig as av, Report as aw, ReportedHookContext as ax, Reporter as ay, UserProjectConfigExport as b, TypecheckConfig as b0, UIOptions as b1, VitestEnvironment as b3, WorkerResponse as b5, _BrowserNames as b6, TestProjectInlineConfiguration as c, UserConfig as d, CliOptions as e, ResolvedCoverageOptions as g, ReportContext as i, VitestOptions as k, VitestRunMode as l, PoolWorker as n, PoolOptions as o, WorkerRequest as p, TestSequencer as q, BenchmarkUserOptions as s, BrowserBuiltinProvider as t, BrowserCommand as u, BrowserCommandContext as v, BrowserConfigOptions as w, BrowserInstanceOption as x, BrowserModuleMocker as y, BrowserOrchestrator as z };
4738
+ export { Logger as L, MinimalReporter as M, PluginHarness as P, ReportersMap as aD, TapFlatReporter as aK, TapReporter as aL, TestCase as aP, TestCollection as aQ, TestModule as aS, DefaultReporter as aa, DotReporter as ac, GithubActionsReporter as ae, HangingProcessReporter as ag, JUnitReporter as aj, JsonReporter as am, TestSuite as b2, VerboseReporter as b8, VitestPackageInstaller as ba, experimental_getRunnerTask as bd, startVitest as be, Vitest as f, CoverageMap as h, TestSpecification as i, TestProject as k, BaseReporter as t };
4739
+ export type { CSSModuleScopeStrategy as $, ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserModuleMocker as D, BrowserOrchestrator as E, FieldsWithDefaultValues as F, BrowserProvider as G, BrowserProviderCloseOptions as H, InlineConfig as I, BrowserProviderOption as J, BrowserScript as K, BrowserServerContribution as N, BrowserServerFactory as O, BrowserServerState as Q, ResolvedConfig as R, BrowserServerStateSession as S, TestProjectConfiguration as T, UserWorkspaceConfig as U, VitestPluginContext as V, WatcherTriggerPattern as W, BrowserTraceViewOptions as X, BuiltinEnvironment as Y, BuiltinReporterOptions as Z, BuiltinReporters as _, UserProjectConfigFn as a, TestSequencerConstructor as a$, CacheKeyIdGenerator as a0, CacheKeyIdGeneratorContext as a1, CachedTestFileResult as a2, CoverageInstrumenter as a3, CoverageIstanbulOptions as a4, CoverageProvider as a5, CoverageProviderModule as a6, CoverageReporter as a7, CoverageV8Options as a8, CustomProviderOptions as a9, Report as aA, ReportedHookContext as aB, Reporter as aC, ResolveSnapshotPathHandler as aE, ResolveSnapshotPathHandlerContext as aF, ResolvedBrowserOptions as aG, ResolvedProjectConfig as aH, SerializedTestProject as aI, SuiteNameTemplateVariables as aJ, TaskOptions as aM, TestAttempt as aN, TestAttemptState as aO, TestDiagnostic as aR, TestModuleState as aT, TestResult as aU, TestResultFailed as aV, TestResultPassed as aW, TestResultPending as aX, TestResultSkipped as aY, TestRunEndReason as aZ, TestRunResult as a_, DepsOptimizationOptions as ab, EnvironmentOptions as ad, HTMLOptions as af, InstrumenterOptions as ah, JUnitOptions as ai, JsonAssertionResult as ak, JsonOptions as al, JsonTestResult as an, JsonTestResults as ao, ModuleDependency as ap, ModuleDiagnostic as aq, ModulesResolver as ar, OnServerRestartHandler as as, OnTestsRerunHandler as at, ParentProjectBrowser as au, Pool as av, PoolRunnerInitializer as aw, PoolTask as ax, ProjectBrowser as ay, ProjectConfig as az, UserProjectConfigExport as b, TestSpecificationOptions as b0, TestState as b1, TestSuiteState as b3, ToMatchScreenshotComparators as b4, ToMatchScreenshotOptions as b5, TypecheckConfig as b6, UIOptions as b7, VitestEnvironment as b9, WorkerResponse as bb, _BrowserNames as bc, TestProjectInlineConfiguration as c, UserConfig as d, CliOptions as e, ResolvedCoverageOptions as g, ReportContext as j, VitestOptions as l, VitestRunMode as m, VCSProvider as n, VCSProviderOptions as o, PoolWorker as p, PoolOptions as q, WorkerRequest as r, TestSequencer as s, BenchmarkUserOptions as u, BrowserBuiltinProvider as v, BrowserCommand as w, BrowserCommandContext as x, BrowserConfigOptions as y, BrowserInstanceOption as z };