TestBed Configuration (Optional)
As you will see in Testing Components, real-world component testing often relies on the Angular2 testing utility TestBed
, which requires some configuration. Most significantly, we need to use TestBed.initTestEnvironment
to create a testing platform before we can use unit tests with TestBed
. This testing environment would have to be created, destroyed and reset as appropriate before every unit test.
In the angular2-redux-starter, this configuration is done in a tests.configure.ts
file and imported into every unit test for easy re-use.
tests.configure.ts
creates the testing platform if it doesn't already exist, compiles the template, and exports configureTests
which can then be imported and used in our unit tests.
Here's a look at how it would be used:
Last updated