aboutsummaryrefslogtreecommitdiff
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
parent5ffee9477cc856d975b6ac8577f25396b55e8403 (diff)
downloadbun-e125ed2aa3840afc448509894d9e3c02ac9bc131.tar.gz
bun-e125ed2aa3840afc448509894d9e3c02ac9bc131.tar.zst
bun-e125ed2aa3840afc448509894d9e3c02ac9bc131.zip
Report timings for failing tests too
-rw-r--r--src/bun.js/test/jest.zig20
-rw-r--r--test/js/node/http/node-http.test.ts2
2 files changed, 16 insertions, 6 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"),
}
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts
index fd2673728..726453217 100644
--- a/test/js/node/http/node-http.test.ts
+++ b/test/js/node/http/node-http.test.ts
@@ -488,7 +488,6 @@ describe("node:http", () => {
it("should return response with lowercase headers", done => {
runTest(done, (server, serverPort, done) => {
const req = request(`http://localhost:${serverPort}/lowerCaseHeaders`, res => {
- console.log(res.headers);
expect(res.headers["content-type"]).toBe("text/plain");
expect(res.headers["x-custom-header"]).toBe("custom_value");
done();
@@ -593,6 +592,7 @@ describe("node:http", () => {
Bun.sleep(10).then(() => {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello World");
+ server.close();
});
});
server.listen({ port: 0 }, (_err, host, port) => {