15

I'm having trouble wrapping my head around Karma. I'd like to:

  • Set up multiple hosts on my network, running Linux, Mac and Windows
  • Preferably also run on Android and iPhone
  • Have these be available for running end-to-end tests through Karma
  • Have them run tests on a remote location, not locally

The goal: being able to automate tests which ensures that our site works on all platforms and browsers, not only the ones available to me locally.

Is this possible? I'm struggling to find any good guides for setting this stuff up.

KarmaNightmare
  • 151
  • 1
  • 3

2 Answers2

13

You can start a webdriver server on your remote servers and configure karma to use the karma-webdriver-launcher to run the tests on the browsers from your webdriver servers.

josketres
  • 3,329
  • 1
  • 26
  • 23
  • It is incredible how much time I browsed for this answer.. I would like that the description of the webdriver setup was highlighted in the main karma site, as it is a very common doubt that arises when you first approach karma. – cesarpachon Jan 28 '16 at 20:10
  • Compatible with Karma 0.12. Won't work with 3.x or 4.x – bhantol Apr 10 '19 at 23:17
1

I've been using karma for a short while myself and I think I can answer some of your questions.

I am not sure what you mean with setting up multiple hosts, but I guess you mean that you want to run the tests on several different devices (maybe even on different browsers?).

All you have to do really is to have the tests and karma installed on some server that you can access remotely. Running Karma from that server should make it possible for your other devices to access it's instance of Karma simply by opening a browser and typing in serverURL:9876 in the URL-bar of the browser. This should cause all the tests found on the server to be run on the browser that opened the page.

If you want to see the output from Karma during the tests, you will either have to make karma spit out some HTML using a reporter (if you manage to do this, give me a call!), use the junit reporter and post process the xml that it generates, or simply SSH to the server and see what comes out in the console.

If you use some sort of regex in the karma config file that is able to find any new code and test files you push to the server, karma will automatically load these files when you push them to the server and re-run all tests.

I am actually in the process of doing this myself, but I would like to create HTML test-reports instead of having to post process some XML or having to SSH and look at the command-line output. I am also having some problems with Istanbul, the code coverage tool, in that if you run the tests on several browsers at once, only one of them will have code coverage generated.

Metareven
  • 822
  • 2
  • 7
  • 26