Open SuneRadich opened 1 year ago
Workaround:
In your preview_head.html
add the following script block to the top of the file:
<script>
window.beforeEach = window.beforeEach || (() => {});
window.afterEach = window.afterEach || (() => {});
</script>
This will effectively monkey-patch the beforeEach and afterEach that the testing internals that are exposed.
Seems this bug was caused by the following commit https://github.com/angular/angular/commit/0b14e4ef742b1c0f73d873e2c337683b60f46845 released in Angular 16.2.0
So another workaround would be to downgrade to Angular 16.1.9
I just updated our NX-workspace v16.3.2 to v16.7.2. And upgraded Angular v16,0.6 to v16.2.1. And am also seeing this issue with the test-runner. @yngvebn Thank you for your workaround.
Seeing the same when using the storybook-addon-angular-router
addon which also adds RouterTestingModule
. It would be great if it could be fixed without requiring a workaround.
I redid migrations one by one, and this time I ended up on Angular 16.2.2
, and suddenly I can't reproduce the error? Anyone can confirm?
@prewk There was a fix for this included in 16.2.2 I believe, see https://github.com/angular/angular/issues/51382.
Describe the bug
If you run Storybook with Angular, and have a story that imports
RouterTestingModule
the story will throw the following js error:To Reproduce
I have uploaded a small project with a single story that showcase the issue
https://github.com/SuneRadich/beforeEachError
System
Additional context
I use Storybook and Angular in a nx (nx.dev) mono-repo, so it might be related to something there. But it seems to be related to some changes in Angular and Storybook.