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 higher
This 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.
Either 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
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
stryker init command also creates a
stryker.config.mjs 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.
"_comment": "This config was generated using a preset. Please see website for more information: https://stryker-mutator.io/docs/stryker-js/guides/angular",
"mutate": ["src/**/*.ts", "!src/**/*.spec.ts", "!src/test.ts", "!src/environments/*.ts"],
"reporters": ["progress", "clear-text", "html"],
"concurrency_comment": "Recommended to use about half of your available cores when running stryker with angular",
Consider adding the Stryker TypeScript checker to increase mutation testing performance and kill mutants that would result in compilation errors:
@stryker-mutator/typescript-checkeras a development dependency:
npm install --save-dev @stryker-mutator/typescript-checker
- Configure the TypeScript checker in
stryker.config.json:If you experience issues, try setting the
Run Stryker using
Please take a look at the troubleshooting page when you run into any problems setting up StrykerJS.