The old way of doing things:
See how we’re getting the number of passing tests from the element with id=”mocha-stats”?
This was pretty dependent on the styling of the page, and can be an intensive amount of logic to put into a Selenium test, especially if you want to parse all the individual assertions.
The new way of doing things:
Now you can let Sauce Labs take care of all the tedium!
Instead of setting up a Webdriver and sending Selenium commands to our servers, just fire off a single HTTP request:
curl -X POST https://saucelabs.com/rest/v1/$SAUCE_USERNAME/js-tests
-u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -H 'Content-Type: application/json'
"platforms": [["Windows 7", "firefox", "20"],
["Linux", "googlechrome", ""]],
The Sauce servers point a browser at the test page and get the results. We parse the results depending on the framework you’re using and display them in a friendly manner on the Job Details page.
Failing Mocha and Qunit test reports on Sauce Labs
We now report the specific tests which fail, no more hunting through screenshots/videos.
The bad news:
An extra feature we get from this is support for an arbitrary “custom” unit test report. If you set `window.global_test_restults` to an object that looks like this:
"name": "foo test",
"message": "so foo",
"name": "bar test",
"message": "passed the bar exam",
"name": "baz test",
"name": "qux test",
We’ll display the results and report the test status automatically.
Enjoy the new reporting, if this gets enough use we can expand support to more frameworks and see if we can inject the reporting code into test pages when we test them, lessening the work for the developer.