Skip to content

Instantly share code, notes, and snippets.

@marcellkiss
Created March 9, 2022 17:09
Show Gist options
  • Save marcellkiss/6580905537d2a2f2590f9b80d9cd746b to your computer and use it in GitHub Desktop.
Save marcellkiss/6580905537d2a2f2590f9b80d9cd746b to your computer and use it in GitHub Desktop.
Setting registerLocaleData once with jest
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import { LOCALE_ID } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import 'jest-preset-angular/setup-jest';
registerLocaleData(localeDe);
// Error message:
/*
The injectable 'PlatformLocation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.
The injectable is part of a library that has been partially compiled.
However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.
Ideally, the library is processed using the Angular Linker to become fully AOT compiled.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment