Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2017-09-28 18:18:20 +0300
committerXhmikosR <xhmikosr@gmail.com>2017-09-29 19:39:25 +0300
commit54d45072810f5cda4f3c75eba6d9acd70274a963 (patch)
tree297683e863a3e540f65ddaf08d33c69bcfdff244 /build/saucelabs-unit-test.js
parentb001118c9878e0a14e63e5c76f6ec6f5a28c8fb0 (diff)
Use sauce_browsers.json.
Diffstat (limited to 'build/saucelabs-unit-test.js')
-rw-r--r--build/saucelabs-unit-test.js102
1 files changed, 67 insertions, 35 deletions
diff --git a/build/saucelabs-unit-test.js b/build/saucelabs-unit-test.js
index f158848a34..7607b6d948 100644
--- a/build/saucelabs-unit-test.js
+++ b/build/saucelabs-unit-test.js
@@ -1,54 +1,86 @@
+'use strict'
+
+const path = require('path')
const JSUnitSaucelabs = require('jsunitsaucelabs')
+// Docs: https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
+// Mac Opera is not currently supported by Sauce Labs
+// Win Opera 15+ is not currently supported by Sauce Labs
+// iOS Chrome is not currently supported by Sauce Labs
+
const jsUnitSaucelabs = new JSUnitSaucelabs({
username: process.env.SAUCE_USERNAME,
password: process.env.SAUCE_ACCESS_KEY,
build: process.env.TRAVIS_JOB_ID
})
+const testURL = 'http://localhost:3000/js/tests/index.html?hidepassed'
+const browsersFile = require(path.resolve(__dirname, './sauce_browsers.json'))
+let jobsDone = 0
+let jobsSuccess = 0
-// TODO : get all the browsers in sauce_browsers.yml
-// Docs: https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
-// Mac Opera is not currently supported by Sauce Labs
-// Win Opera 15+ is not currently supported by Sauce Labs
-// iOS Chrome is not currently supported by Sauce Labs
+const waitingCallback = (error, body, id) => {
+ if (error) {
+ console.error(error)
+ process.exit(1)
+ return
+ }
-const testURL = 'http://localhost:3000/js/tests/index.html?hidepassed'
+ if (typeof body !== 'undefined') {
+ if (!body.completed) {
+ setTimeout(() => {
+ jsUnitSaucelabs.getStatus(id, (error, body) => {
+ waitingCallback(error, body, id)
+ })
+ }, 2000)
+ } else {
+ const test = body['js tests'][0]
+ let passed = false
-jsUnitSaucelabs.start([
- ['Windows 8', 'internet explorer', '10']
-], testURL, 'qunit', (error, success) => {
- if (typeof success !== 'undefined') {
- const taskIds = success['js tests']
- if (!taskIds || !taskIds.length) {
- throw new Error('Error starting tests through SauceLabs API')
- }
+ if (test.result !== null) {
+ passed = test.result.total === test.result.passed
+ }
- const waitingCallback = (error, success) => {
- if (error) {
- console.error(error)
- return
+ console.log(`Tested ${testURL}`)
+ console.log(`Platform: ${test.platform.join(',')}`)
+ console.log(`Passed: ${passed.toString()}`)
+ console.log(`Url ${test.url} \n`)
+
+ if (passed) {
+ jobsSuccess++
}
+ jobsDone++
- if (typeof success !== 'undefined') {
- if (!success.completed) {
- jsUnitSaucelabs.getStatus(taskIds[0], waitingCallback)
- } else {
- const test = success['js tests'][0]
- let 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}`)
- }
+ // Exit
+ if (jobsDone === browsersFile.length - 1) {
+ jsUnitSaucelabs.stop()
+ process.exit(jobsDone === jobsSuccess ? 0 : 1)
}
}
+ }
+}
+
+jsUnitSaucelabs.on('tunnelCreated', () => {
+ browsersFile.forEach((tmpBrowser) => {
+ const broPlatform = typeof tmpBrowser.platform === 'undefined' ? tmpBrowser.platformName : tmpBrowser.platform
+ const arrayBro = [broPlatform, tmpBrowser.browserName, tmpBrowser.version]
+ jsUnitSaucelabs.start([arrayBro], testURL, 'qunit', (error, success) => {
+ if (typeof success !== 'undefined') {
+ const taskIds = success['js tests']
+
+ if (!taskIds || !taskIds.length) {
+ throw new Error('Error starting tests through SauceLabs API')
+ }
- taskIds.forEach((id) => {
- jsUnitSaucelabs.getStatus(id, waitingCallback)
+ taskIds.forEach((id) => {
+ jsUnitSaucelabs.getStatus(id, (error, body) => {
+ waitingCallback(error, body, id)
+ })
+ })
+ } else {
+ console.error(error)
+ }
})
- }
+ })
})
+jsUnitSaucelabs.initTunnel()