Created
July 1, 2014 14:13
-
-
Save bryanforbes/a29b0a173c09901c3e36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
grunt.loadNpmTasks('intern-geezer'); | |
var req = (function () { | |
this.dojoConfig = { | |
async: true, | |
baseUrl: __dirname, | |
packages: [ | |
{ name: 'intern', location: 'node_modules/intern-geezer' }, | |
{ name: 'when', location: 'node_modules/when', main: 'when' }, | |
{ name: 'dojo', location: '.' } | |
], | |
map: { | |
'*': { | |
'intern/dojo': 'intern/node_modules/dojo' | |
} | |
} | |
}; | |
require('intern-geezer/node_modules/dojo/dojo'); | |
return this.require; | |
})(); | |
grunt.initConfig({ | |
intern: { | |
local: { | |
options: { | |
runType: 'runner', | |
config: 'tests-intern/intern.local', | |
reporters: ['runner'] | |
} | |
}, | |
remote: { | |
options: { | |
runType: 'runner', | |
config: 'tests-intern/intern', | |
reporters: ['runner'] | |
} | |
}, | |
proxy: { | |
options: { | |
runType: 'runner', | |
proxyOnly: true, | |
config: 'tests-intern/intern.proxy', | |
reporters: ['runner'] | |
} | |
}, | |
node: { | |
options: { | |
runType: 'client', | |
config: 'tests-intern/intern', | |
reporters: ['console'] | |
} | |
} | |
} | |
}); | |
var servicesServer; | |
grunt.registerTask('proxy', function () { | |
var done = this.async(); | |
req(['dojo/tests-intern/services/main'], function (services) { | |
services.start().then(function (server) { | |
servicesServer = server; | |
done(true); | |
}); | |
}); | |
}); | |
grunt.registerTask('test', function (target) { | |
if (!target || target === 'coverage') { | |
target = 'remote'; | |
} | |
function addReporter(reporter, target) { | |
var property = 'intern.' + target + '.options.reporters', | |
value = grunt.config.get(property); | |
if (value.indexOf(reporter) !== -1) { | |
return; | |
} | |
value.push(reporter); | |
grunt.config.set(property, value); | |
} | |
if (this.flags.coverage) { | |
if (target === 'all') { | |
addReporter('combined', 'node'); | |
addReporter('combined', 'remote'); | |
} | |
else { | |
addReporter('lcovhtml', target); | |
} | |
} | |
if (this.flags.console) { | |
if (target === 'all') { | |
addReporter('console', 'node'); | |
addReporter('console', 'remote'); | |
} | |
else { | |
addReporter('console', target); | |
} | |
} | |
if (target !== 'node') { | |
grunt.task.run('proxy'); | |
} | |
if (target === 'all') { | |
grunt.task.run('intern:node'); | |
grunt.task.run('intern:remote'); | |
} | |
else { | |
grunt.task.run('intern:' + target); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment