Skip to content

Commit

Permalink
feat(ignore): add "angular" ignore plugin (#4789)
Browse files Browse the repository at this point in the history
Add a new ignore plugin to avoid errors using the latest Angular `input`, `model`, and `output` functions. Without it, the options object inside the function can be mutated, leading to errors with the Ivy compiler.

Also document it in the Angular guide and add the plugin by default in the angular initializer

---------
Co-authored-by: Nico Jansen <jansennico@gmail.com>
  • Loading branch information
kal-rein authored Sep 29, 2024
1 parent aaf0ba1 commit 5d792d8
Show file tree
Hide file tree
Showing 23 changed files with 5,009 additions and 3,728 deletions.
8 changes: 5 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,13 @@ Default: `[]`<br />
Command line: _none_<br />
Config file: `"ignorers": ["console.debug"]`<br />

Specify which ignore-plugins to use. With an ignore-plugin you can ignore mutants inside common code patterns that you don't want to test for some reason. For example, you can use this to ignore all `console.debug()` statements from being mutated.
Specify which ignore-plugins to use. With an ignore-plugin, you can skip mutating specific code patterns that you don't want to test or cannot be mutated. For example, you may use an ignore-plugin to exclude all `console.debug()` statements from mutation testing.

You only specify the name of the plugins here. The plugin's implementation must be loaded using a separate file, which must be listed in your [plugins array](#plugins-string).
Here's a list of built-in ignore plugins:

See [using an ignore-plugin](./disable-mutants.md#using-an-ignore-plugin) for more information.
- `"angular"`: Ignores mutating of code in an Angular application that is required to be static by the Angular Compiler. This includes `input()`, `output()` and `model()` option objects. This should be enabled for all Angular projects.

To create your own ignore plugin, implement it in a separate file and load it by specifying its name in the [plugins array](#plugins-string). For more details, see [Using an Ignore-Plugin](./disable-mutants.md#using-an-ignore-plugin).

### `ignoreStatic` [`boolean`]

Expand Down
3 changes: 2 additions & 1 deletion docs/guides/angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The `npm init stryker` command also creates a `stryker.config.json` or `stryker.
}
},
"reporters": ["progress", "clear-text", "html"],
"ignorers": ["angular"],
"concurrency": 4,
"concurrency_comment": "Recommended to use about half of your available cores when running stryker with angular"
}
Expand Down Expand Up @@ -92,6 +93,7 @@ Create a `stryker.config.json` file with the following content:
}
},
"testRunnerNodeArgs": ["--experimental-vm-modules"],
"ignorers": ["angular"],
"reporters": [
"progress",
"clear-text",
Expand Down Expand Up @@ -119,7 +121,6 @@ Consider adding the Stryker TypeScript checker to increase mutation testing perf
```
If you experience issues, try setting the `tsconfigFile` option to `tsconfig.app.json`.


## Troubleshooting

Please take a look at the [troubleshooting page](../troubleshooting.md) when you run into any problems setting up StrykerJS.
6 changes: 3 additions & 3 deletions e2e/test/angular-project/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "angular-project:build:production"
"buildTarget": "angular-project:build:production"
},
"development": {
"browserTarget": "angular-project:build:development"
"buildTarget": "angular-project:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-project:build"
"buildTarget": "angular-project:build"
}
},
"test": {
Expand Down
Loading

0 comments on commit 5d792d8

Please sign in to comment.