Skip to content

Wait for app initialization until rendering component #176

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

Closed
jbchr opened this issue Jan 11, 2021 · 2 comments · Fixed by #177
Closed

Wait for app initialization until rendering component #176

jbchr opened this issue Jan 11, 2021 · 2 comments · Fixed by #177
Labels

Comments

@jbchr
Copy link
Contributor

jbchr commented Jan 11, 2021

Description
Angular TestBed is not honoring APP_INITIALIZER contract. This means tests are executed before app initialization is finished. The corresponding Angular issue is this one: angular/angular#24218

In a scenario without testing-library we can easily use a workaround in waiting for the initialization before executing our tests.

await TestBed.get(ApplicationInitStatus).donePromise;

However when using testing-libraries render function we cannot do so, as the lib immediately renders the component after setting up the TestBed

Proposed solution
Insert the above line after setting up the TestBed here:
https://github.com/testing-library/angular-testing-library/blob/master/projects/testing-library/src/lib/testing-library.ts#L76

I'm happy to create a small PR for that :)

@timdeschryver
Copy link
Member

Thanks for opening this issue! I wasn't aware of this behavior.
It would be great if you'd create a PR for this 👍

@github-actions
Copy link

🎉 This issue has been resolved in version 10.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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