javascript - Issue a unit test on a Gulp file using Karma & Jasmine -


i wrote unit test gulp file. test runs through karma using jasmine framework (safari/chrome). knowing karma runs test file, specified in json config file, in browser, should have way run node's modules in browser. after researching, found using browserify i'll able require modules in browser.

when write command

browserify ./test/gulptest.js -o ./test/test.js -d

the new test.js seems big

and run following command start test on new test.js

karma start karma.conf.js

i error:

gulp input stream ✗ should compile ts js typeerror: cannot read property 'istty' of undefined @ object. (/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): executed 1 of 1 (1 failed) error (0.037 secs / 0.03 secs)

    it("should compile ts 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 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,                                  // not emit comments output.                                  removecomments : false,                                  // warn on expressions , declarations implied 'any' type.                                  noimplicitany : false,                                  // skip resolution , 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");             });  }); 

you can't run gulp inside karma , jasmine—you're running if front-end library, , not.

you need use back-end testing library. can still use jasmine, have use through nodejs, how gulp runs: https://www.npmjs.com/package/jasmine

you might interested see how wrote unit tests gulp tasks work: https://github.com/lostmyname/lmn-gulp-tasks/tree/master/test


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -