# Angular tests: Component 'X' is not resolved: templateUrl: ./x.component.html — Did you run and wait for 'resolveComponentResources()'?

**Code:** `Component is not resolved: templateUrl` · **Category:** Angular · **Seen on:** Angular, TypeScript

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.

## 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()` in `beforeEach` (non-CLI runner)
- Jest not configured with `jest-preset-angular` (templateUrl not inlined)
- Mixed Karma and Jest configuration
- Test creates the component synchronously in `beforeEach` while async setup is pending

## Quick fix

1. Make `beforeEach` async and `await TestBed.compileComponents()`
2. For Jest install and configure `jest-preset-angular`
3. Use standalone components: `imports: [MyComponent]`

## Detailed fix by platform

### Angular

1. `beforeEach(async () => { await TestBed.configureTestingModule({ imports: [MyComponent] }).compileComponents(); });`
2. Jest: `npm i -D jest jest-preset-angular` and set `preset: 'jest-preset-angular'`

## Code examples

### Async setup

```typescript
beforeEach(async () => {
  await TestBed.configureTestingModule({ imports: [MyComponent] }).compileComponents();
  fixture = TestBed.createComponent(MyComponent);   // only after compileComponents resolved
});
```

## How to diagnose

1. **Runner** — Karma or Jest?
2. **Setup** — Awaited compileComponents?
3. **Preset** — jest-preset-angular configured?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/testbed-templateurl-not-resolved)
