我正在关注本教程:https://gist.github.com/maicki/7781943
这是我的grunt文件:
// Gruntfile.js
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Mocha
mocha: {
all: {
src: ['tests/spec.html']
},
options: {
run: true,
reporter: 'Spec',
growlOnSuccess: false
}
}
});
//Load grunt mocha task
grunt.loadNpmTasks('grunt-mocha')
grunt.registerTask('default', ['mocha']);
};
除了本指南建议的内容之外,我还设置了以下内容:
ran bower init inside of the tests folder.
generating the following:
"description": "",
"main": "",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
我完成此操作是因为在运行该命令之前未找到测试。
当我从命令行运行grunt时,将得到以下信息:测试:tests / spec.html
0传递(0ms)
0通过! (0.00秒)
这里是要点,其中包含spec.html页和具有单元测试的webspec.js页:https://gist.github.com/dhuang612/83dcba46e0a70c107a3e081c5e5dca12
谢谢您提供的任何帮助!
我进行了更多研究后发现
https://github.com/shellscape/mocha-chrome
我能够将其配置为在命令行中运行浏览器测试。然后,我使用了另一个同时调用的npm软件包来同时运行单元测试和浏览器测试。