Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View Karma Test Output in a Browser?

Tags:

karma-runner

I'm new to Karma, but I'm wondering how to view its output in a browser (much like the way one interacts with Jasmine, when a runner.html file is present).

I watched the introductory screencast and I understand how to view test outputs in a console window, but in my browser, I get almost no content for Karma except

Karma - connected

Please advise! I would like to avoid having to maintain a separate runner.html file, since the Karma configuration file already requires me to include all necessary script links.

like image 779
blaster Avatar asked May 02 '13 17:05

blaster


People also ask

How do I run a karma test in chrome?

To launch Chrome from karma, we need to use karma-chrome-launcher. Run the command npm install karma-chrome-launcher --save to install to the application. Add the karma-chrome-launcher plugin to the plugins list in your karma.

What is Karmajs?

Karma is a test runner for JavaScript that runs on Node. js. It is very well suited to testing AngularJS or any other JavaScript projects. Using Karma to run tests using one of many popular JavaScript testing suites (Jasmine, Mocha, QUnit, etc.)

How does karma work JavaScript?

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.


2 Answers

AFAIK, the previous two answers are correct in that you'll want to run the tests in a browser; click DEBUG and view the output in the console.

Politely contradicting the previous answer, I regularly do this and step-through debug with full variable interaction using Karma.

The proper answer to your question, because what you want is pretty HTML based output, is "no." However, this plugin for karma may give you the results you desire.

https://npmjs.org/package/karma-html-reporter

like image 86
stolli Avatar answered Sep 28 '22 00:09

stolli


You need to run it with singleRun = false in karma.conf.js and then click the button on the top corner that says "DEBUG". Then you should see the output and it won't disappear or close. You will also be able to use the console to debug.

Worth noting that debugging e2e tests isn't that easy because they are "future" based so you won't be able to intercept values (afaik).

like image 42
Chris Nicola Avatar answered Sep 28 '22 00:09

Chris Nicola