jimivdw / grunt-mutation-testing

JavaScript Mutation Testing as grunt plugin. Tests your tests by mutating the code.
MIT License
51 stars 11 forks source link

exclude files from mutation #40

Closed taylor1791 closed 9 years ago

taylor1791 commented 9 years ago

My projects structure is set up like this.

js
├── calc.js
└── calc.test.js

How can I exclude calc.test.js from the files for mutation? Here is what I tried.

options: {
  code: ['js/*.js'],
  specs: ['js/*.test.js'],
  mutate: ['js/*.js', '!js/calc.test.js']
}

I believe that ['js/*.js', '!js/calc.test.js'] is supported my minimatch and grunt, but it doesn't appear to work here. Is there something to mark files not to be mutated?

jimivdw commented 9 years ago

Hi Taylor,

Good find. I've only now noticed that we handle these configuration options in a way that is slightly different from the default behaviour, which means that you, indeed, cannot simply exclude files in the way you describe. It is still possible, however, to exclude your calc.test.js in our current setup. What you would want to do is the following:

options: {
  code: ['js/!(*.test).js'],
  specs: ['js/*.test.js'],
  mutate: ['js/!(*.test).js']
}

Note that it is also important not to match your spec files in the code configuration (mainly for performance reasons).

I will create a separate issue for us to investigate changing the configuration in a way that it behaves similar to the Grunt default. However, as we are currently focusing mainly on splitting the codebase into separate projects for mutations, karma, mocha, and grunt, it might take a while before we can implement it. You could always try to have a look at it yourself and submit a pull request, if you need it any time soon :-).

-- Jimi

taylor1791 commented 9 years ago

I just want to thank you for getting back to me. I really appreciate it. I probably will not take a stab at it. All I need is a way to exclude files and you provided the method. The exact syntax doesn't really matter to me. I can imagine that for some people this may not be the case, but we will let them speak up on #43 if they are here.