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

config to control handling for tests that 'Failed to exit' - v6+ issue #3279

Closed
croconut opened this issue Dec 29, 2023 · 3 comments · Fixed by #3283
Closed

config to control handling for tests that 'Failed to exit' - v6+ issue #3279

croconut opened this issue Dec 29, 2023 · 3 comments · Fixed by #3283
Assignees
Labels

Comments

@croconut
Copy link

With Node 18.18, I am unable to get Ava to not fail the test suite when a module does not exit. I run integration tests with a local database and want to keep the database pool open.

In 5.3.1, this worked fine but it breaks after upgrading and no other changes on my end.

Please enable some kind of way to set up the configuration to forcibly exit and pass if all tests ran & passed, or just let me know what I'm missing here. I've already tried toggling worker threads and I didnt see anything else usable in the docs for the configuration.

@novemberborn
Copy link
Member

This was discussed here: #3260 (comment)

But I'll use this as the tracking issue.


I run integration tests with a local database and want to keep the database pool open.

Since each test file runs in its own isolated worker thread, I don't think this will make a difference.

In 5.3.1, this worked fine but it breaks after upgrading and no other changes on my end.

Yes this was a change in AVA 6. It's listed under the Breaking Changes in the release notes:

When tests finish, worker threads or child processes are no longer exited through proces.exit(). If your test file does not exit on its own, the test run will time out.

Please enable some kind of way to set up the configuration to forcibly exit and pass if all tests ran & passed

See suggestion at #3260 (comment):

I think a import { registerCompleteHandler } from 'ava' which sets up a function to be called when AVA is done would be a decent solution. You could then registerCompleteHandler(() => process.exit()) and AVA will just assume the test worker exited on its own. This could be in a helper file that is loaded.

Other use cases are as a cleanup routine that sits outside of AVA's test & hook logic. I'm leaning to a solution like this over configuration because configuration implies we can handle edge cases in Node.js and we can't.

@novemberborn novemberborn self-assigned this Dec 30, 2023
novemberborn added a commit that referenced this issue Dec 30, 2023
Register a function to be called when AVA has completed a test run without uncaught exceptions or unhandled rejections.

Fixes #3279.
 *
 * Completion handlers are invoked in order of registration. Results are not awaited.
This was referenced Dec 30, 2023
@novemberborn
Copy link
Member

@croconut let me know if #3283 works for you.

@croconut
Copy link
Author

@novemberborn thanks a bunch, I'll give this a shot

novemberborn added a commit that referenced this issue Jan 2, 2024
Register a function to be called when AVA has completed a test run without uncaught exceptions or unhandled rejections.

Fixes #3279.
 *
 * Completion handlers are invoked in order of registration. Results are not awaited.
novemberborn added a commit that referenced this issue Jan 11, 2024
Register a function to be called when AVA has completed a test run without uncaught exceptions or unhandled rejections.

Fixes #3279.
 *
 * Completion handlers are invoked in order of registration. Results are not awaited.
novemberborn added a commit that referenced this issue Jan 11, 2024
Register a function to be called when AVA has completed a test run without uncaught exceptions or unhandled rejections.

Fixes #3279.
 *
 * Completion handlers are invoked in order of registration. Results are not awaited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants