javascript - How to show passed test in Jasmine? - Stack Overflow

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

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 mand 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?

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 mand 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?

Share Improve this question edited Jul 4, 2020 at 22:28 Sang asked Nov 11, 2017 at 1:05 SangSang 4,4644 gold badges41 silver badges51 bronze badges 2
  • 1 If it helps your search, you're asking how to configure or use a different reporter with jasmine. – stealththeninja Commented Nov 11, 2017 at 1:25
  • I realise that this does not answer your question directly, but Mocha does list passing tests for you, it maybe an alternative for you to try. – Jeremy Commented Oct 10, 2019 at 12:08
Add a ment  | 

3 Answers 3

Reset to default 5

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 mand 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
}

I know this is a relatively old question but found something which worked for me

describe('Desc1',() => {
   
    afterEach(() => {
      const myReporter = {
        specDone: (result) => {
          console.log('Spec FullName: ' + result.fullName);
          console.log('Spec Result: ' + result.status);
        }
      };
      jasmine.getEnv().addReporter(myReporter);
    });
})

Credit for the solution : https://groups.google./g/jasmine-js/c/qqOk6Nh7m4c/m/Nyovy2EjAgAJ

You can use jasmine-spec-reporter.

Just add at the top of your test file:

import { SpecReporter } from 'jasmine-spec-reporter';
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: 'pretty' } }));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744064170a4552333.html

相关推荐

  • javascript - How to show passed test in Jasmine? - Stack Overflow

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

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信