vitest 3.0.8 → 3.1.0-beta.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.
Files changed (60) hide show
  1. package/dist/browser.d.ts +12 -23
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{base.XvKTsMeK.js → base.DV59CbtV.js} +1 -1
  4. package/dist/chunks/{benchmark.Cdu9hjj4.js → benchmark.DL72EVN-.js} +1 -1
  5. package/dist/chunks/{benchmark.CFFwLv-O.d.ts → benchmark.d.BwvBVTda.d.ts} +11 -11
  6. package/dist/chunks/{cac.VN5q-TPC.js → cac.BjmXy7OV.js} +11 -6
  7. package/dist/chunks/{cli-api.Dis64jtY.js → cli-api.BwkkJsRe.js} +13 -8
  8. package/dist/chunks/config.d.DevWltVl.d.ts +218 -0
  9. package/dist/chunks/{constants.fzPh7AOq.js → constants.DTYd6dNH.js} +1 -1
  10. package/dist/chunks/{coverage.DnNIv-kJ.js → coverage.A3sS5-Wm.js} +1 -29
  11. package/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
  12. package/dist/chunks/{resolveConfig.L1_HR0_0.js → coverage.gV8doR2Y.js} +496 -127
  13. package/dist/chunks/{creator.2CFRE1Yx.js → creator.BsBnpTzI.js} +1 -1
  14. package/dist/chunks/defaults.C2Ndd9wx.js +119 -0
  15. package/dist/chunks/env.D4Lgay0q.js +8 -0
  16. package/dist/chunks/environment.d.C8UItCbf.d.ts +170 -0
  17. package/dist/chunks/global.d.Cg2sEPIm.d.ts +127 -0
  18. package/dist/chunks/{globals.CydvVTgC.js → globals.BEpDe-k3.js} +4 -4
  19. package/dist/chunks/{index.CNRemkXW.js → index.D7Ny8f_s.js} +2 -2
  20. package/dist/chunks/{index.B7vJpkTD.js → index.DOyx6FYJ.js} +48 -18
  21. package/dist/chunks/{index.BmFgJtkv.js → index.uXkkC4xl.js} +1 -2
  22. package/dist/chunks/{mocker.cRtM890J.d.ts → mocker.d.BE_2ls6u.d.ts} +6 -6
  23. package/dist/chunks/reporters.d.r7poTZjA.d.ts +3012 -0
  24. package/dist/chunks/{runBaseTests.DnaAUBKD.js → runBaseTests.BVrL_ow3.js} +8 -8
  25. package/dist/chunks/{setup-common.Uaw6Zgv9.js → setup-common.CPvtqi8q.js} +25 -2
  26. package/dist/chunks/{suite.qtkXWc6R.d.ts → suite.d.FvehnV49.d.ts} +1 -1
  27. package/dist/chunks/{typechecker.cZ0LjdSi.js → typechecker.BlF3eHsb.js} +2 -7
  28. package/dist/chunks/{vi.B5EKKJdE.js → vi.nSCvwQ7l.js} +3 -3
  29. package/dist/chunks/vite.d.Fvq-NZoa.d.ts +11 -0
  30. package/dist/chunks/{worker.BmVno_ab.d.ts → worker.d.C58isfFm.d.ts} +62 -62
  31. package/dist/chunks/{worker.BT4v-DKx.d.ts → worker.d.CSFlSYJg.d.ts} +2 -2
  32. package/dist/cli.js +2 -2
  33. package/dist/config.d.ts +48 -45
  34. package/dist/config.js +6 -123
  35. package/dist/coverage.d.ts +82 -79
  36. package/dist/coverage.js +19 -469
  37. package/dist/environments.d.ts +11 -11
  38. package/dist/execute.d.ts +109 -109
  39. package/dist/index.d.ts +414 -412
  40. package/dist/index.js +3 -3
  41. package/dist/node.d.ts +51 -48
  42. package/dist/node.js +13 -10
  43. package/dist/reporters.d.ts +7 -4
  44. package/dist/reporters.js +3 -2
  45. package/dist/runners.d.ts +28 -28
  46. package/dist/runners.js +2 -3
  47. package/dist/snapshot.d.ts +2 -2
  48. package/dist/suite.d.ts +2 -2
  49. package/dist/suite.js +1 -1
  50. package/dist/workers/forks.js +1 -1
  51. package/dist/workers/runVmTests.js +8 -8
  52. package/dist/workers/threads.js +1 -1
  53. package/dist/workers.d.ts +13 -13
  54. package/dist/workers.js +1 -1
  55. package/package.json +11 -11
  56. package/dist/chunks/config.BCv-fVdT.d.ts +0 -215
  57. package/dist/chunks/environment.d8YfPkTm.d.ts +0 -173
  58. package/dist/chunks/global.CnI8_G5V.d.ts +0 -133
  59. package/dist/chunks/reporters.66aFHiyX.d.ts +0 -3051
  60. package/dist/chunks/vite.BCQa3xFG.d.ts +0 -11
@@ -0,0 +1,119 @@
1
+ import nodeos__default from 'node:os';
2
+ import './env.D4Lgay0q.js';
3
+ import { isCI } from 'std-env';
4
+
5
+ const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
6
+ const defaultExclude = [
7
+ "**/node_modules/**",
8
+ "**/dist/**",
9
+ "**/cypress/**",
10
+ "**/.{idea,git,cache,output,temp}/**",
11
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
12
+ ];
13
+ const benchmarkConfigDefaults = {
14
+ include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
15
+ exclude: defaultExclude,
16
+ includeSource: [],
17
+ reporters: ["default"],
18
+ includeSamples: false
19
+ };
20
+ const defaultCoverageExcludes = [
21
+ "coverage/**",
22
+ "dist/**",
23
+ "**/node_modules/**",
24
+ "**/[.]**",
25
+ "packages/*/test?(s)/**",
26
+ "**/*.d.ts",
27
+ "**/virtual:*",
28
+ "**/__x00__*",
29
+ "**/\0*",
30
+ "cypress/**",
31
+ "test?(s)/**",
32
+ "test?(-*).?(c|m)[jt]s?(x)",
33
+ "**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)",
34
+ "**/__tests__/**",
35
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
36
+ "**/vitest.{workspace,projects}.[jt]s?(on)",
37
+ "**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
38
+ ];
39
+ const coverageConfigDefaults = {
40
+ provider: "v8",
41
+ enabled: false,
42
+ all: true,
43
+ clean: true,
44
+ cleanOnRerun: true,
45
+ reportsDirectory: "./coverage",
46
+ exclude: defaultCoverageExcludes,
47
+ reportOnFailure: false,
48
+ reporter: [
49
+ ["text", {}],
50
+ ["html", {}],
51
+ ["clover", {}],
52
+ ["json", {}]
53
+ ],
54
+ extension: [
55
+ ".js",
56
+ ".cjs",
57
+ ".mjs",
58
+ ".ts",
59
+ ".mts",
60
+ ".tsx",
61
+ ".jsx",
62
+ ".vue",
63
+ ".svelte",
64
+ ".marko",
65
+ ".astro"
66
+ ],
67
+ allowExternal: false,
68
+ excludeAfterRemap: false,
69
+ ignoreEmptyLines: true,
70
+ processingConcurrency: Math.min(
71
+ 20,
72
+ nodeos__default.availableParallelism?.() ?? nodeos__default.cpus().length
73
+ )
74
+ };
75
+ const fakeTimersDefaults = {
76
+ loopLimit: 1e4,
77
+ shouldClearNativeTimers: true
78
+ };
79
+ const configDefaults = Object.freeze({
80
+ allowOnly: !isCI,
81
+ isolate: true,
82
+ watch: !isCI,
83
+ globals: false,
84
+ environment: "node",
85
+ pool: "forks",
86
+ clearMocks: false,
87
+ restoreMocks: false,
88
+ mockReset: false,
89
+ unstubGlobals: false,
90
+ unstubEnvs: false,
91
+ include: defaultInclude,
92
+ exclude: defaultExclude,
93
+ teardownTimeout: 1e4,
94
+ forceRerunTriggers: ["**/package.json/**", "**/{vitest,vite}.config.*/**"],
95
+ update: false,
96
+ reporters: [],
97
+ silent: false,
98
+ hideSkippedTests: false,
99
+ api: false,
100
+ ui: false,
101
+ uiBase: "/__vitest__/",
102
+ open: !isCI,
103
+ css: {
104
+ include: []
105
+ },
106
+ coverage: coverageConfigDefaults,
107
+ fakeTimers: fakeTimersDefaults,
108
+ maxConcurrency: 5,
109
+ dangerouslyIgnoreUnhandledErrors: false,
110
+ typecheck: {
111
+ checker: "tsc",
112
+ include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
113
+ exclude: defaultExclude
114
+ },
115
+ slowTestThreshold: 300,
116
+ disableConsoleIntercept: false
117
+ });
118
+
119
+ export { coverageConfigDefaults as a, defaultInclude as b, configDefaults as c, defaultExclude as d, benchmarkConfigDefaults as e };
@@ -0,0 +1,8 @@
1
+ import { isCI } from 'std-env';
2
+
3
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
4
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
5
+ const isWindows = (isNode || isDeno) && process.platform === "win32";
6
+ const isTTY = (isNode || isDeno) && process.stdout?.isTTY && !isCI;
7
+
8
+ export { isWindows as a, isTTY as i };
@@ -0,0 +1,170 @@
1
+ type Awaitable<T> = T | PromiseLike<T>;
2
+ type Nullable<T> = T | null | undefined;
3
+ type Arrayable<T> = T | Array<T>;
4
+ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
5
+ type MutableArray<T extends readonly any[]> = { -readonly [k in keyof T] : T[k] };
6
+ interface Constructable {
7
+ new (...args: any[]): any;
8
+ }
9
+ type TransformMode = "web" | "ssr";
10
+ /** @deprecated not used */
11
+ interface ModuleCache {
12
+ promise?: Promise<any>;
13
+ exports?: any;
14
+ code?: string;
15
+ }
16
+ interface AfterSuiteRunMeta {
17
+ coverage?: unknown;
18
+ testFiles: string[];
19
+ transformMode: TransformMode | "browser";
20
+ projectName?: string;
21
+ }
22
+ interface UserConsoleLog {
23
+ content: string;
24
+ origin?: string;
25
+ browser?: boolean;
26
+ type: "stdout" | "stderr";
27
+ taskId?: string;
28
+ time: number;
29
+ size: number;
30
+ }
31
+ interface ModuleGraphData {
32
+ graph: Record<string, string[]>;
33
+ externalized: string[];
34
+ inlined: string[];
35
+ }
36
+ interface ProvidedContext {}
37
+
38
+ /**
39
+ * Happy DOM options.
40
+ */
41
+ interface HappyDOMOptions {
42
+ width?: number;
43
+ height?: number;
44
+ url?: string;
45
+ settings?: {
46
+ disableJavaScriptEvaluation?: boolean
47
+ disableJavaScriptFileLoading?: boolean
48
+ disableCSSFileLoading?: boolean
49
+ disableIframePageLoading?: boolean
50
+ disableComputedStyleRendering?: boolean
51
+ enableFileSystemHttpRequests?: boolean
52
+ navigator?: {
53
+ userAgent?: string
54
+ }
55
+ device?: {
56
+ prefersColorScheme?: string
57
+ mediaType?: string
58
+ }
59
+ };
60
+ }
61
+
62
+ interface JSDOMOptions {
63
+ /**
64
+ * The html content for the test.
65
+ *
66
+ * @default '<!DOCTYPE html>'
67
+ */
68
+ html?: string | ArrayBufferLike;
69
+ /**
70
+ * referrer just affects the value read from document.referrer.
71
+ * It defaults to no referrer (which reflects as the empty string).
72
+ */
73
+ referrer?: string;
74
+ /**
75
+ * userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
76
+ *
77
+ * @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
78
+ */
79
+ userAgent?: string;
80
+ /**
81
+ * url sets the value returned by window.location, document.URL, and document.documentURI,
82
+ * and affects things like resolution of relative URLs within the document
83
+ * and the same-origin restrictions and referrer used while fetching subresources.
84
+ *
85
+ * @default 'http://localhost:3000'.
86
+ */
87
+ url?: string;
88
+ /**
89
+ * contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
90
+ * Values that are not "text/html" or an XML mime type will throw.
91
+ *
92
+ * @default 'text/html'.
93
+ */
94
+ contentType?: string;
95
+ /**
96
+ * The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
97
+ * Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
98
+ * to 5,000,000 code units per origin, as inspired by the HTML specification.
99
+ *
100
+ * @default 5_000_000
101
+ */
102
+ storageQuota?: number;
103
+ /**
104
+ * Enable console?
105
+ *
106
+ * @default false
107
+ */
108
+ console?: boolean;
109
+ /**
110
+ * jsdom does not have the capability to render visual content, and will act like a headless browser by default.
111
+ * It provides hints to web pages through APIs such as document.hidden that their content is not visible.
112
+ *
113
+ * When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
114
+ * content.
115
+ *
116
+ * @default true
117
+ */
118
+ pretendToBeVisual?: boolean;
119
+ /**
120
+ * `includeNodeLocations` preserves the location info produced by the HTML parser,
121
+ * allowing you to retrieve it with the nodeLocation() method (described below).
122
+ *
123
+ * It defaults to false to give the best performance,
124
+ * and cannot be used with an XML content type since our XML parser does not support location info.
125
+ *
126
+ * @default false
127
+ */
128
+ includeNodeLocations?: boolean | undefined;
129
+ /**
130
+ * @default 'dangerously'
131
+ */
132
+ runScripts?: "dangerously" | "outside-only";
133
+ /**
134
+ * Enable CookieJar
135
+ *
136
+ * @default false
137
+ */
138
+ cookieJar?: boolean;
139
+ resources?: "usable";
140
+ }
141
+
142
+ interface EnvironmentReturn {
143
+ teardown: (global: any) => Awaitable<void>;
144
+ }
145
+ interface VmEnvironmentReturn {
146
+ getVmContext: () => {
147
+ [key: string]: any
148
+ };
149
+ teardown: () => Awaitable<void>;
150
+ }
151
+ interface Environment {
152
+ name: string;
153
+ transformMode: "web" | "ssr";
154
+ setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
155
+ setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
156
+ }
157
+ interface EnvironmentOptions {
158
+ /**
159
+ * jsdom options.
160
+ */
161
+ jsdom?: JSDOMOptions;
162
+ happyDOM?: HappyDOMOptions;
163
+ [x: string]: unknown;
164
+ }
165
+ interface ResolvedTestEnvironment {
166
+ environment: Environment;
167
+ options: Record<string, any> | null;
168
+ }
169
+
170
+ export type { AfterSuiteRunMeta as A, Constructable as C, Environment as E, HappyDOMOptions as H, JSDOMOptions as J, ModuleGraphData as M, Nullable as N, ProvidedContext as P, ResolvedTestEnvironment as R, TransformMode as T, UserConsoleLog as U, VmEnvironmentReturn as V, EnvironmentReturn as a, Awaitable as b, Arrayable as c, ArgumentsType as d, MutableArray as e, EnvironmentOptions as f, ModuleCache as g };
@@ -0,0 +1,127 @@
1
+ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
+ import { Plugin } from '@vitest/pretty-format';
3
+ import { SnapshotState } from '@vitest/snapshot';
4
+ import { B as BenchmarkResult } from './benchmark.d.BwvBVTda.js';
5
+ import { U as UserConsoleLog } from './environment.d.C8UItCbf.js';
6
+
7
+ type RawErrsMap = Map<string, TscErrorInfo[]>;
8
+ interface TscErrorInfo {
9
+ filePath: string;
10
+ errCode: number;
11
+ errMsg: string;
12
+ line: number;
13
+ column: number;
14
+ }
15
+ interface CollectLineNumbers {
16
+ target: number;
17
+ next: number;
18
+ prev?: number;
19
+ }
20
+ type CollectLines = { [key in keyof CollectLineNumbers] : string };
21
+ interface RootAndTarget {
22
+ root: string;
23
+ targetAbsPath: string;
24
+ }
25
+ type Context = RootAndTarget & {
26
+ rawErrsMap: RawErrsMap
27
+ openedDirs: Set<string>
28
+ lastActivePath?: string
29
+ };
30
+
31
+ declare global {
32
+ namespace Chai {
33
+ interface Assertion {
34
+ containSubset: (expected: any) => Assertion;
35
+ }
36
+ interface Assert {
37
+ containSubset: (val: any, exp: any, msg?: string) => void;
38
+ }
39
+ }
40
+ }
41
+ interface SnapshotMatcher<T> {
42
+ <U extends { [P in keyof T] : any }>(snapshot: Partial<U>, message?: string): void;
43
+ (message?: string): void;
44
+ }
45
+ interface InlineSnapshotMatcher<T> {
46
+ <U extends { [P in keyof T] : any }>(properties: Partial<U>, snapshot?: string, message?: string): void;
47
+ (message?: string): void;
48
+ }
49
+ declare module "@vitest/expect" {
50
+ interface MatcherState {
51
+ environment: string;
52
+ snapshotState: SnapshotState;
53
+ }
54
+ interface ExpectPollOptions {
55
+ interval?: number;
56
+ timeout?: number;
57
+ message?: string;
58
+ }
59
+ interface ExpectStatic {
60
+ unreachable: (message?: string) => never;
61
+ soft: <T>(actual: T, message?: string) => Assertion<T>;
62
+ poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
63
+ addEqualityTesters: (testers: Array<Tester>) => void;
64
+ assertions: (expected: number) => void;
65
+ hasAssertions: () => void;
66
+ addSnapshotSerializer: (plugin: Plugin) => void;
67
+ }
68
+ interface Assertion<T> {
69
+ matchSnapshot: SnapshotMatcher<T>;
70
+ toMatchSnapshot: SnapshotMatcher<T>;
71
+ toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
72
+ /**
73
+ * Checks that an error thrown by a function matches a previously recorded snapshot.
74
+ *
75
+ * @param message - Optional custom error message.
76
+ *
77
+ * @example
78
+ * expect(functionWithError).toThrowErrorMatchingSnapshot();
79
+ */
80
+ toThrowErrorMatchingSnapshot: (message?: string) => void;
81
+ /**
82
+ * Checks that an error thrown by a function matches an inline snapshot within the test file.
83
+ * Useful for keeping snapshots close to the test code.
84
+ *
85
+ * @param snapshot - Optional inline snapshot string to match.
86
+ * @param message - Optional custom error message.
87
+ *
88
+ * @example
89
+ * const throwError = () => { throw new Error('Error occurred') };
90
+ * expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
91
+ */
92
+ toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
93
+ /**
94
+ * Compares the received value to a snapshot saved in a specified file.
95
+ * Useful for cases where snapshot content is large or needs to be shared across tests.
96
+ *
97
+ * @param filepath - Path to the snapshot file.
98
+ * @param message - Optional custom error message.
99
+ *
100
+ * @example
101
+ * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
102
+ */
103
+ toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
104
+ }
105
+ }
106
+ declare module "@vitest/runner" {
107
+ interface TestContext {
108
+ expect: ExpectStatic;
109
+ }
110
+ interface TaskMeta {
111
+ typecheck?: boolean;
112
+ benchmark?: boolean;
113
+ failScreenshotPath?: string;
114
+ }
115
+ interface File {
116
+ prepareDuration?: number;
117
+ environmentLoad?: number;
118
+ }
119
+ interface TaskBase {
120
+ logs?: UserConsoleLog[];
121
+ }
122
+ interface TaskResult {
123
+ benchmark?: BenchmarkResult;
124
+ }
125
+ }
126
+
127
+ export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };
@@ -1,6 +1,6 @@
1
- import { g as globalApis } from './constants.fzPh7AOq.js';
2
- import { V as VitestIndex } from './index.CNRemkXW.js';
3
- import './vi.B5EKKJdE.js';
1
+ import { g as globalApis } from './constants.DTYd6dNH.js';
2
+ import { V as VitestIndex } from './index.D7Ny8f_s.js';
3
+ import './vi.nSCvwQ7l.js';
4
4
  import '@vitest/expect';
5
5
  import '@vitest/runner';
6
6
  import '@vitest/runner/utils';
@@ -14,7 +14,7 @@ import '@vitest/spy';
14
14
  import '@vitest/utils/source-map';
15
15
  import './date.W2xKR2qe.js';
16
16
  import './run-once.2ogXb3JV.js';
17
- import './benchmark.Cdu9hjj4.js';
17
+ import './benchmark.DL72EVN-.js';
18
18
  import 'expect-type';
19
19
 
20
20
  function registerApiGlobally() {
@@ -1,6 +1,6 @@
1
- import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.B5EKKJdE.js';
1
+ import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.nSCvwQ7l.js';
2
2
  import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
3
- import { b as bench } from './benchmark.Cdu9hjj4.js';
3
+ import { b as bench } from './benchmark.DL72EVN-.js';
4
4
  import { expectTypeOf } from 'expect-type';
5
5
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
6
  import * as chai from 'chai';
@@ -8,7 +8,8 @@ import { stripVTControlCharacters } from 'node:util';
8
8
  import { positionToOffset, lineSplitRE, isPrimitive, inspect, toArray, notNullish } from '@vitest/utils';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
11
- import { T as TypeCheckError, g as getOutputFile, i as isTTY, h as hasFailedSnapshot } from './typechecker.cZ0LjdSi.js';
11
+ import { i as isTTY } from './env.D4Lgay0q.js';
12
+ import { T as TypeCheckError, g as getOutputFile, h as hasFailedSnapshot } from './typechecker.BlF3eHsb.js';
12
13
  import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
13
14
  import { Console } from 'node:console';
14
15
  import { Writable } from 'node:stream';
@@ -299,6 +300,9 @@ const skipErrorProperties = /* @__PURE__ */ new Set([
299
300
  "actual",
300
301
  "expected",
301
302
  "diffOptions",
303
+ "sourceURL",
304
+ "column",
305
+ "line",
302
306
  "VITEST_TEST_NAME",
303
307
  "VITEST_TEST_PATH",
304
308
  "VITEST_AFTER_ENV_TEARDOWN",
@@ -626,6 +630,28 @@ class BaseReporter {
626
630
  this.reportSummary(files, errors);
627
631
  }
628
632
  }
633
+ onTestCaseResult(testCase) {
634
+ if (testCase.result().state === "failed") {
635
+ this.logFailedTask(testCase.task);
636
+ }
637
+ }
638
+ onTestSuiteResult(testSuite) {
639
+ if (testSuite.state() === "failed") {
640
+ this.logFailedTask(testSuite.task);
641
+ }
642
+ }
643
+ onTestModuleEnd(testModule) {
644
+ if (testModule.state() === "failed") {
645
+ this.logFailedTask(testModule.task);
646
+ }
647
+ }
648
+ logFailedTask(task) {
649
+ if (this.ctx.config.silent === "passed-only") {
650
+ for (const log of task.logs || []) {
651
+ this.onUserConsoleLog(log, "failed");
652
+ }
653
+ }
654
+ }
629
655
  onTaskUpdate(packs) {
630
656
  for (const pack of packs) {
631
657
  const task = this.ctx.state.idMap.get(pack[0]);
@@ -672,7 +698,7 @@ class BaseReporter {
672
698
  for (const test of tests) {
673
699
  const { duration, retryCount, repeatCount } = test.result || {};
674
700
  const padding = this.getTestIndentation(test);
675
- let suffix2 = "";
701
+ let suffix2 = this.getDurationPrefix(test);
676
702
  if (retryCount != null && retryCount > 0) {
677
703
  suffix2 += c.yellow(` (retry x${retryCount})`);
678
704
  }
@@ -680,7 +706,7 @@ class BaseReporter {
680
706
  suffix2 += c.yellow(` (repeat x${repeatCount})`);
681
707
  }
682
708
  if (test.result?.state === "fail") {
683
- this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test, c.dim(" > "))}${this.getDurationPrefix(test)}`) + suffix2);
709
+ this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test, c.dim(" > "))}`) + suffix2);
684
710
  test.result?.errors?.forEach((error) => {
685
711
  const message = this.formatShortError(error);
686
712
  if (message) {
@@ -688,9 +714,7 @@ class BaseReporter {
688
714
  }
689
715
  });
690
716
  } else if (duration && duration > this.ctx.config.slowTestThreshold) {
691
- this.log(
692
- ` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test, c.dim(" > "))} ${c.yellow(Math.round(duration) + c.dim("ms"))}${suffix2}`
693
- );
717
+ this.log(` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test, c.dim(" > "))} ${suffix2}`);
694
718
  } else if (this.ctx.config.hideSkippedTests && (test.mode === "skip" || test.result?.state === "skip")) ; else if (test.result?.state === "skip" && test.result.note) {
695
719
  this.log(` ${padding}${getStateSymbol(test)} ${this.getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`);
696
720
  } else if (this.renderSucceed || failed.length > 0) {
@@ -714,7 +738,7 @@ class BaseReporter {
714
738
  if (!task.result?.duration) {
715
739
  return "";
716
740
  }
717
- const color = task.result.duration > this.ctx.config.slowTestThreshold ? c.yellow : c.gray;
741
+ const color = task.result.duration > this.ctx.config.slowTestThreshold ? c.yellow : c.green;
718
742
  return color(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
719
743
  }
720
744
  onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
@@ -766,8 +790,8 @@ class BaseReporter {
766
790
  this._timeStart = formatTimeString(/* @__PURE__ */ new Date());
767
791
  this.start = performance$1.now();
768
792
  }
769
- onUserConsoleLog(log) {
770
- if (!this.shouldLog(log)) {
793
+ onUserConsoleLog(log, taskState) {
794
+ if (!this.shouldLog(log, taskState)) {
771
795
  return;
772
796
  }
773
797
  const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
@@ -805,8 +829,11 @@ class BaseReporter {
805
829
  this.log(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
806
830
  `) : ""));
807
831
  }
808
- shouldLog(log) {
809
- if (this.ctx.config.silent) {
832
+ shouldLog(log, taskState) {
833
+ if (this.ctx.config.silent === true) {
834
+ return false;
835
+ }
836
+ if (this.ctx.config.silent === "passed-only" && taskState !== "failed") {
810
837
  return false;
811
838
  }
812
839
  const shouldLog = this.ctx.config.onConsoleLog?.(log.content, log.type);
@@ -1429,12 +1456,14 @@ class DefaultReporter extends BaseReporter {
1429
1456
  this.summary?.onTestModuleCollected(module);
1430
1457
  }
1431
1458
  onTestModuleEnd(module) {
1459
+ super.onTestModuleEnd(module);
1432
1460
  this.summary?.onTestModuleEnd(module);
1433
1461
  }
1434
1462
  onTestCaseReady(test) {
1435
1463
  this.summary?.onTestCaseReady(test);
1436
1464
  }
1437
1465
  onTestCaseResult(test) {
1466
+ super.onTestCaseResult(test);
1438
1467
  this.summary?.onTestCaseResult(test);
1439
1468
  }
1440
1469
  onHookStart(hook) {
@@ -1508,11 +1537,13 @@ class DotReporter extends BaseReporter {
1508
1537
  this.renderer?.schedule();
1509
1538
  }
1510
1539
  onTestCaseResult(test) {
1540
+ super.onTestCaseResult(test);
1511
1541
  this.finishedTests.add(test.id);
1512
1542
  this.tests.set(test.id, test.result().state || "skipped");
1513
1543
  this.renderer?.schedule();
1514
1544
  }
1515
- onTestModuleEnd() {
1545
+ onTestModuleEnd(testModule) {
1546
+ super.onTestModuleEnd(testModule);
1516
1547
  if (!this.isTTY) {
1517
1548
  return;
1518
1549
  }
@@ -2005,6 +2036,7 @@ class JUnitReporter {
2005
2036
  mode: "run",
2006
2037
  result: file.result,
2007
2038
  meta: {},
2039
+ timeout: 0,
2008
2040
  // NOTE: not used in JUnitReporter
2009
2041
  context: null,
2010
2042
  suite: null,
@@ -2184,15 +2216,12 @@ class VerboseReporter extends DefaultReporter {
2184
2216
  if (task.type !== "test" || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
2185
2217
  return;
2186
2218
  }
2187
- const duration = task.result.duration;
2188
2219
  let title = ` ${getStateSymbol(task)} `;
2189
2220
  if (task.file.projectName) {
2190
2221
  title += formatProjectName(task.file.projectName);
2191
2222
  }
2192
2223
  title += getFullName(task, c.dim(" > "));
2193
- if (duration != null && duration > this.ctx.config.slowTestThreshold) {
2194
- title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
2195
- }
2224
+ title += super.getDurationPrefix(task);
2196
2225
  if (this.ctx.config.logHeapUsage && task.result.heap != null) {
2197
2226
  title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
2198
2227
  }
@@ -2373,8 +2402,9 @@ ${padding}`;
2373
2402
  if (task.mode === "skip" || task.mode === "todo") {
2374
2403
  suffix += c.dim(c.gray(" [skipped]"));
2375
2404
  }
2376
- if (duration != null && duration > options.slowTestThreshold) {
2377
- suffix += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
2405
+ if (duration != null) {
2406
+ const color = duration > options.slowTestThreshold ? c.yellow : c.green;
2407
+ suffix += color(` ${Math.round(duration)}${c.dim("ms")}`);
2378
2408
  }
2379
2409
  if (options.showHeap && task.result?.heap != null) {
2380
2410
  suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
@@ -1,9 +1,8 @@
1
1
  import * as chai from 'chai';
2
2
  import { resolve } from 'node:path';
3
- import { t as takeCoverageInsideWorker } from './coverage.DnNIv-kJ.js';
3
+ import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.CPvtqi8q.js';
4
4
  import { distDir } from '../path.js';
5
5
  import { r as rpc } from './rpc.TVf73xOu.js';
6
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.Uaw6Zgv9.js';
7
6
  import { g as getWorkerState } from './utils.C8RiOc4B.js';
8
7
 
9
8
  function setupChaiConfig(config) {
@@ -4,14 +4,14 @@ type Promisable<T> = T | Promise<T>;
4
4
  type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
5
5
  type MockFactory = () => any;
6
6
  interface MockOptions {
7
- spy?: boolean;
7
+ spy?: boolean;
8
8
  }
9
9
  interface PendingSuiteMock {
10
- id: string;
11
- importer: string;
12
- action: 'mock' | 'unmock';
13
- type?: MockedModuleType;
14
- factory?: MockFactory;
10
+ id: string;
11
+ importer: string;
12
+ action: "mock" | "unmock";
13
+ type?: MockedModuleType;
14
+ factory?: MockFactory;
15
15
  }
16
16
 
17
17
  export type { MockFactoryWithHelper as M, PendingSuiteMock as P, MockOptions as a, MockFactory as b };