Skip to content

Commit

Permalink
improvement: run single test with mochacli
Browse files Browse the repository at this point in the history
  • Loading branch information
kirrg001 committed May 25, 2016
1 parent d269358 commit 85e2122
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Gruntfile.js
Expand Up @@ -18,7 +18,6 @@ var _ = require('lodash'),
cwd = process.cwd().replace(/( |\(|\))/g, escapeChar + '$1'),
buildDirectory = path.resolve(cwd, '.build'),
distDirectory = path.resolve(cwd, '.dist'),
mochaPath = path.resolve(cwd + '/node_modules/.bin/mocha'),
emberPath = path.resolve(cwd + '/core/client/node_modules/.bin/ember'),

// ## Grunt configuration
Expand Down Expand Up @@ -208,7 +207,10 @@ var _ = require('lodash'),
src: [
'core/test/functional/module/**/*_spec.js'
]
}
},

// #### Run single test (src is set dynamically, see grunt task 'test')
single: {}
},

// ### grunt-mocha-istanbul
Expand Down Expand Up @@ -289,12 +291,6 @@ var _ = require('lodash'),
}
},

test: {
command: function (test) {
return 'node ' + mochaPath + ' --timeout=15000 --ui=bdd --reporter=spec --colors core/test/' + test;
}
},

shrinkwrap: {
command: 'npm shrinkwrap'
},
Expand Down Expand Up @@ -501,7 +497,18 @@ var _ = require('lodash'),
grunt.fail.fatal('No test provided. `grunt test` expects a filename. e.g.: `grunt test:unit/apps_spec.js`. Did you mean `npm test` or `grunt validate`?');
}

grunt.task.run('test-setup', 'shell:test:' + test);
test = 'core/test/' + test;

// CASE: execute folder
if (!test.match(/.js/)) {
test += '/**';
} else if (!fs.existsSync(test)) {
grunt.fail.fatal('This file does not exist!');
}

cfg.mochacli.single.src = [test];
grunt.initConfig(cfg);
grunt.task.run('test-setup', 'mochacli:single');
});

// ### Validate
Expand Down

0 comments on commit 85e2122

Please sign in to comment.