【发布时间】:2015-11-12 19:58:27
【问题描述】:
我为 Gulp 文件编写了一个单元测试。该测试使用 Jasmine 框架 (safari/chrome) 通过业力运行。 知道 Karma 在浏览器中运行 json 配置文件中指定的测试文件,它应该有办法在浏览器中运行 Node 的模块。 经过研究,我发现通过使用 Browserify,我将能够在浏览器中加载模块。
当我写这个命令时
浏览 ./Test/GulpTest.js -o ./Test/TEST.js -d
新的 TEST.js 好像很大
然后我运行以下命令在新的 TEST.js 上开始测试
业力启动 karma.conf.js
我收到此错误:
gulp 输入流 ✗ 应该从 ts 编译到 js TypeError: Cannot read property 'isTTY' of undefined 在对象。 (/Users/Snap/Desktop/Demo App/Test/TEST.js:75226:20) 在 Object.252._process (/Users/Snap/Desktop/Demo App/Test/TEST.js:75284:4) 在 s (/Users/Snap/Desktop/Demo App/Test/TEST.js:1:254) 在 /Users/Snap/Desktop/Demo App/Test/TEST.js:1:305 在 Object.31../lib/PluginError (/Users/Snap/Desktop/Demo App/Test/TEST.js:3530:9) 在 Object.239../lib/PluginError (/Users/Snap/Desktop/Demo App/Test/TEST.js:75113:21) 在 s (/Users/Snap/Desktop/Demo App/Test/TEST.js:1:254) 在 /Users/Snap/Desktop/Demo App/Test/TEST.js:1:305 在 Object.229.deprecated (/Users/Snap/Desktop/Demo App/Test/TEST.js:74824:13) 在 s (/Users/Snap/Desktop/Demo App/Test/TEST.js:1:254)
Chrome 44.0.2403 (Mac OS X 10.10.4):执行 1 of 1 (1 FAILED) 错误 (0.037 秒 / 0.03 秒)
it("should compile from ts to js", function () {
var gulp = require("gulp");
var ts = require("gulp-typescript");
var lazy = require("gulp-load-plugins");
var fs = require('graceful-fs');
var should = require('should');
var join = require('path').join;
/*
* * * Compile Typescript to JavaScript
*/
gulp.task("ts-compiler", function () {
return gulp.src("./Test/lib/file.ts")
.pipe(lazy.typescript({
// Generates corresponding .map file.
sourceMap : false,
// Generates corresponding .d.ts file.
declaration : true,
// Do not emit comments to output.
removeComments : false,
// Warn on expressions and declarations with an implied 'any' type.
noImplicitAny : false,
// Skip resolution and preprocessing.
noResolve : false,
// Specify module code generation: 'commonjs' or 'amd'
module : "amd",
// Specify ECMAScript target version: 'ES3' (default), or 'ES5'
target : "ES5"
}))
.pipe(gulp.dest("./Test/lib/dest"));
});
gulp.start("ts-compiler", function () {
console.log("compiling...");
should.exist("./Test/lib/dest/file.js");
});
});
【问题讨论】:
标签: javascript jasmine gulp karma-runner browserify