From 586f317f002f8bc7aaa6be4045f2bce3b4b0324d Mon Sep 17 00:00:00 2001 From: Joe Forbes Date: Fri, 23 Feb 2018 15:23:44 -0500 Subject: [PATCH] ignore: Code coverage (#38) --- package.json | 6 +++++ src/media-groups.js | 3 +-- src/source-updater.js | 3 +-- src/util/noop.js | 1 + src/videojs-http-streaming.js | 2 ++ test/karma.conf.js | 41 +++++++++++------------------------ test/media-groups.test.js | 3 ++- 7 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 src/util/noop.js diff --git a/package.json b/package.json index 376568653..96a124650 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,11 @@ ], "author": "Brightcove, Inc", "license": "Apache-2.0", + "browserify": { + "transform": [ + "browserify-versionify" + ] + }, "browserify-shim": { "qunit": "global:QUnit", "sinon": "global:sinon", @@ -101,6 +106,7 @@ "browserify": "^11.0.0", "browserify-istanbul": "^2.0.0", "browserify-shim": "^3.0.0", + "browserify-versionify": "^1.0.6", "bundle-collapser": "^1.2.1", "connect": "^3.4.0", "cowsay": "^1.1.0", diff --git a/src/media-groups.js b/src/media-groups.js index a1378528f..d56180022 100644 --- a/src/media-groups.js +++ b/src/media-groups.js @@ -1,8 +1,7 @@ import videojs from 'video.js'; import PlaylistLoader from './playlist-loader'; import DashPlaylistLoader from './dash-playlist-loader'; - -const noop = () => {}; +import noop from './util/noop'; /** * Convert the properties of an HLS track into an audioTrackKind. diff --git a/src/source-updater.js b/src/source-updater.js index 4bcf67ce6..524beddef 100644 --- a/src/source-updater.js +++ b/src/source-updater.js @@ -4,8 +4,7 @@ import videojs from 'video.js'; import { printableRange } from './ranges'; import logger from './util/logger'; - -const noop = function() {}; +import noop from './util/noop'; /** * A queue of callbacks to be serialized and applied when a diff --git a/src/util/noop.js b/src/util/noop.js new file mode 100644 index 000000000..ca6a74471 --- /dev/null +++ b/src/util/noop.js @@ -0,0 +1 @@ +export default function noop() {} diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index c9e406771..fbe7fb341 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -648,6 +648,8 @@ class HlsHandler extends Component { * this object in normal usage. */ const HlsSourceHandler = { + name: 'videojs-http-streaming', + VERSION: '__VERSION__', canHandleSource(srcObj, options = {}) { let localOptions = videojs.mergeOptions(videojs.options, options); diff --git a/test/karma.conf.js b/test/karma.conf.js index 98782c091..b9f059f17 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -22,7 +22,7 @@ module.exports = function(config) { 'node_modules/video.js/dist/video-js.css', 'dist-test/browserify-test.js', 'dist-test/webpack-test.js', - 'dist-test/videojs-http-streaming.js' + 'test/**/*.test.js' ], browserConsoleLogOptions: { level: 'error', @@ -36,6 +36,11 @@ module.exports = function(config) { captureTimeout: 600, timeout: 600 }, + coverageReporter: { + reporters: [{ + type: 'text-summary' + }] + }, customLaunchers: { ChromeHeadlessWithFlags: { base: 'ChromeHeadless', @@ -99,29 +104,24 @@ module.exports = function(config) { } }, preprocessors: { + 'src/**/*.js': ['browserify', 'coverage'], 'test/**/*.test.js': ['browserify'] }, browserify: { debug: true, transform: [ 'babelify', - ['browserify-shim', { global: true }] + ['browserify-shim', { global: true }], + istanbul({ + instrumenter: isparta, + ignore: ['**/node_modules/**', '**/test/**'] + }) ], noParse: [ 'test/data/**', ] }, - babelPreprocessor: { - options: { - presets: ['es2015'], - sourceMap: 'inline' - }, - sourceFileName: function (file) { - return file.originalPath; - } - }, - - reporters: ['dots'], + reporters: ['dots', 'coverage'], port: 9876, colors: true, autoWatch: false, @@ -132,19 +132,4 @@ module.exports = function(config) { browserDisconnectTimeout: 300000, browserDisconnectTolerance: 3 }); - - // Coverage reporting - // Coverage is enabled by passing the flag --coverage to npm test - var coverageFlag = process.env.npm_config_coverage; - var reportCoverage = process.env.TRAVIS || coverageFlag; - - if (reportCoverage) { - config.reporters.push('coverage'); - config.browserify.transform.push(istanbul({ - instrumenter: isparta, - ignore: ['**/node_modules/**', '**/test/**'] - })); - config.preprocessors['src/**/*.js'] = ['browserify', 'coverage']; - } - }; diff --git a/test/media-groups.test.js b/test/media-groups.test.js index d5a93f3c5..b9b3dea69 100644 --- a/test/media-groups.test.js +++ b/test/media-groups.test.js @@ -5,6 +5,7 @@ import { import * as MediaGroups from '../src/media-groups'; import PlaylistLoader from '../src/playlist-loader'; import DashPlaylistLoader from '../src/dash-playlist-loader'; +import noop from '../src/util/noop'; QUnit.module('MediaGroups', { beforeEach(assert) { @@ -19,7 +20,7 @@ QUnit.module('MediaGroups', { QUnit.test('createMediaTypes creates skeleton object for all supported media groups', function(assert) { - const noopToString = 'function noop() {}'; + const noopToString = noop.toString(); const result = MediaGroups.createMediaTypes(); assert.ok(result.AUDIO, 'created AUDIO media group object');