From d16a568c117c284a6e1c8406642723f03410c705 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 21 Nov 2016 21:06:50 +0700 Subject: [PATCH] Fix failing tests across browsers --- browsers.json | 68 +++++++++++++++++++---------------------------- karma.conf.js | 11 +++++--- package.json | 6 ++--- src/index.test.js | 25 ++++++++++------- webpack.config.js | 3 +++ 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/browsers.json b/browsers.json index bb5e2894..12464b5a 100644 --- a/browsers.json +++ b/browsers.json @@ -1,59 +1,45 @@ { - "BS_Safari": { + "BS_Android4.1": { + "base": "BrowserStack", + "os": "android", + "os_version": "4.1", + "browser": "Android Browser", + "real_mobile": false + }, + "BS_MobileSafari8.3": { + "base": "BrowserStack", + "os": "ios", + "os_version": "8.3", + "browser": "Mobile Safari", + "real_mobile": false + }, + "BS_Opera22": { "base": "BrowserStack", "os": "OS X", "os_version": "Yosemite", - "browser": "safari", - "browser_version": "8.0" + "browser": "opera", + "browser_version": "22.0" }, - "BS_Safari": { + "BS_Chrome28": { "base": "BrowserStack", "os": "OS X", "os_version": "Mavericks", - "browser": "safari", - "browser_version": "7.0" + "browser": "chrome", + "browser_version": "28.0" }, - "BS_Chrome": { + "BS_Safari8": { "base": "BrowserStack", "os": "OS X", "os_version": "Yosemite", - "browser": "chrome", - "browser_version": "49.0" + "browser": "safari", + "browser_version": "8.0" }, - "BS_Firefox": { + "BS_Firefox25": { "base": "BrowserStack", "os": "OS X", "os_version": "Yosemite", "browser": "firefox", - "browser_version": "45.0" - }, - "BS_MobileSafari": { - "base": "BrowserStack", - "os": "ios", - "os_version": "8.0", - "browser": "iphone", - "real_mobile": false - }, - "BS_MobileSafari": { - "base": "BrowserStack", - "os": "ios", - "os_version": "9.0", - "browser": "iphone", - "real_mobile": false - }, - "BS_Chrome": { - "base": "BrowserStack", - "os": "Windows", - "os_version": "8.1", - "browser": "chrome", - "browser_version": "49.0" - }, - "BS_Firefox": { - "base": "BrowserStack", - "os": "Windows", - "os_version": "8.1", - "browser": "firefox", - "browser_version": "45.0" + "browser_version": "25.0" }, "BS_InternetExplorer9": { "base": "BrowserStack", @@ -76,11 +62,11 @@ "browser": "ie", "browser_version": "11.0" }, - "BS_Edge": { + "BS_Edge13": { "base": "BrowserStack", "os": "Windows", "os_version": "10", "browser": "edge", - "browser_version": "14" + "browser_version": "13.0" } } diff --git a/karma.conf.js b/karma.conf.js index 9769cea5..f5703854 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -34,16 +34,21 @@ module.exports = (config) => { if (useCloud) { Object.assign(config, { browsers: Object.keys(browsers), - browserDisconnectTolerance: 3, // My current OS plan allows max 2 parallel connections. concurrency: 2, - retryLimit: 3 + retryLimit: 3, + + // Timeouts taken from https://github.com/karma-runner/karma-browserstack-launcher/issues/61 + captureTimeout: 3e5, + browserNoActivityTimeout: 3e5, + browserDisconnectTimeout: 3e5, + browserDisconnectTolerance: 3 }) config.browserStack = { username: browserStackUserName, accessKey: browserStackAccessKey, - captureTimeout: 10000 + captureTimeout: 3e5 } if (isTravis) { diff --git a/package.json b/package.json index 624da86e..35dc162e 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,7 @@ "all": "npm run lint && npm run test && npm run build", "build": "npm run clean && npm run build:lib && npm run build:tests && npm run build:dist", "build:lib": "babel src --out-dir lib", - "build:tests": "npm run build:tests:lib && npm run build:tests:local", - "build:tests:lib": "cross-env NODE_ENV=test babel src --out-dir tests", - "build:tests:local": "cross-env NODE_ENV=test webpack src/index.test.js tmp/tests.js", + "build:tests": "cross-env NODE_ENV=test webpack src/index.test.js tmp/tests.js", "build:dist": "npm run build:dist:max && npm run build:dist:min", "build:dist:max": "cross-env NODE_ENV=development webpack src/index.js dist/react-jss.js", "build:dist:min": "cross-env NODE_ENV=production webpack src/index.js dist/react-jss.min.js", @@ -49,6 +47,7 @@ "babel-plugin-transform-es3-property-literals": "^6.8.0", "babel-preset-es2015": "^6.9.0", "babel-preset-stage-0": "^6.5.0", + "caniuse-support": "^0.2.0", "cross-env": "^3.1.3", "es5-shim": "^4.5.9", "eslint": "^2.8.0", @@ -58,6 +57,7 @@ "eslint-plugin-jsx-a11y": "^1.5.5", "eslint-plugin-react": "^5.0.1", "expect.js": "^0.3.1", + "json-loader": "^0.5.4", "karma": "^1.1.1", "karma-benchmark": "^0.6.0", "karma-benchmark-reporter": "^0.1.1", diff --git a/src/index.test.js b/src/index.test.js index 16a73416..ac9a6b8d 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -1,7 +1,12 @@ +/* eslint-disable func-names, no-console */ + import expect from 'expect.js' +import {getSupport, currentBrowser} from 'caniuse-support' import {prefix, supportedProperty, supportedValue} from './index' +console.log(`Detected browser: ${currentBrowser.id} ${currentBrowser.version}`) + describe('css-vendor', () => { describe('.prefix', () => { it('should be correct for .css', () => { @@ -22,11 +27,11 @@ describe('css-vendor', () => { expect(supportedProperty('display')).to.be('display') }) - it('should prefix if needed', () => { - const prop = supportedProperty(`${prefix.css}animation`) - if (prop !== 'animation') { - expect(prop).to.be(`${prefix.css}animation`) - } + it('should prefix if needed', function () { + const {level, needPrefix} = getSupport('transforms2d') + if (level === 'none' || level === 'unknown') this.skip() + const prop = needPrefix ? `${prefix.css}transform` : 'transform' + expect(supportedProperty('transform')).to.be(prop) }) it('should return false', () => { @@ -44,11 +49,11 @@ describe('css-vendor', () => { expect(supportedValue('color', value)).to.be(value) }) - it('should should prefix if needed', () => { - const value = supportedValue('display', 'flex') - if (value !== 'flex') { - expect(value).to.be(`${prefix.css}flex`) - } + it('should prefix if needed', function () { + const {level, needPrefix} = getSupport('flexbox') + if (level !== 'full') this.skip() + const value = needPrefix ? `${prefix.css}flex` : 'flex' + expect(supportedValue('display', 'flex')).to.be(value) }) it('should return false for unknown value', () => { diff --git a/webpack.config.js b/webpack.config.js index 6ce9905e..664b006d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -24,6 +24,9 @@ module.exports = { loader: 'babel-loader', test: /\.js$/, exclude: /node_modules/ + }, { + loader: 'json-loader', + test: /\.json$/ } ] }