我使用带有grunt-template-jasmine-requirejs的grunt-contrib-jasmine来生成模板。它在Node v0.12.14上运行良好,但当我升级到Nodev4.5.0时,我的specrunner文件输出格式错误。它在输出中包含大量的JavaScript和HTML语言。示例块:
function (obj) {
obj || (obj = {});
var __t, __p = '', __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
with (obj) {
__p += '<!doctype html>\n<html>\n<head>\n <meta charset="utf-8">\n <title>Jasmine Spec Runner</title>\n\n ';
css.forEach(function(style){ ;
__p += '\n <link rel="stylesheet" type="text/css" href="' +
((__t = ( style )) == null ? '' : __t) +
'">\n ';
}) ;
__p += '\n\n ';
with (scripts) { ;
__p += '\n ';
[].concat(vendor).forEach(function(script){ ;
__p += '\n <script src="' +
((__t = ( script )) == null ? '' : __t) +
'"></script>\n ';下面是我的Gruntfile中的'jasmine‘部分:
jasmine: {
test: {
options: {
vendor: ["src/libs/jquery.js"],
display: "short",
summary: true,
specs: ['test/test.js'],
styles: ['src/css/main.css'],
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: 'src/',
paths: {
"test": "../test",
"jquery-1.9": "jquery-1.9.1"
}
}
}
}
}
}是不是有一些我不知道的'grunt-template-jasmine-requirejs‘的'templateOptions’发生了变化?以下是我正在使用的版本:
grunt-template-jasmine-requirejs 0.2.3
grunt-contrib-requirejs 1.0.0
grunt-contrib-jasmine 1.0.3发布于 2016-09-07 15:49:33
自更新到GruntV1.0.1以来,问题出在包grunt-template-jasmine-requirejs上,该包已不再维护。它应该以不同的方式处理模板:grunt.util._.template(source, context)应该是grunt.util._.template(source)(context)。而且,它使用的Lodash版本与我们的Lodash版本冲突。
这里有一个解决这些问题的分支:https://github.com/radum/grunt-template-jasmine-requirejs/tree/7ca7ad28b1bbb7a940de7a01710f62c5b0eb6a65
但是,这个fork仍然使用现在不推荐使用的grunt.util._,所以它将来可能需要重新寻址。
https://stackoverflow.com/questions/39345323
复制相似问题