Skip to content

Using Intern with Grunt

Colin Snover edited this page Jun 9, 2013 · 14 revisions

Grunt support is built into Intern. Install Intern and load the Grunt task into your Gruntfile using grunt.loadTasks('path/to/intern/grunt'); (Intern 1.0) or grunt.loadNpmTasks('intern') (Intern 1.1+).

An example of the Grunt Intern task is available in the intern-examples repository.

Task Options

Options available when running Intern using Grunt are the same as the options available when running Intern directly from the command-line, plus the following additional options:

Name
Default
Description
runType
client
The execution mode in which Intern should be run. This may be either "runner" for the automated test runner, or "client" for the Node.js client.
sauceUsername
(none)
The username for authentication with Sauce Labs.
sauceAccessKey
(none)
The access key for authentication with Sauce Labs.

Gruntfile example

grunt.initConfig({
    intern: {
        someReleaseTarget: {
            options: {
                runType: 'runner', // defaults to 'client'
                config: 'tests/intern',
                reporters: [ 'console', 'lcov' ],
                suites: [ 'myPackage/tests/all' ]
            }
        },
        anotherReleaseTarget: { /* ... */ }
    }
});

// Load the Intern task
grunt.loadNpmTasks('intern');

// Register a test task that uses Intern
grunt.registerTask('test', [ 'intern' ]);

// By default we just test
grunt.registerTask('default', [ 'test' ]);