Search code examples
unit-testingintern

Get environment in an intern unit test suite


I'm running some unit tests in multiple environments. I'm trying to write a unit test for some platform dependant code, so I need a way to know which environment I'm running. I've figured out how to do it in a functional test (using this.remote) but not a unit test.

Is there a way I can identify the running environment from the inside of a unit test suite?


Solution

  • If you are writing a unit test for a browser then you can find out what browser they are running in through the navigator global object, but—and this is true for all code, including tests—you should use feature detection, not UA/environment sniffing, to determine whether or not certain functionality is available.