Angular
Stryker 4.0 and higher supports Angular projects using the Angular CLI starting from @angular/cli v9.0.0. Are you using an older version? Then there are some tips later in this document.
#
@angular/cli 9.0.0 and higherThis setup only works with @angular/cli 9.0.0 or higher. Are you using an older version of Angular? Then we highly suggest upgrading to at least version 9.0.0 of the cli. You can use the Angular Update Guide to help you with this. If it's not possible for you to upgrade your Angular version, please check out the legacy guide for Stryker 3 and Angular CLI 6.1-8.2.
#
InstallEither install the Stryker CLI globally using npm install --global stryker-cli
, or use npx
in front of every Stryker command.
Install the Stryker packages using the command stryker init
.
Recommended other packages:
- @angular/cli 9.0.0 or higher
- @angular-devkit/build-angular 0.900.0 or higher
- karma 4.3.0 or higher
- typescript 3.7.2 or higher
#
ConfigurationThe stryker init
command also creates a stryker.conf.json
or stryker.conf.js
configuration in your repository
like the one below which is a good starting point for Angular projects.
You may have to change some paths or config settings like the selected browsers.
We highly suggest using a headless browser when testing using Stryker.
Consider adding the Stryker TypeScript checker to increase mutation testing performance and kill mutants that would result in compilation errors:
- Install
@stryker-mutator/typescript-checker
as a development dependency:npm install --save-dev @stryker-mutator/typescript-checker
- Configure the TypeScript checker in
stryker.conf.json
:If you experience issues, try setting thetsconfigFile
option totsconfig.app.json
.
#
RunRun Stryker using stryker run
.