Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output jasmine test results to the console


I am using Jasmine (BDD Testing Framework for JavaScript) in my firefox add-on to test the functionality of my code.

The problem is that jasmine is outputing the test results to an HTML file,what I need is to Firebug Console or other solution to output the results.

like image 971
Yosi Avatar asked Aug 23 '11 08:08

Yosi


People also ask

What is done () in Jasmine?

Using the done() Method in Your Jasmine-driven Asynchronous JavaScript Tests. Jasmine. Async is an add-on library for Jasmine that provides additional functionality to do asynchronous testing. Modeled after Mocha's async test support, it brings the done() function to the Jasmine unit testing environment.

Why is Jasmine tested?

Jasmine follows Behavior Driven Development (BDD) procedure to ensure that each line of JavaScript statement is properly unit tested. By following BDD procedure, Jasmine provides a small syntax to test the smallest unit of the entire application instead of testing it as a whole.

Which matcher is used in Jasmine to check whether the result is equal to true or false?

ToBeTruthy() This Boolean matcher is used in Jasmine to check whether the result is equal to true or false.


1 Answers

Have you tried the ConsoleReporter?

jasmine.getEnv().addReporter(new jasmine.ConsoleReporter(console.log)); 

According to the code Jasmine has the ConsoleReporter class that executes a print function (in this case console.log) that should do what you need.

If all else fails you could just use this as a starting point to implement your own console.log reporter.

UPDATE In newer versions of jasmine, ConsoleReporter was removed. You can either use the built-in jsApiReporter, or write your own (console) reporter, as shown in the following link: https://jasmine.github.io/tutorials/custom_reporter

like image 175
Tigraine Avatar answered Oct 13 '22 00:10

Tigraine