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?
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.
Jasmine is a JavaScript testing framework and Karma is a node-based testing tool for JavaScript codes across multiple real browsers.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With