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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744367763a4570793.html
评论列表(0条)