Phantomjs grunt qunit与grunt服务器一起使用
在运行Phantomjs grunt qunit与grunt服务器一起使用,phantomjs,gruntjs,qunit,grunt-contrib-qunit,Phantomjs,Gruntjs,Qunit,Grunt Contrib Qunit,在运行grunt服务器进行开发时,我如何单独使用grunt qunit任务来运行测试。 试图将[“test/***/.html”]传递给all属性时,该属性无法运行并返回(警告:0/0断言运行(0ms)使用) 看起来,它没有触发phantomjs实例,也没有找到这些脑袋。 所以我尝试了以下方法 grunt.initConfig({ .... qunit: { all: { options: {
grunt服务器
进行开发时,我如何单独使用grunt qunit
任务来运行测试。
试图将[“test/***/.html”]
传递给all
属性时,该属性无法运行并返回(警告:0/0断言运行(0ms)使用
)
看起来,它没有触发phantomjs实例,也没有找到这些脑袋。
所以我尝试了以下方法
grunt.initConfig({
....
qunit: {
all: {
options: {
urls: ['http://localhost:<%= connect.options.port %>/test/tests/foo.html']
}
}
}
....
});
grunt.initConfig({
....
昆特:{
全部:{
选项:{
网址:['http://localhost:/test/tests/foo.html']
}
}
}
....
});
仅当手动包含所有测试html页面(如示例中所示)时,它才起作用。问题是 我的问题是,即使使用grunt服务器,grunt qUnit也能正常工作吗。 以及如何使
[“test/***/.html”]
语法正确工作。我相信一定有更好的方法可以做到这一点!
另外,如何使用grunt.file.expand以编程方式添加匹配文件以在grunt qunit任务中运行。我做了如下操作:
grunt.initConfig({
...
'qunit': {
'files': ['test/**/*.html']
}
...
});
...
// Wrap the qunit task
grunt.renameTask('qunit', 'contrib-qunit');
grunt.registerTask('qunit', function(host, protocol) {
host = host || 'localhost';
protocol = protocol || 'http';
// Turn qunit.files into urls for conrib-qunit
var urls = grunt.util._.map(grunt.file.expand(grunt.config.get('qunit.files')), function(file) {
return protocol + '://' + host + '/' + file;
});
var config = { 'options': { 'urls' : urls } };
grunt.config.set('contrib-qunit.all', config);
grunt.task.run('contrib-qunit');
});