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

React propTypes mutation. #1653

Closed
rodoabad opened this issue Jul 21, 2019 · 9 comments
Closed

React propTypes mutation. #1653

rodoabad opened this issue Jul 21, 2019 · 9 comments
Labels
⁉ Question Further information is requested

Comments

@rodoabad
Copy link

Question

When we're writing React component, we typically write propTypes validations so we know that the props we're passing to a component is of the correct type.

Stryker is mutating these though even though they are for development purposes.
Screen Shot 2019-07-21 at 6 41 29 PM

For those who have actually prevented Stryker from mutating these, what did you do?

@rodoabad rodoabad added the ⁉ Question Further information is requested label Jul 21, 2019
@bartekleon
Copy link
Member

For now i guess this is a bug. I don't see workaround. We might need to add some option to exclude given line or sth like this, the way it is done ex. in tslint or eslint

@simondel
Copy link
Member

Hi! Right now this is not possible to exclude. We have a general feature request for this: #1472
As there is a general issue open, I'm closing this issue for now.

@itsmeraji
Copy link

Hi, our team is interested in using Stryker to get the mutation test results, but almost all the files get this propTypes mutated and it brings the mutation test score down. We would like to know is there a possibility to exclude propTypes from getting mutated in Stryker. Is there any progress made on this?

@bartekleon
Copy link
Member

@itsmeraji I'll start working on #1472 very soon. It should be done until the end of this month I hope

@itsmeraji
Copy link

@kmdrGroch, Thank you for the reply. But will it be possible to add some configuration in Stryker.conf and disable proptypes mutation in all files automatically, based on the configuration ? If we have to add ignore comments, we ve to add ignore comment for proptypes in all the files..

@bartekleon
Copy link
Member

@itsmeraji, for now, we are only planning to add the comments-based exclusion. In the future, we could write some plugin for it, but no hopes right now.

@itsmeraji
Copy link

@kmdrGroch, is there any update on this feature? I see PR #1810 created for this.

@bartekleon
Copy link
Member

It is still being worked on. Unfortunately this issue is quite complex so it takes time :<

@itsmeraji
Copy link

@kmdrGroch , I understand. I have been trying other options to ignore prototypes from mutation. I wrote a custom transpiler to remove a node if it has propTypes in assignment expression. When applying this as plugin in Babel and Jest transform, propTypes gets removed when I run a test. But the plugins / transpilers options in Stryker configuration doesn't allow a custom transpiler plugin like this. Even the plugins option within the mutator object allows only the plugins provided within babel-parser. Do you have any suggestions for me here ? To make the custom transpiler get applied before Stryker generates mutants ? We are blocked due to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⁉ Question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants