Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing the multiple doms using karma

I intend to write tests using Mocha that can be executed using Karma. When I develop code, the application starts on http://localhost:3000 and I want to run tests (through command line - via GRUNT) that validate the status of the DOM.

How do I configure karma to do that? How do I provide the HTML for that view?

Also, there are multiple pages and each page has a different set of tests. How to architect the solution so that all the tests are executed precisely?

like image 912
tusharmath Avatar asked Mar 09 '14 11:03

tusharmath


People also ask

What is karma testing used for?

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.

What is the difference between Jasmine and karma?

Jasmine is a JavaScript testing framework and Karma is a node-based testing tool for JavaScript codes across multiple real browsers.

Does karma use selenium?

To use Karma with selenium, install the latest selenium client version equivalent to your selected selenium grid version. Example: If you selected to use selenium version 2.53. 1 for your selenium grid, install the latest 2.53. x for Javascript (Node).


1 Answers

I think all you need is Protractor configured with Karma. Here is example (with Jasmine) - https://github.com/angular/angular-seed/blob/master/test/protractor-conf.js.

It can run browser, simulate any action like real "end" user, and check DOM elements.

like image 86
IProblemFactory Avatar answered Oct 23 '22 21:10

IProblemFactory