Angular tests: Component 'X' is not resolved: templateUrl: ./x.component.html — Did you run and wait for 'resolveComponentResources()'?
A test created a component whose external template was not compiled yet — compileComponents() was not called/awaited, or the test runner does not process templates.
Component is not resolved: templateUrlDid you run and wait for 'resolveComponentResources()'?Component 'MyComponent' is not resolvedtemplateUrl: ./my.component.html Meaning
With the CLI builder the template is compiled in advance. The error appears with Jest setups lacking the Angular preset, or when a test creates the component before await TestBed.compileComponents() finished. Standalone components in imports usually avoid it.
Common causes
- Missing
await TestBed.compileComponents()inbeforeEach(non-CLI runner) - Jest not configured with
jest-preset-angular(templateUrl not inlined) - Mixed Karma and Jest configuration
- Test creates the component synchronously in
beforeEachwhile async setup is pending
⚡ Quick fix
- Make
beforeEachasync andawait TestBed.compileComponents() - For Jest install and configure
jest-preset-angular - Use standalone components:
imports: [MyComponent]
Detailed fix by platform
Angular
beforeEach(async () => { await TestBed.configureTestingModule({ imports: [MyComponent] }).compileComponents(); });- Jest:
npm i -D jest jest-preset-angularand setpreset: 'jest-preset-angular'
Code examples
Async setup
beforeEach(async () => {
await TestBed.configureTestingModule({ imports: [MyComponent] }).compileComponents();
fixture = TestBed.createComponent(MyComponent); // only after compileComponents resolved
});How to diagnose
- Runner — Karma or Jest?
- Setup — Awaited compileComponents?
- Preset — jest-preset-angular configured?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot find control with name Angular: Error: Cannot find control with name: 'email' (reactive forms)
- Could not find the builder's node package Angular CLI: Could not find the '@angular-devkit/build-angular:browser' builder's node package / Cannot find module '@angular-devkit/build-angular/package.json'
- exceeded maximum budget Angular build: Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 120.00 kB with a total of 1.12 MB
Most viewed in Angular
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026