You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 291b7ea
Browse filesBrowse the repository at this point in the historyBrowse files
feat(babel): update babel to major version 8 (#6104)
This updates Babel to version 8, which was a long time in the works. If you're using the type-safety feature of the ignorer plugin, you will need to use a different approach.
```ts
import { PluginKind, declareValuePlugin } from '@stryker-mutator/api/plugin';
import { babel } from '@stryker-mutator/core;
export const strykerPlugins = [declareValuePlugin(PluginKind.Ignore, 'MyIgnorer', {
shouldIgnore(path: babel.NodePath) {
// Define the conditions for which you want to ignore mutants
}
})];
```
See the [ignorer-plugin documentation](https://stryker-mutator.io/docs/stryker-js/disable-mutants/#using-an-ignore-plugin).
| 9.7 | Added the `type babel` to the export `@stryker-mutator/core`|
193
+
194
+
</details>
186
195
187
196
You might not be interested in testing specific code patterns in some projects. You can use `// Stryker disable` comments for these. However, this gets tedious quickly.
188
197
@@ -213,23 +222,25 @@ Now add a "stryker-console-ignorer.js" to your project:
return"We're not interested in testing `console.debug` statements, see ADR 648.";
240
+
}
241
+
},
242
+
}),
243
+
];
233
244
```
234
245
235
246
In the above example, you declare an ignore-plugin with the name `'console.debug'` and an `Ignorer`. An `Ignorer` is an object with a `shouldIgnore(path)` method. Stryker will execute this method on each node of the abstract syntax tree (AST). To ignore mutants in the current node and child nodes, return a non-empty ignore reason as a string here. The `path` parameter is a babel `NodePath` object, [see 'visiting' in the babel handbook](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md#user-content-visiting) for more information on the `NodePath` API.
@@ -249,17 +260,44 @@ After rerunning Stryker, your report will look like this.
249
260
250
261
:::tip
251
262
252
-
If you want TypeScript type-safety on the `path` being passed into your ignore-plugin, you will need to install the babel types yourself: `npm i -D @types/babel__core` and add this TypeScript file somewhere in your project:
If you want to write the plugin itself as TypeScript as well, you will need to transpile it to JavaScript yourself. Either by doing it before you run Stryker, or using a just-in-time compiler like `tsx`.
263
+
If you want TypeScript to type-check the `path` passed to your ignore plugin, use `NodePath` from `@stryker-mutator/core`.
264
+
265
+
1. Rename your plugin to `.ts`.
266
+
- Don't forget to also update the `"plugins"` in your Stryker config file.
0 commit comments