Skip to content Skip to sidebar Skip to footer

Trouble Running Qunit Tests With Static Server Using Grunt

Running the tests via a web browser works fine, but using grunt gives me errors. I struggle to understand what I'm doing wrong here. grunt tests fails with $ grunt tests Running 'j

Solution 1:

You'll need to run your Node server as another step in your grunt process. There is a grunt task for specifically running Express servers, I'd recommend starting there. Here's what the grunt config might look like:

grunt.initConfig({
    // ...
    express: {  // this is the new task...
      dev: {
        options: {
          script: 'path/to/main.js'
        }
      }
    },
    connect: {
      server: {
        options: {
          port: 3000,  // I changed this so it doesn't conflict with your express app
          base: '.'
        }
      }
    },
    qunit: {
      all: {
        options: {
          urls: [
            'http://localhost:3000/tests/tests.html'  // changed this as well
          ]
        }
      }
    }
});

Then you'll want to run all three tasks as your "test" run. You can create an alias like so:

grunt.registerTask('tests', ['jsonlint', 'jshint', 'express', 'connect', 'qunit']);


Post a Comment for "Trouble Running Qunit Tests With Static Server Using Grunt"