Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bun-test): test title in results #1753

Merged
merged 4 commits into from Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bun.js/test/jest.zig
Expand Up @@ -1549,7 +1549,7 @@ pub const DescribeScope = struct {
var scope = allocator.create(DescribeScope) catch unreachable;
scope.* = .{
.label = (label.toSlice(allocator).cloneIfNeeded(allocator) catch unreachable).slice(),
.parent = this,
.parent = active orelse this,
.file_id = this.file_id,
};
var new_this = DescribeScope.Class.make(ctx, scope);
Expand Down
8 changes: 6 additions & 2 deletions src/cli/test_command.zig
Expand Up @@ -90,7 +90,9 @@ pub const CommandLineReporter = struct {
const display_label = if (label.len > 0) label else "test";

if (Output.enable_ansi_colors_stderr) {
for (scopes) |scope| {
for (scopes) |_, i| {
const index = (scopes.len - 1) - i;
const scope = scopes[index];
if (scope.label.len == 0) continue;
writer.writeAll(" ") catch unreachable;

Expand All @@ -100,7 +102,9 @@ pub const CommandLineReporter = struct {
writer.writeAll(" >") catch unreachable;
}
} else {
for (scopes) |scope| {
for (scopes) |_, i| {
const index = (scopes.len - 1) - i;
const scope = scopes[index];
if (scope.label.len == 0) continue;
writer.writeAll(" ") catch unreachable;
writer.writeAll(scope.label) catch unreachable;
Expand Down
38 changes: 38 additions & 0 deletions test/bun.js/bun-test/nested-describes.test.ts
@@ -0,0 +1,38 @@
import {
describe,
expect,
test,
} from "bun:test";

/*
In this test we want the tests to print out the following on a success.
Each success / fail should show the path of describe and test scopes

✓ outer most describe > mid describe 1 > inner most describe 1 > first
✓ outer most describe > mid describe 1 > inner most describe 2 > second
✓ outer most describe > mid describe 2 > inner most describe 3 > first

@TODO add testing for this, would require to read the test console output
*/

describe("outer most describe", () => {
describe("mid describe 1", () => {
describe("inner most describe 1", () => {
test("first", () => {
expect(5).toEqual(5);
})
})
describe("inner most describe 2", () => {
test("second", () => {
expect(5).toEqual(5);
})
})
})
describe("mid describe 2", () => {
describe("inner most describe 3", () => {
test("third", () => {
expect(5).toEqual(5);
})
})
})
})