What testing does Selenium cover over and above Karma?

17,471

Solution 1

There is a huge difference between Karma and Selenium. Selenium has a built-in browser control mechanism, while Karma does not. So Selenium is more suited to end to end testing, for example with nightwatch.js. Karma is designed for unit tests, so it is much harder to achieve end to end tests on it, you can add for example a phantomjs launcher, but it will never be the same as real browser tests with Selenium... I think both of them can run any js testing framework if you have an adapter... Mocha, jasmine, qunit, etc...

An eternity later:

It is possible to write e2e tests with Karma. You need to create an iframe or open a new window and run a script, which does the navigation, fires the events, submits forms, etc. from the parent frame or window. The tested page needs to allow your Karma server with CORS or you need to disable browser security. I am working on an e2e testing library, which does exactly this.

Solution 2

There are several versions of Selenium, the newest (I believe) of which is Selenium Web Driver which allows you to create a driver that will handle a browser for you by simulating actions that interact with the UI much like a user would (through a Json wire).

My current understanding of Karma (which may I add is very limited) is that it relies heavily on executing javascript. Because of this Karma would have to call change events on elements (as in, 'blur' and 'hover over') whereas Selenium would just click, tab out, move cursor to. Selenium's browsers are limited to those specified on their webpage here.

Share:
17,471
Jason Weden
Author by

Jason Weden

@jweden

Updated on June 12, 2022

Comments

  • Jason Weden
    Jason Weden almost 2 years

    I understand that Karma is a JavaScript test runner, which can run tests in real browsers. If that is the case, what kind of test coverage does Selenium provide over and above Karma.