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

Exclude code with regex #2966

Closed
ZHeadlee opened this issue Jun 23, 2021 · 4 comments
Closed

Exclude code with regex #2966

ZHeadlee opened this issue Jun 23, 2021 · 4 comments
Labels
🚀 Feature request New feature request ☠ stale Marked as stale by the stale bot, will be removed after a certain time.

Comments

@ZHeadlee
Copy link

Is your feature request related to a problem? Please describe.
My project uses material-ui's style engine, so the CSS is included in the JS files. Stryker mutates the CSS, but this doesn't affect the functionality of the unit tests at all, so it is not useful. I have a similar issue with the prop-types library which does runtime type checking. Mutating this section also doesn't do anything, so I would like to exclude it.

Describe the solution you'd like
I would like to be able to exclude some of the code in a file from mutation specified via RegEx, for example:

Exclude the "makeStyles" CSS engine section of my code which looks like this:

const useStyles = makeStyles((theme) => ({
  button: {
    margin: theme.spacing(1),
  },
  buttonContainer: {
    display: 'flex',
    justifyContent: 'space-between',
  },
  caption: {
    textAlign: 'center',
    marginTop: '15%',
  },
  textField: { margin: theme.spacing(1) },
}));

with this expression: /.*makeStyles\(\((.|\n)*\}\)\).*/

Describe alternatives you've considered
I have considered using the mutation range config to specify what lines to mutate, but this would be tedious to do for my entire project, and my team would have to remember to update the lines any time the code is changed.

@nicojs
Copy link
Member

nicojs commented Jul 6, 2021

Yeah, I've been thinking about this a lot. Would #1472 be something that could work for you? I think we would need a more robust solution in the future, but #1472 is being worked on a.t.m.

@nicojs
Copy link
Member

nicojs commented Aug 26, 2021

The solution that I want to add is allowing for ignore-plugins. The idea is simple: it is provided a babel AST node, and it returns a boolean (or something like that) that specifies if the AST node should be ignored or not. But I first want to close #3072 .

@stale
Copy link

stale bot commented Sep 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the ☠ stale Marked as stale by the stale bot, will be removed after a certain time. label Sep 4, 2022
@stale stale bot closed this as completed Oct 8, 2022
@nicojs
Copy link
Member

nicojs commented Oct 17, 2023

Ignore-plugins are released in StrykerJS 7.3 🎉 . Ignoring something like makeStyles should be pretty easy, if you want help please don't hesitate to ask.

https://twitter.com/stryker_mutator/status/1713557660832792870

https://stryker-mutator.io/docs/stryker-js/disable-mutants/#using-an-ignore-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature request ☠ stale Marked as stale by the stale bot, will be removed after a certain time.
Projects
None yet
Development

No branches or pull requests

2 participants