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

JUNIT reporter doesn't mark test as failed if the beforeAll throws error #4516

Closed
6 tasks done
jonatan-zint-tfs opened this issue Nov 16, 2023 · 5 comments · Fixed by #4819
Closed
6 tasks done

JUNIT reporter doesn't mark test as failed if the beforeAll throws error #4516

jonatan-zint-tfs opened this issue Nov 16, 2023 · 5 comments · Fixed by #4819

Comments

@jonatan-zint-tfs
Copy link

Describe the bug

When a beforeAll hook throws an error, the generated JUNIT report will report all tests in that describe block as without failiure, ergo succeeded.

That doesn't seem right to me.

Reproduction

I set up a minimal example in this stackblitz:

https://stackblitz.com/edit/vitest-dev-vitest-brpfrz

System Info

See the stackblitz example

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Nov 16, 2023

What is your expectation here? Do you expect all tests to have the same error? I am not actually sure what JUNIT spec defines this situation. Does it support a single failure inside a suite?

@jonatan-zint-tfs
Copy link
Author

Reading this it seems junit allows only failed testcases, not suites.

However not reporting the failiures at all does seem worse to me instead of reporting the same failiure to each testcase affecte by the bad beforeAll. That is also the behaviour if beforeEach throws an error.

@sheremet-va
Copy link
Member

However not reporting the failiures at all does seem worse to me instead of reporting the same failiure to each testcase affecte by the bad beforeAll. That is also the behaviour if beforeEach throws an error.

I do agree that we need to show them, I am just not sure how. Maybe jest has an answer.

@torsten-ueckert
Copy link

With Jest the individual test cases are not run and every test case is reported as failing with the same error in beforeAll

@hi-ogawa
Copy link
Contributor

It looks like a failure in afterAll doesn't make relevant test cases as failed. I made a repro to compare all four cases of
afterAll/afterEach/beforeAll/beforeEach.

https://stackblitz.com/edit/vitest-dev-vitest-m7bw4w?file=junit.xml

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants