Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2K
Views
Error: zone-testing.js is needed for the fakeAsync() test helper but could not be found. When running test on Angular webapp using serenityJS+Jasmine

I am trying to run component testing on Angular web app using serenityJS + Jasmine but encountered the error below. Any idea how I can resolve this issue?

Message:
Error: zone-testing.js is needed for the fakeAsync() test helper but could not be found.
        Please make sure that your environment includes zone.js/dist/zone-testing.js

Stack: Error: zone-testing.js is needed for the fakeAsync() test helper but could not be found. Please make sure that your environment includes zone.js/dist/zone-testing.js at resetFakeAsyncZone (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\testing\src\fake_async.ts:25:9) at UserContext. (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\testing\src\before_each.ts:26:5) at at processImmediate (internal/timers.js:439:21) at process.topLevelDomainCallback (domain.js:131:23) Message: Error: In this configuration Angular requires Zone.js Stack: Error: In this configuration Angular requires Zone.js at new NgZone (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\src\zone\ng_zone.ts:129:13) at TestBedViewEngine._initIfNeeded (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\testing\src\test_bed.ts:409:9) at TestBedViewEngine.createComponent (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\testing\src\test_bed.ts:599:10) at Function.TestBedViewEngine.createComponent (C:\Users\zhenweiwong\Desktop\serenityjsframework\packages\core\testing\src\test_bed.ts:245:36)
at UserContext. (C:\Users\zhenweiwong\Desktop\serenityjsframework\jasmine-test\spec\app1.component.spec.ts:32:29) at

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

This issue comes into picture from Angular v11.

Solution: Move import 'zone.js/dist/zone-testing'; to the top in src/test.ts file.

over 4 years ago · Santiago Trujillo Report

0

I got the same issue after upgraded from the Angular 10 to Angular 12. Then I fixed it by move the import 'zone.js/testing to the top of the file test.ts

enter image description here

over 4 years ago · Santiago Trujillo Report

0

Hello little bit late to answer but I leave the comment here for future reference:

ERROR ORIGIN

In my case, the error was found in the test.ts file. This file sets the TestBed config that is used by default in Angular spec files when created with the command ng generate component my-component.

SOLUTION

The fix is to make sure that the following imports are at the top of the file test.ts before any other import:

import 'zone.js';
import 'zone.js/testing';

Be careful with your configurations that might alter the order of those imports as it may lead to break the tests again. That's why you might, over the test.ts file:

  1. Deactivate onSave optimize imports.
  2. Avoid running Prettier, Beautify or other code style formatter that reorganizes the imports.
  3. Check for pre-commits hooks like Husky that format the files and reorganize the imports.

FURTHER TROUBLESHOTING

You might also want to look if the following imports are present:

import 'zone.js';
import 'zone.js/dist/async-test.js';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';

Same issue was solved with other approaches in this thread.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!