Search code examples
javascriptcontinuous-integrationjasminejasmine-maven-plugin

Why is my jasmine with a specified browserVersion not failing?


I have set up jasmine tests for my app. In my app I have javascript that shouldn't work in IE8 :

var foo = Object.create(Array.prototype);

When I run mvn jasmine:bdd and I open the test page in Internet Explorer (with browserMode set to Internet Explorer 8), it fails as expected:

TypeError: Object doesn't support property or method 'create'

However, when I run:

mvn jasmine:test -DbrowserVersion=INTERNET_EXPLORER_8

All of my tests are successful. The logs specify that the browserVersion is set to INTERNET_EXPLORER_8.

I expected both to give me the same result. This is causing an issue with our ci testing since it has let out js errors that I wanted to catch.

Should this be working as I'm expecting and if not, what should I change?

Also, this is the best way I know how to test multiple browsers. Is there a better way that I'm missing?

EDIT

A coworker has tried to dash my hopes that the browserVersion wouldn't even catch such an error and suggested that it was only meant to change the header so that the tests could cover browser specific javascript as well (blocks of code that only run when the browser is a specific version). Is this accurate?


Solution

  • It seems very accurate that the jasmine tests browserVersion property does not change the internals of how the js is run, meaning that the quirks or each browser will not be tested. I have successfully transitioned to using js-test-driver for my tests which can run jasmine tests on actual browsers. This looks to be the right way to do this. Although if you're starting new down this path, I'd look at Karma instead (previously named testacular, and built as an improvement on js-test-driver).