(testId: string, artifact: Artifact)
| 56 | } |
| 57 | |
| 58 | async recordArtifact<Artifact extends TestArtifact>(testId: string, artifact: Artifact): Promise<Artifact> { |
| 59 | const task = this.vitest.state.idMap.get(testId) |
| 60 | const entity = task && this.vitest.state.getReportedEntity(task) |
| 61 | |
| 62 | assert(task && entity, `Entity must be found for task ${task?.name || testId}`) |
| 63 | assert(entity.type === 'test', `Artifacts can only be recorded on a test, instead got ${entity.type}`) |
| 64 | |
| 65 | // annotations won't resolve as artifacts for backwards compatibility until next major |
| 66 | if (artifact.type === 'internal:annotation') { |
| 67 | await this.resolveTestAttachment(entity, artifact.annotation.attachment, artifact.annotation.message) |
| 68 | |
| 69 | entity.task.annotations.push(artifact.annotation) |
| 70 | |
| 71 | await this.vitest.report('onTestCaseAnnotate', entity, artifact.annotation) |
| 72 | |
| 73 | return artifact |
| 74 | } |
| 75 | |
| 76 | if (Array.isArray(artifact.attachments)) { |
| 77 | await Promise.all( |
| 78 | artifact.attachments.map(attachment => this.resolveTestAttachment(entity, attachment)), |
| 79 | ) |
| 80 | } |
| 81 | |
| 82 | entity.task.artifacts.push(artifact) |
| 83 | |
| 84 | await this.vitest.report('onTestCaseArtifactRecord', entity, artifact) |
| 85 | |
| 86 | return artifact |
| 87 | } |
| 88 | |
| 89 | async updated(update: TaskResultPack[], events: TaskEventPack[]): Promise<void> { |
| 90 | this.syncUpdateStacks(update) |
no test coverage detected