$ npm install --save-dev mocha
$ mkdir public/vendor
$ cp node_modules/mocha/mocha.js public/vendor
$ cp node_modules/mocha/mocha.css public/vendor
$ npm i -D chai
$ cp node_modules/chai/chai.js public/vendor
$ sudo npm install -g grunt-cli
$ npm install --save-dev grunt
$ npm install --save-dev grunt-cafe-mocha
$ npm install --save-dev grunt-contrib-jshint
$ npm install --save-dev grunt-exec
module.exports = function(grunt) {
// 加载插件,forEach 遍历
[
'grunt-cafe-mocha',
'grunt-contrib-jshint',
'grunt-exec',
].forEach(function(task){
grunt.loadNpmTasks(task);
});
// 配置插件
grunt.initConfig({
cafemocha: {
all: { src: 'qa/tests-*.js', options: { ui: 'tdd' }, }
},
jshint: {
app: ['meadowlark.js', 'public/js/**/*.js','lib/**/*.js'],
qa: ['Gruntfile.js', 'public/qa/**/*.js', 'qa/**/*.js'],
},
exec: {
linkchecker: { cmd: 'linkchecker http://localhost:3000' }
},
});
// 注册任务
grunt.registerTask('default', ['cafemocha','jshint','exec']);
};