diff --git a/.travis.yml b/.travis.yml index c926fa071..9c17044d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,26 @@ language: node_js node_js: -- '4' -- '6' -- '8' + - '4' + - '6' + - '8' + - node sudo: false git: depth: 1 notifications: - irc: irc.freenode.org#socket.io + irc: 'irc.freenode.org#socket.io' matrix: include: - - node_js: 'node' - env: BROWSER_NAME=chrome BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=safari BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=firefox BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=8 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=9 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=10 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=11 - - node_js: 'node' - env: BROWSER_NAME=microsoftedge BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=8.4 - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=9.2 - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=10.0 - - node_js: 'node' - env: BROWSER_NAME=android BROWSER_VERSION=4.4 - - node_js: 'node' - env: BROWSER_NAME=android BROWSER_VERSION=5.1 - - node_js: 'node' - env: BROWSER_NAME=ipad BROWSER_VERSION=9.3 - - node_js: 'node' - env: BROWSER_NAME=ipad BROWSER_VERSION=10.0 + - node_js: node + env: BROWSERS=1 +cache: + directories: + - node_modules +env: + global: + - secure: >- + QYaPt9wtF7Vm+kRPaGNAaCRP/E74gjxA7T0k1GqPYIs2xDiuhU/ef03pzWIjBB+6z0GGnsQ4rG+6JlM1lsthTMEDcegbp6/XKZkqZqWUaJmCy7U41J2mJutwli6ZV9VAqh5pi0mfe5elAqeh/fx+GhFbtu6JzBQkpW58OytiP1Y= + - secure: >- + pa7ocLVb5BJPCIC1cnGWWC0nGOKywR6Ac/QuiX1VD1SUt0XxpPVrbBzdgfHIMD0MCJ8F8xIlu2IPgp0O/a6c+Nj2V825Up5yKD/H0k1FKQ/4jp9aInV1VDFkKmoWdQcpCSaHq9HXJH58Bm4lpNyJdCydMpGOjZmSfs/ZGbzNN1Y= + - secure: >- + Og1/VRKnYHFNIj5rFhn/MIWvk8TBJ4CrNwffeBsUmusPJzyeATjkD8ZjGHD3jcjUcI3m4ihHe5al+WOt8GT9pUABDbuvFJXCBtNMGlo0URRlFu+oc3Qi3Ux8gJ/2317HDx9RNOJ+AC8EcBym49BDTm93rHc80ZLBVZZDS2pUU6o= diff --git a/gulpfile.js b/gulpfile.js index 5f0ce0fc6..1ddbd3c29 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,7 @@ const TEST_FILE = './test/index.js'; const TEST_SUPPORT_SERVER_FILE = './test/support/server.js'; gulp.task('test', ['lint'], function () { - if (process.env.hasOwnProperty('BROWSER_NAME')) { + if (process.env.hasOwnProperty('BROWSERS')) { return testZuul(); } else { return testNode(); @@ -63,18 +63,7 @@ gulp.task('lint', function () { // runs zuul through shell process function testZuul () { const ZUUL_CMD = './node_modules/zuul/bin/zuul'; - const args = [ - '--browser-name', - process.env.BROWSER_NAME, - '--browser-version', - process.env.BROWSER_VERSION - ]; - if (process.env.hasOwnProperty('BROWSER_PLATFORM')) { - args.push('--browser-platform'); - args.push(process.env.BROWSER_PLATFORM); - } - args.push(TEST_FILE); - const zuulChild = child.spawn(ZUUL_CMD, args, { stdio: 'inherit' }); + const zuulChild = child.spawn(ZUUL_CMD, [TEST_FILE], { stdio: 'inherit' }); zuulChild.on('exit', function (code) { process.exit(code); }); return zuulChild; } diff --git a/package.json b/package.json index 2d7c4a92c..d2c6c9ea5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "object-component": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "~3.1.1", + "socket.io-parser": "3.1.2", "to-array": "0.1.4" }, "devDependencies": { @@ -49,6 +49,7 @@ "istanbul": "^0.4.5", "mocha": "^3.3.0", "socket.io": "2.0.4", + "socket.io-browsers": "^1.0.0", "strip-loader": "0.1.2", "text-blob-builder": "0.0.1", "webpack-merge": "4.1.2", diff --git a/support/webpack.config.dev.js b/support/webpack.config.dev.js index 23508f480..a42e186c2 100644 --- a/support/webpack.config.dev.js +++ b/support/webpack.config.dev.js @@ -1,6 +1,4 @@ -var webpack = require('webpack'); - module.exports = { name: 'default', entry: './lib/index.js', @@ -17,7 +15,7 @@ module.exports = { loaders: [{ test: /\.js$/, exclude: /(node_modules|bower_components)/, - loader: 'babel', // 'babel-loader' is also a legal name to reference + loader: 'babel-loader', query: { presets: ['es2015'] } }, { test: /\json3.js/, diff --git a/support/webpack.config.js b/support/webpack.config.js index 42a48e316..3046dc87e 100644 --- a/support/webpack.config.js +++ b/support/webpack.config.js @@ -1,6 +1,6 @@ var webpack = require('webpack'); var merge = require('webpack-merge'); -var baseConfig = require('./webpack.config.dev.js') +var baseConfig = require('./webpack.config.dev.js'); module.exports = merge(baseConfig, { output: { @@ -21,5 +21,5 @@ module.exports = merge(baseConfig, { beautify: false } }) - ], + ] }); diff --git a/support/webpack.config.slim.dev.js b/support/webpack.config.slim.dev.js index 805730992..14b04b1a4 100644 --- a/support/webpack.config.slim.dev.js +++ b/support/webpack.config.slim.dev.js @@ -15,13 +15,13 @@ module.exports = { }, devtool: 'source-map', plugins: [ - new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/support/noop.js'), + new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/support/noop.js') ], module: { loaders: [{ test: /\.js$/, exclude: /(node_modules|bower_components)/, - loader: 'babel', // 'babel-loader' is also a legal name to reference + loader: 'babel-loader', query: { presets: ['es2015'] } }, { test: /\json3.js/, diff --git a/support/webpack.config.slim.js b/support/webpack.config.slim.js index 2c92b3305..479e23e80 100644 --- a/support/webpack.config.slim.js +++ b/support/webpack.config.slim.js @@ -1,6 +1,6 @@ var webpack = require('webpack'); var merge = require('webpack-merge'); -var baseConfig = require('./webpack.config.slim.dev.js') +var baseConfig = require('./webpack.config.slim.dev.js'); module.exports = merge(baseConfig, { output: { @@ -10,5 +10,5 @@ module.exports = merge(baseConfig, { }, plugins: [ new webpack.optimize.UglifyJsPlugin() - ], + ] }); diff --git a/test/index.js b/test/index.js index eb06e0996..83ced1d1e 100644 --- a/test/index.js +++ b/test/index.js @@ -2,7 +2,9 @@ require('./support/env'); // whitelist some globals to avoid warnings -global.___eio = null; +if (global.mocha) { + global.mocha.globals(['___eio', 'eio_iframe_*']); +} require('./url'); diff --git a/zuul.config.js b/zuul.config.js index d2b94d137..be4b61eda 100644 --- a/zuul.config.js +++ b/zuul.config.js @@ -1,17 +1,33 @@ +'use strict'; + +var browsers = require('socket.io-browsers'); var zuulConfig = module.exports = { ui: 'mocha-bdd', + + // test on localhost by default + local: true, + + concurrency: 2, // ngrok only accepts two tunnels by default + // if browser does not sends output in 120s since last output: + // stop testing, something is wrong + browser_output_timeout: 120 * 1000, + browser_open_timeout: 60 * 4 * 1000, + // we want to be notified something is wrong asap, so no retry + browser_retries: 1, + server: './test/support/server.js', - local: true, // test on localhost by default builder: 'zuul-builder-webpack', - webpack: require('./support/webpack.config.js') + webpack: require('./support/webpack.config.dev.js') }; if (process.env.CI === 'true') { zuulConfig.local = false; zuulConfig.tunnel = { type: 'ngrok', - authtoken: '6Aw8vTgcG5EvXdQywVvbh_3fMxvd4Q7dcL2caAHAFjV', - proto: 'tcp' + bind_tls: true }; } + +var isPullRequest = process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false'; +zuulConfig.browsers = isPullRequest ? browsers.pullRequest : browsers.all;