@vitest/runner 4.0.10 → 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 CHANGED
@@ -1,10 +1,46 @@
1
- import { T as Test, S as Suite, a as SuiteHooks, F as File, b as TaskUpdateEvent, c as Task, d as TestAPI, e as SuiteAPI, f as SuiteCollector } from './hooks.d-C0RE9A6t.js';
2
- export { A as AfterAllListener, l as AfterEachListener, B as BeforeAllListener, m as BeforeEachListener, n as Fixture, p as FixtureFn, q as FixtureOptions, r as Fixtures, I as ImportDuration, s as InferFixturesTypes, O as OnTestFailedHandler, t as OnTestFinishedHandler, R as RunMode, u as RuntimeContext, v as SequenceHooks, w as SequenceSetupFiles, x as SuiteFactory, y as TaskBase, z as TaskCustomOptions, C as TaskEventPack, D as TaskHook, E as TaskMeta, G as TaskPopulated, H as TaskResult, J as TaskResultPack, K as TaskState, L as TestAnnotation, M as TestAnnotationLocation, N as TestAttachment, P as TestContext, Q as TestFunction, U as TestOptions, V as Use, g as afterAll, h as afterEach, i as beforeAll, j as beforeEach, o as onTestFailed, k as onTestFinished } from './hooks.d-C0RE9A6t.js';
1
+ import { b as TestArtifact, a as Test, S as Suite, d as SuiteHooks, F as File, e as TaskUpdateEvent, T as Task, f as TestAPI, g as SuiteAPI, h as SuiteCollector } from './tasks.d-r9p5YKu0.js';
2
+ 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, I as ImportDuration, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, x as SequenceHooks, y as SequenceSetupFiles, z as SuiteFactory, D as TaskBase, E as TaskCustomOptions, G as TaskEventPack, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, M as TaskResultPack, N as TaskState, P as TestAnnotation, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, Z as TestContext, _ as TestFunction, $ as TestOptions, a0 as Use, i as afterAll, j as afterEach, k as beforeAll, l as beforeEach, o as onTestFailed, m as onTestFinished } from './tasks.d-r9p5YKu0.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import { FileSpecification, VitestRunner } from './types.js';
5
5
  export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
6
6
  import '@vitest/utils/diff';
7
7
 
8
+ /**
9
+ * @experimental
10
+ * @advanced
11
+ *
12
+ * Records a custom test artifact during test execution.
13
+ *
14
+ * This function allows you to attach structured data, files, or metadata to a test.
15
+ *
16
+ * Vitest automatically injects the source location where the artifact was created and manages any attachments you include.
17
+ *
18
+ * @param task - The test task context, typically accessed via `this.task` in custom matchers or `context.task` in tests
19
+ * @param artifact - The artifact to record. Must extend {@linkcode TestArtifactBase}
20
+ *
21
+ * @returns A promise that resolves to the recorded artifact with location injected
22
+ *
23
+ * @throws {Error} If called after the test has finished running
24
+ * @throws {Error} If the test runner doesn't support artifacts
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * // In a custom assertion
29
+ * async function toHaveValidSchema(this: MatcherState, actual: unknown) {
30
+ * const validation = validateSchema(actual)
31
+ *
32
+ * await recordArtifact(this.task, {
33
+ * type: 'my-plugin:schema-validation',
34
+ * passed: validation.valid,
35
+ * errors: validation.errors,
36
+ * })
37
+ *
38
+ * return { pass: validation.valid, message: () => '...' }
39
+ * }
40
+ * ```
41
+ */
42
+ declare function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact>;
43
+
8
44
  declare function setFn(key: Test, fn: () => Awaitable<void>): void;
9
45
  declare function getFn<Task = Test>(key: Task): () => Awaitable<void>;
10
46
  declare function setHooks(key: Suite, hooks: SuiteHooks): void;
@@ -141,4 +177,4 @@ declare function createTaskCollector(fn: (...args: any[]) => any, context?: Reco
141
177
 
142
178
  declare function getCurrentTest<T extends Test | undefined>(): T;
143
179
 
144
- export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, setFn, setHooks, startTests, suite, test, updateTask };
180
+ export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, TestArtifact, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, recordArtifact, setFn, setHooks, startTests, suite, test, updateTask };