Setup global providers for Angular unit tests

Discussão em 'Angular' iniciado por JSON Derulo, Novembro 12, 2024.

  1. JSON Derulo

    JSON Derulo Guest

    I have generated a fresh Angular 18 project and made it zoneless. It works fine, however in all of my unit tests I am now getting the following error:

    Error: NG0908: In this configuration Angular requires Zone.js


    I resolved the error by adding provideExperimentalZonelessChangeDetection() to each TestBed's providers, however it's quite annoying needing to add this manually to every spec file. Also it pops up again every time I generate a new component.

    Is there a way to set up this provider globally for all unit tests? I have read something about changing the content of the src/test.ts file, but in my project this file does not exist.

    Continue reading...

Compartilhe esta Página