What testing does Selenium cover over and above Karma? What testing does Selenium cover over and above Karma? selenium selenium

What testing does Selenium cover over and above Karma?


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.


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.


It depends what you are testing. If you are using javascript to write unit tests - via jasmine/mocha/chai or equivalent then - the argument that karma relies heavily on javascript and selenium doesn't - is redundant.

In all my experience I have worked with very few dedicated automated testers, and while selenium language maybe their choice, the selenium library of methods is not as easy to memorise as an equivalent selector engine like jquery.

The difficulty for dedicated automated testers to learn the language, and the lack of interest for developers to learn a lesser language perpetuates the lack of investment for companies to invest in more intricate automated testing

There have been a few augmentation implementations of jquery with selenium over the years, but none really have a huge following and most are written in java.

Webdriverio has an npm package has some jquery features - https://www.npmjs.com/package/webdriverio-jquery

Karma has a means to import the whole jquery engine - https://github.com/bessdsv/karma-jasmine-jquery

It depends what is being tested. If you are testing the front end code, then it makes sense to use javascript, and it is easier to use jquery than the selenium language and currently karma supports jquery better than webdriver.

Using jquery for automated testing would empower transferable skills into development and vice versa for developers into automated testing.