aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/test/jest.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-11 01:16:46 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-11 01:16:46 -0700
commite125ed2aa3840afc448509894d9e3c02ac9bc131 (patch)
tree1b6d6bb7a5a67e672e29f74320ac55de5141376c /src/bun.js/test/jest.zig
parent5ffee9477cc856d975b6ac8577f25396b55e8403 (diff)
downloadbun-e125ed2aa3840afc448509894d9e3c02ac9bc131.tar.gz
bun-e125ed2aa3840afc448509894d9e3c02ac9bc131.tar.zst
bun-e125ed2aa3840afc448509894d9e3c02ac9bc131.zip
Report timings for failing tests too
Diffstat (limited to 'src/bun.js/test/jest.zig')
-rw-r--r--src/bun.js/test/jest.zig20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index ed4741f1f..5b0315f78 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -435,9 +435,9 @@ pub const TestRunner = struct {
this.tests.items(.status)[test_id] = .pass;
this.callback.onTestPass(this.callback, test_id, file, label, expectations, elapsed_ns, parent);
}
- pub fn reportFailure(this: *TestRunner, test_id: Test.ID, file: string, label: string, expectations: u32, parent: ?*DescribeScope) void {
+ pub fn reportFailure(this: *TestRunner, test_id: Test.ID, file: string, label: string, expectations: u32, elapsed_ns: u64, parent: ?*DescribeScope) void {
this.tests.items(.status)[test_id] = .fail;
- this.callback.onTestFail(this.callback, test_id, file, label, expectations, 0, parent);
+ this.callback.onTestFail(this.callback, test_id, file, label, expectations, elapsed_ns, parent);
}
pub fn reportSkip(this: *TestRunner, test_id: Test.ID, file: string, label: string, parent: ?*DescribeScope) void {
@@ -3617,7 +3617,7 @@ pub const DescribeScope = struct {
const beforeAll = this.runCallback(ctx, .beforeAll);
if (!beforeAll.isEmpty()) {
while (i < end) {
- Jest.runner.?.reportFailure(i + this.test_id_start, source.path.text, tests[i].label, 0, this);
+ Jest.runner.?.reportFailure(i + this.test_id_start, source.path.text, tests[i].label, 0, 0, this);
i += 1;
}
this.tests.clearAndFree(allocator);
@@ -3806,7 +3806,7 @@ pub const TestRunnerTask = struct {
const beforeEach = this.describe.runCallback(globalThis, .beforeEach);
if (!beforeEach.isEmpty()) {
- Jest.runner.?.reportFailure(test_id, this.source_file_path, label, 0, this.describe);
+ Jest.runner.?.reportFailure(test_id, this.source_file_path, label, 0, 0, this.describe);
globalThis.bunVM().runErrorHandler(beforeEach, null);
return false;
}
@@ -3894,7 +3894,17 @@ pub const TestRunnerTask = struct {
0,
describe,
),
- .fail => |count| Jest.runner.?.reportFailure(test_id, this.source_file_path, test_.label, count, describe),
+ .fail => |count| Jest.runner.?.reportFailure(
+ test_id,
+ this.source_file_path,
+ test_.label,
+ count,
+ if (test_elapsed_timer) |timer|
+ timer.read()
+ else
+ 0,
+ describe,
+ ),
.skip => Jest.runner.?.reportSkip(test_id, this.source_file_path, test_.label, describe),
.pending => @panic("Unexpected pending test"),
}