-
-
Notifications
You must be signed in to change notification settings - Fork 78
Angular 13: Errors when running Unit Tests #198
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
Comments
I have faced the same issue when trying to unit test this angular component. |
@aarontoys - Using waitForAsync() in the tests should help. I figured that the tests did not account for the async nature of plotly. During creation of a plot, it accesses the DOM elements. By the time the createPlot is being executed, the component is destroyed so are the elements associated with it. I have created a PR to your tests repo. aarontoys/angular-plotly-test#1 @nirakar5656jad does this help you too? |
…ized This can occur in unit tests if you do not await the component being stable, so this resolves plotly#198. However, this could also happen if ngOnDestroy is called very quickly after ngOnInit.
I have just submitted a PR that should fix this issue. While indeed waiting on the fixture to stabilize would be ideal if you're asserting that the plot has fully loaded, sometimes that is not directly relevant to what's under test. Ideally, ngOnDestroy would not throw if the plot has not been initialized yet. My PR prevents that from occurring. Note that this can also theoretically happen if ngOnDestroy is called too quickly after ngOnInit. I'm open to feedback on if the PR could be improved, but at least this avoids the error. |
I get serval errors when running units tests after upgrading to Angular 13.
This repo can produce the error.
Thanks in advance for your help resolving this issue.
The text was updated successfully, but these errors were encountered: