node.js - Can I change the output of jasmine-node to show the passing tests in the console as well as the failing? -
i have following file runs when run node test.js
.
var jasmine = require('jasmine'); var jasmine = new jasmine(); var request = require('request'); describe("test", function(){ it("works", function(){ expect(5 + 2).toequal(4); }); it("should respond hello world", function(done){ request('http://localhost:3000/', function(err, res, body){ expect(body).toequal('hello world'); done(); }) }); }) jasmine.execute();
and gives me following output:
started f. failures: 1) test works message: expected 7 equal 4. stack: error: expected 7 equal 4. @ object.<anonymous> 2 specs, 1 failure finished in 0.037 seconds
obviously 1 fails, showing f, , 1 passes, showing dot. can change configuration have show both passing , failing tests?
you'll want use custom reporter. recommend using jasmine-console-reporter, give nicely formatted output include tests ran (not failed ones). original script change following:
var jasmine = require("jasmine"); var jasmine = new jasmine(); var request = require('request'); // register custom reporter const reporter = require('jasmine-console-reporter'); jasmine.jasmine.getenv().addreporter(new reporter()); describe("test", function(){ it("works", function(){ expect(5 + 2).toequal(4); }); it("should respond hello world", function(done){ request('http://localhost:3000/', function(err, res, body){ expect(body).toequal('hello world'); done(); }) }); }) jasmine.execute();
note if using jasmine command line run tests (and jasmine has exported helpers namespace), code follows:
const reporter = require('jasmine-console-reporter'); jasmine.getenv().addreporter(new reporter());
i find easiest use gulp , gulp-jasmine make definition clear , in 1 place, while allowing me run build steps prior tests:
const gulp = require('gulp'); const jasmine = require('gulp-jasmine'); const reporter = require('jasmine-console-reporter'); gulp.task('default', function() { gulp.src('spec/**/*.js') .pipe(jasmine({ reporter: new reporter() })); });
Comments
Post a Comment