0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 09:52:29 +01:00

Use jsunitsaucelabs to run our unit tests on Saucelabs

This commit is contained in:
Johann-S 2017-09-28 14:55:15 +02:00 committed by XhmikosR
parent 502ac7ee4d
commit 210bb221a8
3 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,48 @@
const JSUnitSaucelabs = require('jsunitsaucelabs')
var jsUnitSaucelabs = new JSUnitSaucelabs({
username: process.env.SAUCE_USERNAME,
password: process.env.SAUCE_ACCESS_KEY
})
// TODO : get all the browsers in sauce_browsers.yml
var testURL = 'http://localhost:3000/js/tests/index.html?hidepassed'
jsUnitSaucelabs.start([
['Windows 8', 'internet explorer', '10']
], testURL, 'qunit', function (error, success) {
if (typeof success !== 'undefined') {
var taskIds = success['js tests']
if (!taskIds || !taskIds.length) {
throw new Error('Error starting tests through SauceLabs API')
}
var waitingCallback = function (error, success) {
if (error) {
console.error(error)
return
}
if (typeof success !== 'undefined') {
if (!success.completed) {
jsUnitSaucelabs.getStatus(taskIds[0], waitingCallback)
} else {
var test = success['js tests'][0]
var passed = false
if (test.result !== null) {
passed = test.result.total === test.result.passed
}
console.log('Tested ' + testURL)
console.log('Platform: ' + test.platform.join(','))
console.log('Passed: ' + passed.toString())
console.log('Url ' + test.url)
}
}
}
taskIds.forEach(function (id) {
jsUnitSaucelabs.getStatus(id, waitingCallback)
})
}
})

6
package-lock.json generated
View File

@ -3699,6 +3699,12 @@
"verror": "1.10.0" "verror": "1.10.0"
} }
}, },
"jsunitsaucelabs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jsunitsaucelabs/-/jsunitsaucelabs-1.0.0.tgz",
"integrity": "sha512-5/PCsSwLGMLCiA4IOlbuxOcangxnEadEZTPwGvF4sHQ+NQoPbSIbCtK4Wce1IReJiyY6fQldA2uITycXZOhqrQ==",
"dev": true
},
"kew": { "kew": {
"version": "0.7.0", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz",

View File

@ -41,7 +41,7 @@
"js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js", "js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js",
"js-minify-docs": "uglifyjs --mangle --comments \"/^!/\" --output assets/js/docs.min.js assets/js/vendor/anchor.min.js assets/js/vendor/clipboard.min.js assets/js/vendor/holder.min.js assets/js/src/application.js assets/js/src/pwa.js", "js-minify-docs": "uglifyjs --mangle --comments \"/^!/\" --output assets/js/docs.min.js assets/js/vendor/anchor.min.js assets/js/vendor/clipboard.min.js assets/js/vendor/holder.min.js assets/js/src/application.js assets/js/src/pwa.js",
"js-test": "phantomjs ./node_modules/qunit-phantomjs-runner/runner.js js/tests/index.html 60", "js-test": "phantomjs ./node_modules/qunit-phantomjs-runner/runner.js js/tests/index.html 60",
"js-test-cloud": "ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd, :Logger => WEBrick::Log.new('/dev/null'), :AccessLog => []); trap('INT') { s.shutdown }; s.start\" & grunt saucelabs-qunit", "js-test-cloud": "ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd, :Logger => WEBrick::Log.new('/dev/null'), :AccessLog => []); trap('INT') { s.shutdown }; s.start\" & node build/saucelabs-unit-test.js",
"docs": "npm-run-all docs-compile docs-lint", "docs": "npm-run-all docs-compile docs-lint",
"docs-lint": "htmllint --rc build/.htmllintrc _gh_pages/*.html _gh_pages/**/*.html js/tests/visual/*.html", "docs-lint": "htmllint --rc build/.htmllintrc _gh_pages/*.html _gh_pages/**/*.html js/tests/visual/*.html",
"docs-compile": "bundle exec jekyll build", "docs-compile": "bundle exec jekyll build",
@ -90,6 +90,7 @@
"grunt-cli": "^1.2.0", "grunt-cli": "^1.2.0",
"grunt-saucelabs": "^9.0.0", "grunt-saucelabs": "^9.0.0",
"htmllint-cli": "^0.0.6", "htmllint-cli": "^0.0.6",
"jsunitsaucelabs": "^1.0.0",
"node-sass": "^4.5.3", "node-sass": "^4.5.3",
"nodemon": "^1.11.0", "nodemon": "^1.11.0",
"npm-run-all": "^4.0.2", "npm-run-all": "^4.0.2",