1

In the karma.conf.js you can set what browsers to use e.g. :

browsers: [
  "Chrome",
  "Firefox",
  "IE"    
],

Is there anyway in this configuration file to see what the build environment is e.g. Windows or Linux and then only run the tests in the appropriate browsers.

I basically don't want to have to keep changing the config file for karma every time I switch a OS.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Softey
  • 1,451
  • 3
  • 21
  • 42
  • Yes. You need to write some code for it, but here's the how to: http://stackoverflow.com/questions/24276239/detecting-environment-when-running-karma/24286880#24286880 – MarcoL Mar 15 '16 at 12:58

1 Answers1

0

After looking into Node.js I found out that you can get the operating system with the following call:

var os = require("os");

With the os variable I was then able to do simple if/else statements with os.type:

if(os.type()==='Linux')

I would then assign the appropriate browser options to the browser array in the config object.

browsers = ["Chrome","Firefox"];

All this logic was done inside the Karam.conf.js file but before the module.exports = function() call.

Softey
  • 1,451
  • 3
  • 21
  • 42