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

aroundAll(): To ensure teardown even if beforeAll aborted. #2694

Closed
4 tasks done
genki opened this issue Jan 17, 2023 · 2 comments · Fixed by #2737
Closed
4 tasks done

aroundAll(): To ensure teardown even if beforeAll aborted. #2694

genki opened this issue Jan 17, 2023 · 2 comments · Fixed by #2737

Comments

@genki
Copy link

genki commented Jan 17, 2023

Clear and concise description of the problem

As we know beforeAll/afterAll is typically used to setup/teardown resources for a test suite.
But currently if beforeAll is aborted by errors then afterAll won't be called, so that we can't surely cleanup resources that are prepared in the beforeAll.

Suggested solution

I think it is better if there's a way to wrap an entire test suite with one hook, so to speak, aroundAll().

aroundAll(async (run) => {
  try {
    // setup
    run() // run suite
  } catch (e) {
    ...
  }
  // teardown
})

aroundEach is may also useful.

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

But currently if beforeAll is aborted by errors then afterAll won't be called, so that we can't surely cleanup resources that are prepared in the beforeAll.

This is a bug. afterEach is called, if beforeEach failed. The same should apply to beforeAll/afterAll.

@genki
Copy link
Author

genki commented Jan 23, 2023

@sheremet-va I see. Thanks to fix :)

@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants