首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nodejs上gulp + babel +茉莉花的测试

nodejs上gulp + babel +茉莉花的测试
EN

Stack Overflow用户
提问于 2015-11-02 22:23:54
回答 1查看 1K关注 0票数 2

我正在尝试用一元化茉莉花和古普-巴贝尔来测试我的代码:

代码语言:javascript
复制
var gulp = require("gulp"),
    jasmine = require("gulp-jasmine"),
    babel = require("gulp-babel");

module.exports = function () {
    gulp.src(["index.js", "src/**/*.js", "spec/**/*[sS]pec.js"])
        .pipe(babel({
            "presets": ["es2015"],
            "plugins": ["transform-runtime"]
        }))
        .pipe(jasmine())
};

我得到了

代码语言:javascript
复制
events.js:141
      throw er; // Unhandled 'error' event
      ^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at D:\creation\software developer\projects\javascript-project-template\node_modules\jasmine\lib\jasmine.js:63:5
    at Array.forEach (native)
    at Jasmine.loadSpecs (D:\creation\software developer\projects\javascript-project-template\node_modules\jasmine\lib\jasmine.js:62:18)

知道我错过了什么吗?代码似乎中断了,因为仍然使用ES6关键字。我不知道怎么解决这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-03 13:22:55

根据sindresorhus,lib只在文件路径上工作,因此我不能使用streams:https://github.com/sindresorhus/gulp-jasmine/issues/60#event-452847672

他建议采取这种办法:

代码语言:javascript
复制
require('babel-core/register');

var gulp = require("gulp"),
    jasmine = require("gulp-jasmine");

module.exports = function () {
    gulp.src(["index.js", "src/**/*.js", "spec/**/*[sS]pec.js"])
        .pipe(jasmine({
            includeStackTrace: true
        }))
};
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33488140

复制
相关文章

相似问题

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