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

Async global setup doesn't work properly #127

Closed
m3hari opened this issue Aug 1, 2021 · 1 comment
Closed

Async global setup doesn't work properly #127

m3hari opened this issue Aug 1, 2021 · 1 comment

Comments

@m3hari
Copy link

m3hari commented Aug 1, 2021

First of all, Thank you very much for the amazing package ❤️!

Context

I want to run a global setup script before starting tests.
My actual use case is starting playwright browser server and making a ws connection on each test suite to open a tab.

What I did

I have a typescript file that does some setup tasks in scripts/test-setup.ts and I have the following command to
run tests
"test": "uvu -r ts-node/register -r scripts/test-setup tests"

What happened

uvu starts running suits before the setup script finishes

Expectation

Run tests after the global setup script exits

Here is a small repo to reproduce the issue https://github.com/m3hari/uvu-issue-sandbox

image

@lukeed
Copy link
Owner

lukeed commented Dec 8, 2021

This type of setup file needs top-level await in order for it to finish executing before the file "exits". Unfortunately, TLA is only available within ESM files and any --require/-r usage expects a CommonJS file.

So, in order to achieve this, this type of feature requires either #113 or #81.

Both of these will solve this through separate avenues. Closing this in favor of them.
Thanks!

@lukeed lukeed closed this as completed Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants