ngtsc has a robust suite of testing utilities, designed for in-memory testing of a TypeScript compiler. Previously these utilities lived in the `test` directory for the compiler-cli package. This commit moves those utilities to an `ngtsc/testing` package, enabling them to be depended on separately and opening the door for using them from the upcoming language server testing infrastructure. As part of this refactoring, the `fake_core` package (a lightweight API replacement for @angular/core) is expanded to include functionality needed for Language Service test use cases. PR Close #39594
893 B
893 B
fake_core
is a library designed to expose some of the same symbols as @angular/core
, without
requiring compilation of the whole of @angular/core
. This enables unit tests for the compiler to
be written without incurring long rebuilds for every change.
@angular/core
is compiled with@angular/compiler-cli
, and therefore has an implicit dependency on it. Therefore core must be rebuilt if the compiler changes.- Tests for the compiler which intend to build code that depends on
@angular/core
must have a data dependency on@angular/core
. Therefore core must be built to run the compiler tests, and thus rebuilt if the compiler changes.
This rebuild cycle is expensive and slow. fake_core
avoids this by exposing a subset of the
@angular/core
API, which enables applications to be built by the ngtsc compiler without
needing a full version of core present at compile time.