-
Notifications
You must be signed in to change notification settings - Fork 25
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
shallow-render > 14.0.0 error: the code should be running in the fakeAsync zone to call this function #233
Comments
I'm not sure this is related to I pulled down your project and replaced everything in the file class Shallow {
async render() {
return;
}
}
exports.Shallow = Shallow; The test still failed on the Other things I've tried:
|
If you downgrade Edit: if I repeat the scenario with all Angular dependencies downgraded to version 14 and |
I meanwhile investigated this issue closer, as this is currently causing a dependency mismatch in my Angular 15 repository. I'm still running The main difference I'm seeing when comparing In the case of I'm by no means a |
Thanks for the detailed info. Strange indeed. I wondered if it has anything to do with the ES Target changes between versions (see this line from the NG14 PR). I did some searching and it turns out that anything > ES2015 breaks zone.js 😢 From this page:
I just published a test build ( I think it will solve your problem, it works locally. If this solves zone issues for you, I'll publish a proper release and backport the change to the v14 release. |
Yes sir, that does the trick! Tests in the example I posted are now passing with the new |
I've meanwhile been running |
I have found an issue when using
shallow-render
in afakeAsync()
zone inAngular 15.x
when upgrading my project. I knowshallow-render
officially doesn't support Angular 15 yet, but even when I upgradedshallow-render
locally to version 15 and used that to run my tests, the issue I faced remained so I decided to file an issue.When running a
shallow-render
unit test insidefakeAsync()
, the following error is thrown:A basic example would be the following code snippet:
This worked fine pre
Angular 15
and is a valid test case according to Angular tests.A similar example that does work is when I don't include
shallow.render()
like so:Somehow
shallow-render
is modifying/replacingZone
which leads toFakeAsyncTestZoneSpec
going missing, which then causes the error message down the line. I'm taking a look to see if this was the same for older versions ofAngular
, or if something new is going on here.Functional repository to offer a minimal reproduction of the issue:
https://github.com/Timebutt/shallow-render-issue
You can check out the code, run
npm i
andnpm run test
to see the issue at work.Let me know if I can help!
EDIT: from the looks of it, the Angular version has nothing to do with this. In the example repo I provided the tests run fine when I installed
shallow-render@13.0.1
.Zone.current.get('FakeAsyncTestZoneSpec')
is still defined and no error is thrown. Seems like this is a regression in the code ofshallow-render
when upgrading to version 14 then?The text was updated successfully, but these errors were encountered: