Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instrumenter): harden the instrumenter #2490

Merged
merged 2 commits into from
Sep 21, 2020

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Sep 21, 2020

Fixes #2399

Improve the invalid mutant placement error using `nodePath.buildCodeFrameError`.

This:

> Stryker Error: Error while placing mutants of type(s) "StringLiteral" on 52:15 with expressionMutantPlacer. TypeError: Property id of DeclareModule expected node to be of a type ["Identifier","StringLiteral"] but instead got "SequenceExpression"

Becomes:
> SyntaxError: packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js:52:15 expressionMutantPlacer could not place mutants with type(s): "StringLiteral". Either remove this file from the list of files to be mutated, or ignore the mutators. Please report this issue at https://github.com/stryker-mutator/stryker/issues/new?assignees=&labels=%F0%9F%90%9B+Bug&template=bug_report.md&title=expressionMutantPlacer%20could%20not%20place%20mutants%20with%20type(s)%3A%20%22StringLiteral%22.
>   50 | };
>   51 |
> > 52 | declare module 'react-test-renderer' {
>      |                ^^^^^^^^^^^^^^^^^^^^^
>   53 |   // eslint-disable-next-line no-inner-declarations
>   54 |   declare export type ReactTestRenderer = {
>   55 |     toJSON(): null | ReactTestRendererJSON,
Ignore `declare` syntax in flow and ts files when instrumenting the code. Some examples:

```js
declare module 'react-test-renderer' {
  // eslint-disable-next-line no-inner-declarations
}
declare type ReactTestRenderer = {
};

declare type Thenable = {
};

declare function create(
): ReactTestRenderer;

declare function act(callback: () => ?Thenable): Thenable;

declare const foo: string;
declare function bar(): 'bar';
```
@nicojs nicojs merged commit b1faa16 into epic/mutation-switching Sep 21, 2020
@nicojs nicojs deleted the fix/instrument-declare-statements branch September 22, 2020 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String literal mutator should not mutate DeclareModule node types
1 participant