4

As, mocha logs the specs string if the test is successful. for the below test suite,

describe("capitalize", function() {
   it("capitalizes single words", function() { /* … */});
   it("makes the rest of the string lowercase", function() {
     expect(capitalize("javaScript")).to.equal("Javascript");
   });
});

firing the npm test command would log the following,

capitalize
✓ capitalizes single words
✓ makes the rest of the string lowercase
2 passing (10ms)

The same when written with jasmine would simply log two green dots denoting that the tests were successful. So, is there any way to achieve the mocha like logs ? As the official docs do not help in this regard !

Vickar
  • 923
  • 11
  • 16
  • Doesn't the SpecRunner.html do what you ask for? I can see all the specs there and a tick if they passed. – Marc Compte Jun 21 '16 at 11:47
  • I've actually downloaded jasmine using npm and I did read about the SpecRunner.html file but I don't find one in my globally/locally installed jasmine module.Am I missing out something ? one thing that I want to bring to your notice is that I'm using the CLI to run my tests and not a browser instance ! – Vickar Jun 22 '16 at 06:35
  • I think specRunner is to be used with plain javascript, I'm using Express.js on top of Node.js. – Vickar Jun 22 '16 at 06:36
  • Yes, I think SpecRunner.html is for plain Javascript. Sorry, I don't know how it'd work from CLI in node.js. – Marc Compte Jun 22 '16 at 08:46

2 Answers2

3

You can use jasmine-spec-reporter, it is a jasmine reporter that display output this way:

Spec started

  first suite
    ✓ should be ok
    ✗ should failed
      - Expected true to be false.
Bastien Caudan
  • 4,482
  • 1
  • 17
  • 29
1

If you use Karma to run your tests you can accomplish this. I use a reporter called karma-mocha-reporter. You can find more details here.It produces output in the console like this:

enter image description here

tehbeardedone
  • 2,833
  • 1
  • 15
  • 23