Angular "NG0..." runtime error in CI tests and prerender
Angular runtime errors are coded NG0xxx. They appear at runtime, which in CI means during headless unit tests, prerendering, or SSR. The code identifies the exact runtime contract that was violated.
What this error means
A karma/Jest run or a prerender step logs "ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError" or "NG0200: Circular dependency in DI detected" and the job fails.
ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError:
Expected 'false' but got 'true'.Common causes
A value changed after change detection ran (NG0100)
A binding or parent property was mutated during or after the same change-detection pass, which Angular flags in dev mode used by tests.
A circular dependency in DI (NG0200)
Two services inject each other directly, producing a circular provider graph the injector cannot resolve at runtime.
How to fix it
Resolve the specific NG code
- Look up the NG code in the error to identify the exact contract.
- For NG0100, move the state change out of the render pass or into ngOnInit/async, or use markForCheck appropriately.
- For NG0200, break the injection cycle with forwardRef or by restructuring the services.
Reproduce in a headless test locally
Run the same headless test command CI uses so the runtime error reproduces off the runner.
ng test --watch=false --browsers=ChromeHeadlessHow to prevent it
- Avoid mutating bound state during change detection.
- Keep DI graphs acyclic; use forwardRef only where necessary.
- Run headless tests locally to catch NG0 errors before CI.