What testing does Selenium cover over and above Karma?

Jason Weden picture Jason Weden · Dec 20, 2012 · Viewed 16.5k times · Source

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.

Answer

inf3rno picture inf3rno · Apr 20, 2014

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.