ngx-zombie-compiler

raw JSON →
0.3.0 verified Fri May 01 auth: no javascript maintenance

Fast JiT compiler for Angular unit testing that reuses compiled results across specs to reduce execution time. Current stable version 0.3.0, compatible with Angular 4.2+. Unlike default Angular TestingCompiler which compiles modules per spec, this compiler outlives the default and caches compiled components. Ships TypeScript types. Low release cadence; last release in 2017. Useful for Angular CLI projects (edit src/test.ts). Few alternatives exist for this niche optimization.

error Error: Can't resolve 'ngx-zombie-compiler'
cause Package not installed or typo in import path.
fix
npm install ngx-zombie-compiler --save-dev
error TypeError: TestBed.configureCompiler is not a function
cause Using old Angular version where TestBed.configureCompiler does not exist.
fix
Ensure @angular/core is version 4.x.x or later. For Angular 2.x, use deprecated methods.
error Error: StaticInjectorError[ZombieCompiler]: NullInjectorError: No provider for JitCompiler!
cause Missing @angular/compiler peer dependency.
fix
npm install @angular/compiler@^4.2.0
breaking Version 0.3.0 requires Angular 4.2.0+ due to breaking change in JitCompiler constructor. Older versions incompatible.
fix Upgrade to ngx-zombie-compiler@0.3.0 and ensure @angular/core and @angular/compiler are >=4.2.0.
deprecated Package has not been updated since Angular 4. May not work with Angular 5+ due to changes in compiler internals.
fix Consider testing with Angular 5+; if compilation fails, look for alternatives or fork.
gotcha ZOMBIE_COMPILER_PROVIDERS must be provided in beforeEach(), not once at top level, to avoid cross-test contamination.
fix Call getTestBed().configureCompiler({ providers: ZOMBIE_COMPILER_PROVIDERS }) inside each beforeEach() or in a setup function per test suite.
gotcha Does not support AOT compilation; only JiT. AOT tests may need jasmine or jest configuration.
fix For AOT, use Angular's default TestBed or @angular/platform-browser-dynamic testing utilities.
npm install ngx-zombie-compiler
yarn add ngx-zombie-compiler
pnpm add ngx-zombie-compiler

Configures TestBed to use the zombie compiler, reusing compiled results across specs.

import { TestBed, getTestBed } from '@angular/core/testing';
import { ZOMBIE_COMPILER_PROVIDERS } from 'ngx-zombie-compiler';

beforeEach(() => {
  getTestBed().configureCompiler({
    providers: ZOMBIE_COMPILER_PROVIDERS,
  });
});

// Then write your tests normally