diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b009dfb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/.travis.yml b/.travis.yml index 0b65123..a5b3176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,25 +4,21 @@ language: node_js node_js: - 'node' - 'lts/argon' +cache: + directories: + - node_modules before_script: - # check if the current version is equal to the version for the env - - 'export IS_INSTALLED="$(npm list video.js | grep "video.js@$VJS")"' - # we have to add semi colons to the end of each line in the if - # as travis runs this all on one line - - 'if [ -z "$IS_INSTALLED" ]; then - echo "INSTALLING video.js@>=$VJS.0.0-RC.0 <$(($VJS+1)).0.0"; - npm i "video.js@>=$VJS.0.0-RC.0 <\$(($VJS+1)).0.0"; - else - echo "video.js@$VJS ALREADY INSTALLED"; - fi' - - export CHROME_BIN=/usr/bin/google-chrome - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + # always install the appropriate version of video.js for the environment + - npm i "video.js@$VJS"; + # pulseaudio is needed for dockerized chrome since it has a dummy sink and + # the dummy audio ALSA kernel module isn't loaded by Travis + # libavcodec54 is needed by firefox for h.264 support + - sudo apt-get install --no-install-recommends pulseaudio libavcodec54 + - pulseaudio -D env: - - VJS=5 - - VJS=6 + matrix: + - VJS=5 + - VJS=6 addons: - # TODO: This should be using latest for firefox. It is currently turned off because - # of https://github.com/travis-ci/travis-ci/issues/8242 When this issue is - # resolved, this should be updated back to latest chrome: stable + firefox: latest diff --git a/package.json b/package.json index 62c3d08..770c8af 100644 --- a/package.json +++ b/package.json @@ -93,14 +93,14 @@ "doctoc": "^0.15.0", "glob": "^6.0.3", "jsdoc": "^3.4.0", - "karma": "^0.13.0", + "karma": "^2.0.0", "karma-browserify": "^4.4.0", "karma-chrome-launcher": "^2.2.0", "karma-detect-browsers": "^2.0.0", - "karma-firefox-launcher": "^0.1.0", - "karma-ie-launcher": "^0.2.0", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", "karma-qunit": "^0.1.0", - "karma-safari-launcher": "^0.1.0", + "karma-safari-launcher": "^1.0.0", "lodash-compat": "^3.10.0", "minimist": "^1.2.0", "nodemon": "^1.9.1", diff --git a/test/karma.conf.js b/test/karma.conf.js index 174b49d..17ef34a 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,30 +1,22 @@ module.exports = function(config) { var detectBrowsers = { - enabled: false, usePhantomJS: false, - postDetection: function(availableBrowsers) { - var safariIndex = availableBrowsers.indexOf('Safari'); - if(safariIndex !== -1) { - availableBrowsers.splice(safariIndex, 1); - console.log("Disabled Safari as it was/is not supported"); + // detect what browsers are installed on the system and + // use headless mode and flags to allow for playback + postDetection: function(browsers) { + var newBrowsers = []; + if (browsers.indexOf('Chrome') !== -1) { + newBrowsers.push('ChromeHeadlessWithFlags'); } - return availableBrowsers; - } - }; - // TODO: This should include firefox. It is currently turned off because - // of https://github.com/travis-ci/travis-ci/issues/8242 When this issue is - // resolved, this should be updated to include firefox - if (process.env.TRAVIS) { - config.browsers = ['ChromeHeadless']; - } + if (browsers.indexOf('Firefox') !== -1) { + newBrowsers.push('FirefoxHeadless'); + } - // If no browsers are specified, we enable `karma-detect-browsers` - // this will detect all browsers that are available for testing - if (!config.browsers.length) { - detectBrowsers.enabled = true; - } + return newBrowsers; + } + }; config.set({ basePath: '..', @@ -46,13 +38,27 @@ module.exports = function(config) { preprocessors: { 'test/**/*.js': ['browserify'] }, + customLaunchers: { + ChromeHeadlessWithFlags: { + base: 'ChromeHeadless', + flags: [ + '--mute-audio', + '--no-sandbox', + '--no-user-gesture-required' + ] + } + }, detectBrowsers: detectBrowsers, reporters: ['dots'], port: 9876, colors: true, autoWatch: false, singleRun: true, - concurrency: Infinity, + concurrency: 1, + captureTimeout: 300000, + browserNoActivityTimeout: 300000, + browserDisconnectTimeout: 300000, + browserDisconnectTolerance: 3, browserify: { debug: true, transform: [