MCPcopy
hub / github.com/vitest-dev/vitest / recordArtifact

Function recordArtifact

packages/runner/src/artifact.ts:41–83  ·  view source on GitHub ↗
(task: Test, artifact: Artifact)

Source from the content-addressed store, hash-verified

39 * ```
40 */
41export async function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact> {
42 const runner = getRunner()
43
44 const stack = findTestFileStackTrace(
45 task.file.filepath,
46 new Error('STACK_TRACE').stack!,
47 )
48
49 if (stack) {
50 artifact.location = {
51 file: stack.file,
52 line: stack.line,
53 column: stack.column,
54 }
55
56 if (artifact.type === 'internal:annotation') {
57 artifact.annotation.location = artifact.location
58 }
59 }
60
61 if (Array.isArray(artifact.attachments)) {
62 for (const attachment of artifact.attachments) {
63 manageArtifactAttachment(attachment)
64 }
65 }
66
67 // annotations won't resolve as artifacts for backwards compatibility until next major
68 if (artifact.type === 'internal:annotation') {
69 return artifact
70 }
71
72 if (!runner.onTestArtifactRecord) {
73 throw new Error(`Test runner doesn't support test artifacts.`)
74 }
75
76 await finishSendTasksUpdate(runner)
77
78 const resolvedArtifact = await runner.onTestArtifactRecord(task, artifact)
79
80 task.artifacts.push(resolvedArtifact)
81
82 return resolvedArtifact as typeof artifact
83}
84
85const table: string[] = []
86for (let i = 65; i < 91; i++) {

Callers 3

createTestContextFunction · 0.90
BrowserTestRunnerClass · 0.85
toMatchScreenshotFunction · 0.85

Calls 4

getRunnerFunction · 0.90
findTestFileStackTraceFunction · 0.90
finishSendTasksUpdateFunction · 0.90
manageArtifactAttachmentFunction · 0.85

Tested by

no test coverage detected