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

Set QUnit preconfig autostart to false to ensure qunit waits correctly for top level await in app #136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

evoactivity
Copy link
Contributor

Without this when using top level await in your app the tests will break.

[test:ember] not ok 1 Chrome 131.0 - [undefined ms] - Global error: Uncaught Error: Called start() while test already started running at http://localhost:7357/assets/tests-BE6RHohS.js, line 45

Somehow, and I don't know why, autostart is true when QUnit starts up when the app uses a top level await, a component like this can recreate the issue.

import Component from '@glimmer/component';
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
await sleep(1000);

export default class MyComponent extends Component {}

I found this by using dynamic import at the top level to make a large library it's own chunk. I think it's down to bundle ordering, but I'm not sure.

Using qunit's preconfig option ensures autostart is false and top level awaits don't break the test suite.

More context on discord
https://discord.com/channels/480462759797063690/568935504288940056/1319396012506484850
https://discord.com/channels/480462759797063690/568935504288940056/1320540566274179182
https://discord.com/channels/480462759797063690/568935504288940056/1321109960117063773

@evoactivity evoactivity changed the title Set QUnit preconf autostart to false to ensure qunit waits correctly for top level await in app Set QUnit preconfig autostart to false to ensure qunit waits correctly for top level await in app Jan 24, 2025
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

Successfully merging this pull request may close these issues.

1 participant