@vitest/runner 4.0.9 → 4.0.11
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/index.d.ts +39 -3
- package/dist/index.js +568 -451
- package/dist/{hooks.d-C0RE9A6t.d.ts → tasks.d-r9p5YKu0.d.ts} +244 -111
- package/dist/types.d.ts +11 -3
- package/dist/utils.d.ts +2 -2
- package/package.json +2 -2
|
@@ -14,6 +14,122 @@ interface FixtureItem extends FixtureOptions {
|
|
|
14
14
|
deps?: FixtureItem[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Registers a callback function to be executed once before all tests within the current suite.
|
|
19
|
+
* This hook is useful for scenarios where you need to perform setup operations that are common to all tests in a suite, such as initializing a database connection or setting up a test environment.
|
|
20
|
+
*
|
|
21
|
+
* **Note:** The `beforeAll` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
22
|
+
*
|
|
23
|
+
* @param {Function} fn - The callback function to be executed before all tests.
|
|
24
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // Example of using beforeAll to set up a database connection
|
|
29
|
+
* beforeAll(async () => {
|
|
30
|
+
* await database.connect();
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function beforeAll(fn: BeforeAllListener, timeout?: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Registers a callback function to be executed once after all tests within the current suite have completed.
|
|
37
|
+
* This hook is useful for scenarios where you need to perform cleanup operations after all tests in a suite have run, such as closing database connections or cleaning up temporary files.
|
|
38
|
+
*
|
|
39
|
+
* **Note:** The `afterAll` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
40
|
+
*
|
|
41
|
+
* @param {Function} fn - The callback function to be executed after all tests.
|
|
42
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
43
|
+
* @returns {void}
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // Example of using afterAll to close a database connection
|
|
47
|
+
* afterAll(async () => {
|
|
48
|
+
* await database.disconnect();
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function afterAll(fn: AfterAllListener, timeout?: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Registers a callback function to be executed before each test within the current suite.
|
|
55
|
+
* This hook is useful for scenarios where you need to reset or reinitialize the test environment before each test runs, such as resetting database states, clearing caches, or reinitializing variables.
|
|
56
|
+
*
|
|
57
|
+
* **Note:** The `beforeEach` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
58
|
+
*
|
|
59
|
+
* @param {Function} fn - The callback function to be executed before each test. This function receives an `TestContext` parameter if additional test context is needed.
|
|
60
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
61
|
+
* @returns {void}
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* // Example of using beforeEach to reset a database state
|
|
65
|
+
* beforeEach(async () => {
|
|
66
|
+
* await database.reset();
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function beforeEach<ExtraContext = object>(fn: BeforeEachListener<ExtraContext>, timeout?: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Registers a callback function to be executed after each test within the current suite has completed.
|
|
73
|
+
* This hook is useful for scenarios where you need to clean up or reset the test environment after each test runs, such as deleting temporary files, clearing test-specific database entries, or resetting mocked functions.
|
|
74
|
+
*
|
|
75
|
+
* **Note:** The `afterEach` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
76
|
+
*
|
|
77
|
+
* @param {Function} fn - The callback function to be executed after each test. This function receives an `TestContext` parameter if additional test context is needed.
|
|
78
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
79
|
+
* @returns {void}
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* // Example of using afterEach to delete temporary files created during a test
|
|
83
|
+
* afterEach(async () => {
|
|
84
|
+
* await fileSystem.deleteTempFiles();
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function afterEach<ExtraContext = object>(fn: AfterEachListener<ExtraContext>, timeout?: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Registers a callback function to be executed when a test fails within the current suite.
|
|
91
|
+
* This function allows for custom actions to be performed in response to test failures, such as logging, cleanup, or additional diagnostics.
|
|
92
|
+
*
|
|
93
|
+
* **Note:** The `onTestFailed` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
94
|
+
*
|
|
95
|
+
* @param {Function} fn - The callback function to be executed upon a test failure. The function receives the test result (including errors).
|
|
96
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
97
|
+
* @throws {Error} Throws an error if the function is not called within a test.
|
|
98
|
+
* @returns {void}
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* // Example of using onTestFailed to log failure details
|
|
102
|
+
* onTestFailed(({ errors }) => {
|
|
103
|
+
* console.log(`Test failed: ${test.name}`, errors);
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare const onTestFailed: TaskHook<OnTestFailedHandler>;
|
|
108
|
+
/**
|
|
109
|
+
* Registers a callback function to be executed when the current test finishes, regardless of the outcome (pass or fail).
|
|
110
|
+
* This function is ideal for performing actions that should occur after every test execution, such as cleanup, logging, or resetting shared resources.
|
|
111
|
+
*
|
|
112
|
+
* This hook is useful if you have access to a resource in the test itself and you want to clean it up after the test finishes. It is a more compact way to clean up resources than using the combination of `beforeEach` and `afterEach`.
|
|
113
|
+
*
|
|
114
|
+
* **Note:** The `onTestFinished` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
115
|
+
*
|
|
116
|
+
* **Note:** The `onTestFinished` hook is not called if the test is canceled with a dynamic `ctx.skip()` call.
|
|
117
|
+
*
|
|
118
|
+
* @param {Function} fn - The callback function to be executed after a test finishes. The function can receive parameters providing details about the completed test, including its success or failure status.
|
|
119
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
120
|
+
* @throws {Error} Throws an error if the function is not called within a test.
|
|
121
|
+
* @returns {void}
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* // Example of using onTestFinished for cleanup
|
|
125
|
+
* const db = await connectToDatabase();
|
|
126
|
+
* onTestFinished(async () => {
|
|
127
|
+
* await db.disconnect();
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare const onTestFinished: TaskHook<OnTestFinishedHandler>;
|
|
132
|
+
|
|
17
133
|
type ChainableFunction<
|
|
18
134
|
T extends string,
|
|
19
135
|
F extends (...args: any) => any,
|
|
@@ -178,9 +294,10 @@ interface ImportDuration {
|
|
|
178
294
|
type TaskResultPack = [id: string, result: TaskResult | undefined, meta: TaskMeta];
|
|
179
295
|
interface TaskEventData {
|
|
180
296
|
annotation?: TestAnnotation | undefined;
|
|
297
|
+
artifact?: TestArtifact | undefined;
|
|
181
298
|
}
|
|
182
299
|
type TaskEventPack = [id: string, event: TaskUpdateEvent, data: TaskEventData | undefined];
|
|
183
|
-
type TaskUpdateEvent = "test-failed-early" | "suite-failed-early" | "test-prepare" | "test-finished" | "test-retried" | "suite-prepare" | "suite-finished" | "before-hook-start" | "before-hook-end" | "after-hook-start" | "after-hook-end" | "test-annotation";
|
|
300
|
+
type TaskUpdateEvent = "test-failed-early" | "suite-failed-early" | "test-prepare" | "test-finished" | "test-retried" | "suite-prepare" | "suite-finished" | "before-hook-start" | "before-hook-end" | "after-hook-start" | "after-hook-end" | "test-annotation" | "test-artifact";
|
|
184
301
|
interface Suite extends TaskBase {
|
|
185
302
|
type: "suite";
|
|
186
303
|
/**
|
|
@@ -232,22 +349,12 @@ interface Test<ExtraContext = object> extends TaskPopulated {
|
|
|
232
349
|
* An array of custom annotations.
|
|
233
350
|
*/
|
|
234
351
|
annotations: TestAnnotation[];
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
interface TestAnnotationLocation {
|
|
242
|
-
line: number;
|
|
243
|
-
column: number;
|
|
244
|
-
file: string;
|
|
245
|
-
}
|
|
246
|
-
interface TestAnnotation {
|
|
247
|
-
message: string;
|
|
248
|
-
type: string;
|
|
249
|
-
location?: TestAnnotationLocation;
|
|
250
|
-
attachment?: TestAttachment;
|
|
352
|
+
/**
|
|
353
|
+
* An array of artifacts produced by the test.
|
|
354
|
+
*
|
|
355
|
+
* @experimental
|
|
356
|
+
*/
|
|
357
|
+
artifacts: TestArtifact[];
|
|
251
358
|
}
|
|
252
359
|
type Task = Test | Suite | File;
|
|
253
360
|
type TestFunction<ExtraContext = object> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
@@ -518,122 +625,148 @@ interface TaskHook<HookListener> {
|
|
|
518
625
|
}
|
|
519
626
|
type SequenceHooks = "stack" | "list" | "parallel";
|
|
520
627
|
type SequenceSetupFiles = "list" | "parallel";
|
|
521
|
-
|
|
522
628
|
/**
|
|
523
|
-
*
|
|
524
|
-
* This hook is useful for scenarios where you need to perform setup operations that are common to all tests in a suite, such as initializing a database connection or setting up a test environment.
|
|
525
|
-
*
|
|
526
|
-
* **Note:** The `beforeAll` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
629
|
+
* Represents a file or data attachment associated with a test artifact.
|
|
527
630
|
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* @returns {void}
|
|
531
|
-
* @example
|
|
532
|
-
* ```ts
|
|
533
|
-
* // Example of using beforeAll to set up a database connection
|
|
534
|
-
* beforeAll(async () => {
|
|
535
|
-
* await database.connect();
|
|
536
|
-
* });
|
|
537
|
-
* ```
|
|
631
|
+
* Attachments can be either file-based (via `path`) or inline content (via `body`).
|
|
632
|
+
* The `contentType` helps consumers understand how to interpret the attachment data.
|
|
538
633
|
*/
|
|
539
|
-
|
|
634
|
+
interface TestAttachment {
|
|
635
|
+
/** MIME type of the attachment (e.g., 'image/png', 'text/plain') */
|
|
636
|
+
contentType?: string;
|
|
637
|
+
/** File system path to the attachment */
|
|
638
|
+
path?: string;
|
|
639
|
+
/** Inline attachment content as a string or raw binary data */
|
|
640
|
+
body?: string | Uint8Array;
|
|
641
|
+
}
|
|
540
642
|
/**
|
|
541
|
-
*
|
|
542
|
-
* This hook is useful for scenarios where you need to perform cleanup operations after all tests in a suite have run, such as closing database connections or cleaning up temporary files.
|
|
543
|
-
*
|
|
544
|
-
* **Note:** The `afterAll` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
643
|
+
* Source code location information for a test artifact.
|
|
545
644
|
*
|
|
546
|
-
*
|
|
547
|
-
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
548
|
-
* @returns {void}
|
|
549
|
-
* @example
|
|
550
|
-
* ```ts
|
|
551
|
-
* // Example of using afterAll to close a database connection
|
|
552
|
-
* afterAll(async () => {
|
|
553
|
-
* await database.disconnect();
|
|
554
|
-
* });
|
|
555
|
-
* ```
|
|
645
|
+
* Indicates where in the source code the artifact originated from.
|
|
556
646
|
*/
|
|
557
|
-
|
|
647
|
+
interface TestArtifactLocation {
|
|
648
|
+
/** Line number in the source file (1-indexed) */
|
|
649
|
+
line: number;
|
|
650
|
+
/** Column number in the line (1-indexed) */
|
|
651
|
+
column: number;
|
|
652
|
+
/** Path to the source file */
|
|
653
|
+
file: string;
|
|
654
|
+
}
|
|
558
655
|
/**
|
|
559
|
-
*
|
|
560
|
-
* This hook is useful for scenarios where you need to reset or reinitialize the test environment before each test runs, such as resetting database states, clearing caches, or reinitializing variables.
|
|
656
|
+
* @experimental
|
|
561
657
|
*
|
|
562
|
-
*
|
|
658
|
+
* Base interface for all test artifacts.
|
|
563
659
|
*
|
|
564
|
-
*
|
|
565
|
-
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
566
|
-
* @returns {void}
|
|
567
|
-
* @example
|
|
568
|
-
* ```ts
|
|
569
|
-
* // Example of using beforeEach to reset a database state
|
|
570
|
-
* beforeEach(async () => {
|
|
571
|
-
* await database.reset();
|
|
572
|
-
* });
|
|
573
|
-
* ```
|
|
660
|
+
* Extend this interface when creating custom test artifacts. Vitest automatically manages the `attachments` array and injects the `location` property to indicate where the artifact was created in your test code.
|
|
574
661
|
*/
|
|
575
|
-
|
|
662
|
+
interface TestArtifactBase {
|
|
663
|
+
/** File or data attachments associated with this artifact */
|
|
664
|
+
attachments?: TestAttachment[];
|
|
665
|
+
/** Source location where this artifact was created */
|
|
666
|
+
location?: TestArtifactLocation;
|
|
667
|
+
}
|
|
576
668
|
/**
|
|
577
|
-
*
|
|
578
|
-
* This hook is useful for scenarios where you need to clean up or reset the test environment after each test runs, such as deleting temporary files, clearing test-specific database entries, or resetting mocked functions.
|
|
579
|
-
*
|
|
580
|
-
* **Note:** The `afterEach` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
669
|
+
* @deprecated Use {@linkcode TestArtifactLocation} instead.
|
|
581
670
|
*
|
|
582
|
-
*
|
|
583
|
-
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
584
|
-
* @returns {void}
|
|
585
|
-
* @example
|
|
586
|
-
* ```ts
|
|
587
|
-
* // Example of using afterEach to delete temporary files created during a test
|
|
588
|
-
* afterEach(async () => {
|
|
589
|
-
* await fileSystem.deleteTempFiles();
|
|
590
|
-
* });
|
|
591
|
-
* ```
|
|
671
|
+
* Kept for backwards compatibility.
|
|
592
672
|
*/
|
|
593
|
-
|
|
673
|
+
type TestAnnotationLocation = TestArtifactLocation;
|
|
674
|
+
interface TestAnnotation {
|
|
675
|
+
message: string;
|
|
676
|
+
type: string;
|
|
677
|
+
location?: TestArtifactLocation;
|
|
678
|
+
attachment?: TestAttachment;
|
|
679
|
+
}
|
|
594
680
|
/**
|
|
595
|
-
*
|
|
596
|
-
* This function allows for custom actions to be performed in response to test failures, such as logging, cleanup, or additional diagnostics.
|
|
597
|
-
*
|
|
598
|
-
* **Note:** The `onTestFailed` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
681
|
+
* @experimental
|
|
599
682
|
*
|
|
600
|
-
*
|
|
601
|
-
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
602
|
-
* @throws {Error} Throws an error if the function is not called within a test.
|
|
603
|
-
* @returns {void}
|
|
604
|
-
* @example
|
|
605
|
-
* ```ts
|
|
606
|
-
* // Example of using onTestFailed to log failure details
|
|
607
|
-
* onTestFailed(({ errors }) => {
|
|
608
|
-
* console.log(`Test failed: ${test.name}`, errors);
|
|
609
|
-
* });
|
|
610
|
-
* ```
|
|
683
|
+
* Artifact type for test annotations.
|
|
611
684
|
*/
|
|
612
|
-
|
|
685
|
+
interface TestAnnotationArtifact extends TestArtifactBase {
|
|
686
|
+
type: "internal:annotation";
|
|
687
|
+
annotation: TestAnnotation;
|
|
688
|
+
}
|
|
613
689
|
/**
|
|
614
|
-
*
|
|
615
|
-
*
|
|
690
|
+
* @experimental
|
|
691
|
+
* @advanced
|
|
616
692
|
*
|
|
617
|
-
*
|
|
693
|
+
* Registry for custom test artifact types.
|
|
618
694
|
*
|
|
619
|
-
*
|
|
695
|
+
* Augment this interface to register custom artifact types that your tests can produce.
|
|
620
696
|
*
|
|
621
|
-
*
|
|
697
|
+
* Each custom artifact should extend {@linkcode TestArtifactBase} and include a unique `type` discriminator property.
|
|
698
|
+
*
|
|
699
|
+
* @remarks
|
|
700
|
+
* - Use a `Symbol` as the **registry key** to guarantee uniqueness
|
|
701
|
+
* - The `type` property should follow the pattern `'package-name:artifact-name'`, `'internal:'` is a reserved prefix
|
|
702
|
+
* - Use `attachments` to include files or data; extend {@linkcode TestAttachment} for custom metadata
|
|
703
|
+
* - `location` property is automatically injected to indicate where the artifact was created
|
|
622
704
|
*
|
|
623
|
-
* @param {Function} fn - The callback function to be executed after a test finishes. The function can receive parameters providing details about the completed test, including its success or failure status.
|
|
624
|
-
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
625
|
-
* @throws {Error} Throws an error if the function is not called within a test.
|
|
626
|
-
* @returns {void}
|
|
627
705
|
* @example
|
|
628
|
-
*
|
|
629
|
-
* //
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
706
|
+
* ```ts
|
|
707
|
+
* // Define custom attachment type for generated PDF
|
|
708
|
+
* interface PDFAttachment extends TestAttachment {
|
|
709
|
+
* contentType: 'application/pdf'
|
|
710
|
+
* body: Uint8Array
|
|
711
|
+
* pageCount: number
|
|
712
|
+
* fileSize: number
|
|
713
|
+
* }
|
|
714
|
+
*
|
|
715
|
+
* interface PDFGenerationArtifact extends TestArtifactBase {
|
|
716
|
+
* type: 'my-plugin:pdf-generation'
|
|
717
|
+
* templateName: string
|
|
718
|
+
* isValid: boolean
|
|
719
|
+
* attachments: [PDFAttachment]
|
|
720
|
+
* }
|
|
721
|
+
*
|
|
722
|
+
* // Use a symbol to guarantee key uniqueness
|
|
723
|
+
* const pdfKey = Symbol('pdf-generation')
|
|
724
|
+
*
|
|
725
|
+
* declare module 'vitest' {
|
|
726
|
+
* interface TestArtifactRegistry {
|
|
727
|
+
* [pdfKey]: PDFGenerationArtifact
|
|
728
|
+
* }
|
|
729
|
+
* }
|
|
730
|
+
*
|
|
731
|
+
* // Custom assertion for PDF generation
|
|
732
|
+
* async function toGenerateValidPDF(
|
|
733
|
+
* this: MatcherState,
|
|
734
|
+
* actual: PDFTemplate,
|
|
735
|
+
* data: Record<string, unknown>
|
|
736
|
+
* ): AsyncExpectationResult {
|
|
737
|
+
* const pdfBuffer = await actual.render(data)
|
|
738
|
+
* const validation = await validatePDF(pdfBuffer)
|
|
739
|
+
*
|
|
740
|
+
* await recordArtifact(this.task, {
|
|
741
|
+
* type: 'my-plugin:pdf-generation',
|
|
742
|
+
* templateName: actual.name,
|
|
743
|
+
* isValid: validation.success,
|
|
744
|
+
* attachments: [{
|
|
745
|
+
* contentType: 'application/pdf',
|
|
746
|
+
* body: pdfBuffer,
|
|
747
|
+
* pageCount: validation.pageCount,
|
|
748
|
+
* fileSize: pdfBuffer.byteLength
|
|
749
|
+
* }]
|
|
750
|
+
* })
|
|
751
|
+
*
|
|
752
|
+
* return {
|
|
753
|
+
* pass: validation.success,
|
|
754
|
+
* message: () => validation.success
|
|
755
|
+
* ? `Generated valid PDF with ${validation.pageCount} pages`
|
|
756
|
+
* : `Invalid PDF: ${validation.error}`
|
|
757
|
+
* }
|
|
758
|
+
* }
|
|
634
759
|
* ```
|
|
635
760
|
*/
|
|
636
|
-
|
|
761
|
+
interface TestArtifactRegistry {}
|
|
762
|
+
/**
|
|
763
|
+
* @experimental
|
|
764
|
+
*
|
|
765
|
+
* Union type of all test artifacts, including built-in and custom registered artifacts.
|
|
766
|
+
*
|
|
767
|
+
* This type automatically includes all artifacts registered via {@link TestArtifactRegistry}.
|
|
768
|
+
*/
|
|
769
|
+
type TestArtifact = TestAnnotationArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
|
|
637
770
|
|
|
638
|
-
export { createChainable as
|
|
639
|
-
export type { AfterAllListener as A, BeforeAllListener as B,
|
|
771
|
+
export { createChainable as c, afterAll as i, afterEach as j, beforeAll as k, beforeEach as l, onTestFinished as m, onTestFailed as o };
|
|
772
|
+
export type { TestOptions as $, AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, TaskBase as D, TaskCustomOptions as E, File as F, TaskEventPack as G, TaskHook as H, ImportDuration as I, TaskMeta as J, TaskPopulated as K, TaskResult as L, TaskResultPack as M, TaskState as N, OnTestFailedHandler as O, TestAnnotation as P, TestAnnotationArtifact as Q, RunMode as R, Suite as S, Task as T, TestAnnotationLocation as U, TestArtifactBase as V, TestArtifactLocation as W, TestArtifactRegistry as X, TestAttachment as Y, TestContext as Z, TestFunction as _, Test as a, Use as a0, TestArtifact as b, SuiteHooks as d, TaskUpdateEvent as e, TestAPI as f, SuiteAPI as g, SuiteCollector as h, AfterEachListener as n, BeforeEachListener as p, Fixture as q, FixtureFn as r, FixtureOptions as s, Fixtures as t, InferFixturesTypes as u, OnTestFinishedHandler as v, RuntimeContext as w, SequenceHooks as x, SequenceSetupFiles as y, SuiteFactory as z };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiffOptions } from '@vitest/utils/diff';
|
|
2
|
-
import { F as File,
|
|
3
|
-
export { A as AfterAllListener,
|
|
2
|
+
import { F as File, a as Test, S as Suite, M as TaskResultPack, G as TaskEventPack, P as TestAnnotation, b as TestArtifact, Z as TestContext, I as ImportDuration, x as SequenceHooks, y as SequenceSetupFiles } from './tasks.d-r9p5YKu0.js';
|
|
3
|
+
export { A as AfterAllListener, n as AfterEachListener, B as BeforeAllListener, p as BeforeEachListener, q as Fixture, r as FixtureFn, s as FixtureOptions, t as Fixtures, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, g as SuiteAPI, h as SuiteCollector, z as SuiteFactory, d as SuiteHooks, T as Task, D as TaskBase, E as TaskCustomOptions, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, N as TaskState, e as TaskUpdateEvent, f as TestAPI, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, _ as TestFunction, $ as TestOptions, a0 as Use } from './tasks.d-r9p5YKu0.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -122,6 +122,12 @@ interface VitestRunner {
|
|
|
122
122
|
*/
|
|
123
123
|
onTestAnnotate?: (test: Test, annotation: TestAnnotation) => Promise<TestAnnotation>;
|
|
124
124
|
/**
|
|
125
|
+
* @experimental
|
|
126
|
+
*
|
|
127
|
+
* Called when artifacts are recorded on tests via the `recordArtifact` utility.
|
|
128
|
+
*/
|
|
129
|
+
onTestArtifactRecord?: <Artifact extends TestArtifact>(test: Test, artifact: Artifact) => Promise<Artifact>;
|
|
130
|
+
/**
|
|
125
131
|
* Called before running all tests in collected paths.
|
|
126
132
|
*/
|
|
127
133
|
onBeforeRunFiles?: (files: File[]) => unknown;
|
|
@@ -161,11 +167,13 @@ interface VitestRunner {
|
|
|
161
167
|
*/
|
|
162
168
|
getWorkerContext?: () => Record<string, unknown>;
|
|
163
169
|
onCleanupWorkerContext?: (cleanup: () => unknown) => void;
|
|
170
|
+
trace?<T>(name: string, cb: () => T): T;
|
|
171
|
+
trace?<T>(name: string, attributes: Record<string, any>, cb: () => T): T;
|
|
164
172
|
/** @private */
|
|
165
173
|
_currentTaskStartTime?: number;
|
|
166
174
|
/** @private */
|
|
167
175
|
_currentTaskTimeout?: number;
|
|
168
176
|
}
|
|
169
177
|
|
|
170
|
-
export { File, ImportDuration, SequenceHooks, SequenceSetupFiles, Suite, TaskEventPack, TaskResultPack, Test, TestAnnotation, TestContext };
|
|
178
|
+
export { File, ImportDuration, SequenceHooks, SequenceSetupFiles, Suite, TaskEventPack, TaskResultPack, Test, TestAnnotation, TestArtifact, TestContext };
|
|
171
179
|
export type { CancelReason, FileSpecification, VitestRunner, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Suite, F as File,
|
|
2
|
-
export {
|
|
1
|
+
import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-r9p5YKu0.js';
|
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks.d-r9p5YKu0.js';
|
|
3
3
|
import { ParsedStack, Arrayable } from '@vitest/utils';
|
|
4
4
|
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.11",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"pathe": "^2.0.3",
|
|
42
|
-
"@vitest/utils": "4.0.
|
|
42
|
+
"@vitest/utils": "4.0.11"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "premove dist && rollup -c",
|