admin管理员组文章数量:1402953
I changed my angular app V 19.x to ZoneLess app (I did uninstall the Zone.js and removed its import from polyfills.ts
). All works fine. The issue is when running the unit test (using jest
). The spec files have been all changed to use Zoneless adding:
provideExperimentalZonelessChangeDetection()
in providers:[]
matadata etc.
The test runs all fine and no errors, but I keep getting the following warning in the console for each spec
file which is bad:
console.warn
NG0914: The application is using zoneless change detection, but is still loading Zone.js. Consider removing Zone.js to get the full benefits of zoneless. In applications using the Angular CLI, Zone.js is typically included in the "polyfills" section of the angular.json file.
247 | providers: [
> 248 | provideExperimentalZonelessChangeDetection(),
| ^
249 | {
250 | provide: AppSettingsService,
251 | useValue: getAppSettingsServiceSpy()
},
...
]
I have been searching and tried some options, but none of my tries fixes the warning. Any idea or a hint what could be the cause please?
I changed my angular app V 19.x to ZoneLess app (I did uninstall the Zone.js and removed its import from polyfills.ts
). All works fine. The issue is when running the unit test (using jest
). The spec files have been all changed to use Zoneless adding:
provideExperimentalZonelessChangeDetection()
in providers:[]
matadata etc.
The test runs all fine and no errors, but I keep getting the following warning in the console for each spec
file which is bad:
console.warn
NG0914: The application is using zoneless change detection, but is still loading Zone.js. Consider removing Zone.js to get the full benefits of zoneless. In applications using the Angular CLI, Zone.js is typically included in the "polyfills" section of the angular.json file.
247 | providers: [
> 248 | provideExperimentalZonelessChangeDetection(),
| ^
249 | {
250 | provide: AppSettingsService,
251 | useValue: getAppSettingsServiceSpy()
},
...
]
I have been searching and tried some options, but none of my tries fixes the warning. Any idea or a hint what could be the cause please?
Share Improve this question asked Mar 21 at 7:54 k.vincentk.vincent 4,1638 gold badges43 silver badges85 bronze badges1 Answer
Reset to default 0You need change your file setup-jest.ts for that:
import { setupZonelessTestEnv } from 'jest-preset-angular/setup-env/zoneless';
setupZonelessTestEnv();
You can find a documentation here
https://thymikee.github.io/jest-preset-angular/docs/getting-started/testbed-environment
本文标签: How to fix unit test warnings for angularzoneless applicationStack Overflow
版权声明:本文标题:How to fix unit test warnings for angular-zoneless application? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744367763a2602867.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论