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

Nest test/it calls under a single describe label instead of repeating the describe label for each test #3342

Open
jakeboone02 opened this issue Jun 17, 2023 · 9 comments · Fixed by #12189
Labels
enhancement New feature or request jest Something related to the `bun test` runner

Comments

@jakeboone02
Copy link
Contributor

What is the problem this feature would solve?

bun test currently repeats the describe label for each test/it call. Take the following test file as an example:

describe("test group 1", () => {
  it("does thing 0", () => { expect(0).toBe(0); });
  it("does thing 1", () => { expect(1).toBe(1); });
  it("does thing 2", () => { expect(2).toBe(2); });
  it("does thing 3", () => { expect(3).toBe(3); });
  it("does thing 4", () => { expect(4).toBe(4); });
});

describe("test group 2", () => {
  it("does thing 5", () => { expect(5).toBe(5); });
  it("does thing 6", () => { expect(6).toBe(6); });
  it("does thing 7", () => { expect(7).toBe(7); });
  it("does thing 8", () => { expect(8).toBe(8); });
  it("does thing 9", () => { expect(9).toBe(9); });
});

This produces the following output:

image

What is the feature you are proposing to solve the problem?

I would prefer a more concise output like Jest, where the describe label is only printed once and the test/it labels are nested beneath it. I believe this is not just cleaner, but also clearer visually.

Here is Jest's output for the same test file:

image

What alternatives have you considered?

No response

@jakeboone02 jakeboone02 added the enhancement New feature or request label Jun 17, 2023
@trnxdev
Copy link
Contributor

trnxdev commented Jun 17, 2023

We probably should implement it, if someone else from the core team agrees I might work on it.

@Electroid Electroid added the jest Something related to the `bun test` runner label Jun 17, 2023
@Electroid
Copy link
Contributor

Seems like a good idea 👍

@simylein
Copy link
Contributor

simylein commented Jun 22, 2023

On that note, can we make it that failed tests log last?
Because the constant scrolling up to find logs is rather annoying.

edit:
I finally found the issue again, it is #2109

@jakeboone02
Copy link
Contributor Author

@simylein That's a good point. Jest shows the pass/fail result for each test inline, but batches the logging of all the verbose stuff (Expected/Received/etc.) at the end of the output. bun test puts the verbose failure explanations interspersed with the one-line pass/fail logs. Comparison of the same test suite as above, with a couple of intentional failures:

image

With Jest's format it's much easier to see everything that needs to be addressed in one place without much scrolling, if any.

@simylein
Copy link
Contributor

Any updates on this? It would make testing with bun much more prettier and useful.

@trnxdev
Copy link
Contributor

trnxdev commented Jul 29, 2023

Any updates on this? It would make testing with bun much more prettier and useful.

I don't think it's really prioritized right now, maybe when bun gets more stable we can think about this. But right now we have lots of issues to fix.

@Jarred-Sumner
Copy link
Collaborator

I don't think it's really prioritized right now, maybe when bun gets more stable we can think about this. But right now we have lots of issues to fix.

I don't think you have enough context to say this :)

Any updates on this? It would make testing with bun much more prettier and useful.

No real updates, other than we should do this before Bun 1.0.

@trnxdev
Copy link
Contributor

trnxdev commented Jul 30, 2023

No real updates, other than we should do this before Bun 1.0.

Can we create a Milestone or Label on github for stuff we need to do before Bun 1.0?

@dylan-conway
Copy link
Collaborator

Reopening, see #12189 (comment)

@dylan-conway dylan-conway reopened this Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jest Something related to the `bun test` runner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants