2

grunt-contrib-jasminewithを使用しgrunt-template-jasmine-requirejsてテンプレートを生成しています。Node v0.12.14 では問題なく動作していましたが、Node v4.5.0 にアップグレードすると、specrunner ファイルの出力が正しくありません。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」セクションです。

    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
4

1 に答える 1

0

Grunt v1.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

ただし、このフォークは現在非推奨の を引き続き使用しているgrunt.util._ため、将来的に再アドレス指定が必要になる場合があります。

于 2016-09-07T07:49:33.400 に答える