首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >格式错误的Specrunner文件-grunt template-jasmine-requirejs

格式错误的Specrunner文件-grunt template-jasmine-requirejs
EN

Stack Overflow用户
提问于 2016-09-06 17:23:20
回答 1查看 186关注 0票数 2

我使用带有grunt-template-jasmine-requirejsgrunt-contrib-jasmine来生成模板。它在Node v0.12.14上运行良好,但当我升级到Nodev4.5.0时,我的specrunner文件输出格式错误。它在输出中包含大量的JavaScript和HTML语言。示例块:

代码语言:javascript
复制
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‘部分:

代码语言:javascript
复制
    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’发生了变化?以下是我正在使用的版本:

代码语言:javascript
复制
grunt-template-jasmine-requirejs 0.2.3
grunt-contrib-requirejs 1.0.0
grunt-contrib-jasmine 1.0.3
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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._,所以它将来可能需要重新寻址。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39345323

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档