# Angular tests: Error: Expected to be running in 'ProxyZone', but it was not found.

**Code:** `Expected to be running in 'ProxyZone'` · **Category:** Angular · **Seen on:** Angular, TypeScript

`fakeAsync` / `waitForAsync` was used, but the test environment's zone testing setup is missing.

## Meaning

`fakeAsync` needs `zone.js/testing` loaded. With Karma the CLI does it; with Jest you need `jest-preset-angular` and a `setup-jest.ts` importing it. Also happens when zone.js testing is imported twice, or tests run outside the Angular test runner.

## Common causes

- `zone.js/testing` not imported (Jest without `setup-jest.ts`)
- `jest-preset-angular` missing or misconfigured
- Using `fakeAsync` in a plain function outside `it()`
- Mixed Zone.js versions
- Test runner replaced without Angular's polyfills

## Quick fix

1. Create `setup-jest.ts` with `import 'jest-preset-angular/setup-jest';` and reference it in the Jest config
2. Use the preset: `preset: 'jest-preset-angular'`
3. Call `fakeAsync` only inside `it` / `beforeEach`

## Detailed fix by platform

### npm

1. `npm i -D jest jest-preset-angular @types/jest`
2. jest.config.js: `{ preset: 'jest-preset-angular', setupFilesAfterEach: ['<rootDir>/setup-jest.ts'] }` (older: setupFilesAfterEnv)

## Code examples

### Jest setup

```javascript
// setup-jest.ts
import 'jest-preset-angular/setup-jest';

// jest.config.js
module.exports = { preset: 'jest-preset-angular', setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'] };
```

## How to diagnose

1. **Runner** — Karma or Jest?
2. **Setup** — zone.js/testing loaded?
3. **Usage** — fakeAsync inside an it block?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/expected-to-be-running-in-proxyzone)
