jdcataldo / grunt-mocha-phantomjs

A simple grunt wrapper for mocha-phantomjs to allow for ci integration
MIT License
70 stars 40 forks source link

Cannot dynamically alter the watched files #23

Closed fatso83 closed 10 years ago

fatso83 commented 10 years ago

I am trying to use the watch event triggered by grunt-contrib-watch to only run tests on the files that have been changed. Unfortunately grunt-mocha-phantomjs does not seem to pick up the new options.

Basically I am doing this :

    grunt.initConfig({
        mocha_phantomjs : {
            all     : ['develop/test/**/*.html']
        }
    );

    grunt.event.on('watch', function(action, filepath) {
        grunt.config('mocha_phantomjs.all', [filepath]);
    });

I can see the value changing, but the value is simply not being picked up after loading the task. Is there any way of making them be picked up?

jdcataldo commented 10 years ago

Just pushed an example here and it is definitely working correctly: https://github.com/jdcataldo/grunt-mocha-phantomjs/commit/197c8af4f0fad1aaec257ca7cee23a4659c3b11a

If you make a change to two.html, the task will kick off with that test file only.

How is your watch task setup?

fatso83 commented 10 years ago

Thanks for the quick reply. My watch setup was pretty much like, but the cause of grief was this missing piece of configuration of the grunt watch task

   watch : {
      options: {
        spawn: false
      },

BTW: I used the simplified array syntax that I had seen in the examples for specifying files. Although I have been been looking through lots of Grunt documentation, I have yet to understand in what way it differs from "the long form". Do you have any pointers for documentation on that format?