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

Can't get this to run #47

Closed jdinard closed 8 years ago

jdinard commented 8 years ago

Neat plugin but unfortunately all I can get this to do is:

`Running "mutationTest:target" (mutationTest) task Warning: Not all required options have been set properly Used --force, continuin g. Warning: Cannot read property 'testFramework' of null Used --force, continuing.

Done, but with warnings.`

I have mocha installed. Not sure why this is being thrown.

Gruntfile is configured like this: mutationTest: { options: { code: 'test/setup.js', specs: 'test/component/test.js', mutate: 'src/scripts/testing/QuestionStoreTest.js', }, target: { code: ['src/scripts/stores/testing/*.js', 'src/mutations/*.js'], specs: 'test/setup.js', mutate: 'src/scripts/stores/testing/*.js' } }

After changing the mutationTest command to: mutationTest: { mocha: { options: { code: 'test/setup.js', specs: 'test/component/test.js', mutate: 'src/scripts/testing/QuestionStoreTest.js', ignore: /^\s*log\(/, ignoreReplacement: [/^console$/], reporters: { text: { file: 'mocha.txt' } } } } },

The same issue persists.

Some more documentation, or an example project would be greatly appreciated!

jimivdw commented 8 years ago

Hi,

The documentation on the configuration could indeed be improved. Creating an example project is also a great idea. For now you could have a look at https://github.com/jimivdw/grunt_playground/tree/grunt-mutation-testing_demo, but I've created two new issues to both improve documentation (#48) and create a proper example project (#49).

Now for your configuration issue: the thing you're missing is that, also in your target, you need to wrap the configuration in an options object. It should then look something like the following:

mutationTest: {
  options: {
    testFramework: 'mocha'
  },
  target: {
    options: {
      code: <YOUR SOURCE CODE FILES (probably something like 'src/*.js')>,
      specs: <YOUR TEST FILES (probably something like 'test/*.js')>,
      mutate: <THE SOURCE FILES YOU WISH TO MUTATE (probably something like 'src/scripts/*.js')>
    }
  }
}

I hope this helps. Please reopen the issue if you still cannot get it to run.

-- Jimi