Skip to content

Commit d6f0802

Browse files
committed
Fixed and tested history
1 parent 2ef5c56 commit d6f0802

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

e2e/vitest.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ describe('examples/vitest', () => {
8383
expanded: expect.arrayContaining([expect.stringContaining("vitest/example.test.js\:11\:20")])
8484
})
8585
]))
86+
87+
expect(json).toHaveProperty("data[0].history")
88+
89+
const firstHistory = json.data[0].history
90+
expect(firstHistory).toHaveProperty("section", "top")
91+
expect(firstHistory).toHaveProperty("start_at", expect.any(Number))
92+
expect(firstHistory.start_at).toBeGreaterThanOrEqual(0)
93+
expect(firstHistory).toHaveProperty("end_at", expect.any(Number))
94+
expect(firstHistory.end_at).toBeGreaterThan(firstHistory.start_at)
95+
expect(firstHistory).toHaveProperty("duration", expect.any(Number))
96+
expect(firstHistory.duration).toBeGreaterThan(0)
97+
98+
const secondHistory = json.data[1].history
99+
expect(secondHistory).toHaveProperty("section", "top")
100+
expect(secondHistory).toHaveProperty("start_at", expect.any(Number))
101+
expect(secondHistory.start_at).toBeGreaterThanOrEqual(0)
102+
expect(secondHistory).toHaveProperty("end_at", expect.any(Number))
103+
expect(secondHistory.end_at).toBeGreaterThan(secondHistory.start_at)
104+
expect(secondHistory).toHaveProperty("duration", expect.any(Number))
105+
expect(secondHistory.duration).toBeGreaterThan(0)
106+
86107
done()
87108
})
88109
}, 10000) // 10s timeout

vitest/reporter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class VitestBuildkiteTestEngineReporter extends JsonReporter {
4646
result: this.testEngineResult(assertionResult),
4747
failure_reason: this.testEngineFailureReason(assertionResult),
4848
failure_expanded: this.testEngineFailureExpanded(assertionResult),
49-
history: this.testEngineHistory(originStart, assertionResult),
49+
history: this.testEngineHistory(originStart, testResult, assertionResult),
5050
};
5151
},
5252
);
@@ -105,11 +105,11 @@ class VitestBuildkiteTestEngineReporter extends JsonReporter {
105105
];
106106
}
107107

108-
testEngineHistory(originStart, assertionResults) {
108+
testEngineHistory(originStart, testResult, assertionResults) {
109109
return {
110110
section: 'top',
111-
start_at: (assertionResults.startTime - originStart) / 1000,
112-
end_at: (assertionResults.endTime - originStart) / 1000,
111+
start_at: (testResult.startTime - originStart) / 1000,
112+
end_at: (testResult.endTime - originStart) / 1000,
113113
duration: assertionResults.duration / 1000,
114114
};
115115
}

0 commit comments

Comments
 (0)