I have my testing up and running with Travis/SauceLabs. Now I would like to add a SauceLabs test badge to my repo.

I added the badge markdown to my Readme file but how can I send the build pass/fail to SauceLabs? I found this instructions for Selenium,

Key: passed
Value type: bool
Example: "passed": true

but how/where do I add info in my files for my Grunt-Karma/Travis/SauceLabs testing?

有帮助吗?

解决方案

The Karma-Sauce-Launcher was using the wrong id, and this was fixed on Github by this PR and released in NPM as version 0.2.5

Aditionally the saucelabs reporter has to be added to the gruntfile options, besides the existing ones or the default progress.

So the bugfix I added to my package.json:

"karma-sauce-launcher": "~0.2.5"

and added this:

reporters: ['progress', 'saucelabs'],

in the Karma options.

其他提示

You have to use the REST API. What you would do is add code in a function that is executed at the very end of your test suite and knows the result of your test run. This code would have to perform a query equivalent to this curl command:

$ curl -H "Content-Type:text/json" -s -X PUT -d '{"passed": <status>}' http://<username>:<key>@saucelabs.com/rest/v1/<username>/jobs/<job-id>

(The identifiers in angular brackets have to be replaced with appropriate values.)

I've done it with Python but I don't have JavaScript code to share. And by the way, you have to do this for Selenium too because as the documentation states, when Selenium sends the job data to Sauce Labs, it cannot know yet what the test result is going to be.

If you're using Grunt already, you should use https://github.com/axemclion/grunt-saucelabs as it is the official plug-in that is worked on by devs from SauceLabs.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top