Open cyrilletuzi opened 1 month ago
I see the same issue even though not using zoneless. So maybe its a more general issue. I've followed various guides which in fact all state that just angular.json
must be changed like this:
and in addition @web/test-runner
must be installed. That's it. Somebody also said that @web/test-runner-core
must be installed additionally to fix this error but it didn't help either.
Have the same problem. It seems to me that jasmine is needed zone.js,and no doesn't matter karma runner you has or web-test-runner. So without "polyfills": ["zone.js", "zone.js/testing"] line in "test" block your tests doesnt work, mb need to await global fix from Angular team.
I think I found the solution for my problem. But it will probably not solve the initial issue mentioned here regarding the "Zoneless" approach.
Since Angular 15 they've introduced a new way of adding the polyfills. Additionally to the legacy src/polyfills.ts
file, now adding the polyfills directly in angular.json
like this is supported:
The code for the new experimental web test runner obviously only works when adding the polyfills this way. And additionally also the second entry zone.js/testing
must be added to the array. Then it works as expected as far as I could see.
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
@angular-devkit/build-angular:web-test-runner
is loading files fromzone.js/testing
even when in zoneless mode, thus resulting inng test
command failing.Minimal Reproduction
ng new
(with CLI 18.0.1)ng test
=> OKnpm install @web/test-runner -D
@angular-devkit/build-angular:karma
by@angular-devkit/build-angular:web-test-runner
inangular.json
ng test
=> OKprovideZoneChangeDetection({ eventCoalescing: true })
byprovideExperimentalZonelessChangeDetection()
insrc/app/app.config.ts
providers: [provideExperimentalZonelessChangeDetection()]
inconfigureTestingModule
insrc/app/app.component.spec.ts
polyfills
properties (both inbuild
andtest
) inangular.json
npm rm zone.js
but is is not required for reproductionng test
=> FAIL after the timeout (error below)polyfills
properties (intest
) inangular.json
(andnpm install zone.js
if you removed it)ng test
=> OK but now there are warnings:Reproduction repository here. The repo is in the error case. You can uncomment
polyfills
inangular.json
to see the working scenario.Exception or Error
Your Environment
Anything else relevant?
Pull Request which implemented
@web/test-runner
builder.The missing
testing.js
from the error seems to come from this line.The line which links it to
zone.js/testing
seems to be here.What is strange is that this last file seems to have some behaviors to detect zone or zoneless, but it seems ineffective in the end, probably because of the import in the first file, which is always here.