Skip to content

Commit a3ad66e

Browse files
committed
fix: await onTestRunEnd
1 parent ca33a24 commit a3ad66e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/vitest/src/node/test-run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class TestRun {
105105
process.exitCode = 1
106106
}
107107

108-
this.vitest.report('onTestRunEnd', modules, [...errors] as SerializedError[], state)
108+
await this.vitest.report('onTestRunEnd', modules, [...errors] as SerializedError[], state)
109109
}
110110

111111
private hasFailed(modules: TestModule[]) {

test/reporters/tests/html.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('html reporter', async () => {
3131
const resultJson = parse(metaJson.replace(new RegExp(vitestRoot, 'g'), '<rootDir>'))
3232
resultJson.config = {} // doesn't matter for a test
3333
const file = resultJson.files[0]
34+
// reset durations and id
3435
file.id = 0
3536
file.collectDuration = 0
3637
file.environmentLoad = 0
@@ -39,12 +40,15 @@ describe('html reporter', async () => {
3940
file.importDurations = {}
4041
file.result.duration = 0
4142
file.result.startTime = 0
43+
4244
const task = file.tasks[0]
4345
task.id = 0
4446
task.result.duration = 0
4547
task.result.startTime = 0
48+
4649
expect(task.result.errors).not.toBeDefined()
4750
expect(task.result.logs).not.toBeDefined()
51+
4852
expect(resultJson).toMatchSnapshot(`tests are passing`)
4953
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.json.gz"')
5054
}, 120000)
@@ -70,6 +74,7 @@ describe('html reporter', async () => {
7074
const resultJson = parse(metaJson.replace(new RegExp(vitestRoot, 'g'), '<rootDir>'))
7175
resultJson.config = {} // doesn't matter for a test
7276
const file = resultJson.files[0]
77+
// reset durations and id
7378
file.id = 0
7479
file.collectDuration = 0
7580
file.environmentLoad = 0
@@ -78,16 +83,19 @@ describe('html reporter', async () => {
7883
file.importDurations = {}
7984
file.result.duration = 0
8085
file.result.startTime = 0
86+
8187
const task = file.tasks[0]
8288
task.id = 0
8389
task.result.duration = 0
8490
task.result.startTime = 0
91+
8592
expect(task.result.errors).toBeDefined()
8693
task.result.errors[0].stack = task.result.errors[0].stack.split('\n')[0]
8794
expect(task.logs).toBeDefined()
8895
expect(task.logs).toHaveLength(1)
8996
task.logs[0].taskId = 0
9097
task.logs[0].time = 0
98+
9199
expect(resultJson).toMatchSnapshot(`tests are failing`)
92100
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.json.gz"')
93101
}, 120000)

0 commit comments

Comments
 (0)