Skip to content
Advertisement

How to show passed test in Jasmine?

When running jasmine it only presents dot(.) for successful tests, and only verbose if the test fails.

//test.spec.js
describe('jasmine', ()=>{
  it('should show this text', () =>{
  });
})

My running command is: jasmine-node test.spec.js

The result:

.
Finished in 0.003 seconds
1 test, 1 assertion, 0 failures, 0 skipped

How to make jasmine display this test result like jasmine should show this text?

Advertisement

Answer

Use the --verbose flag:

> jasmine-node test.spec.js --verbose

jasmine - 0 ms
    should show this test - 0 ms

Finished in 0.007 seconds
1 test, 1 assertion, 0 failures, 0 skipped

Note: jasmine-node doesn’t seem to be actively maintained. The jasmine CLI supports tests run from the command line.

Although jasmine doesn’t have a verbose flag, you can use a custom terminal reporter (example: jasmine-terminal-reporter). From jasmine’s documentation, add a helper file to load the custom reporter and include the helper in your configuration file.

helpers/terminal-reporter.js

var Reporter = require('jasmine-terminal-reporter');
var reporter = new Reporter(options);

jasmine.addReporter(reporter);

spec/support/jasmine.json

{
  "spec_dir": "spec",
  "spec_files": [
    "**/*[sS]pec.js",
  ],
  "helpers": [
    "helpers/**/*.js"
  ],
  stopSpecOnExpectationFailure: false,
  random: false
}
Advertisement