From e6a2925b39c765bb5146ac02e5deec52e343efe5 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Mon, 31 Oct 2016 18:26:49 -0400 Subject: [PATCH] Factor in unused/unrequired files in to coverage % - Solution is thanks to @wagenet - Change node versions to test against --- .travis.yml | 7 +++---- index.js | 29 +++-------------------------- lib/templates/test-body-footer.html | 12 ++++++++++++ test/unit/index-test.js | 16 ++++++++++++++-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03989290..6de39467 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ --- language: node_js node_js: - - "0.10" - "0.12" - "4.2" - - "5" + - "6" dist: trusty sudo: required @@ -26,9 +25,9 @@ env: matrix: fast_finish: true include: - - node_js: "5" + - node_js: "6" env: NPM_SCRIPT=jscs - - node_js: "5" + - node_js: "6" env: NPM_SCRIPT=lint before_install: diff --git a/index.js b/index.js index 17992ac4..3a603937 100644 --- a/index.js +++ b/index.js @@ -25,44 +25,30 @@ module.exports = { return this.preprocessJs(instrumentedTree, '/', this.name, { registry: this.registry }); - } + }; } }, - /** - * Get content for type - * @param {String} type - type to get content for - * @returns {String} content for type - */ contentFor: function(type) { - // If coverage is enabled add content to test-body-footer to show percentages if (type === 'test-body-footer' && this._isCoverageEnabled()) { - return fs.readFileSync(path.join(__dirname, 'lib', 'templates', 'test-body-footer.html')); + var template = fs.readFileSync(path.join(__dirname, 'lib', 'templates', 'test-body-footer.html')).toString(); + return template.replace('{%PROJECT_NAME%}', this._parentName()); } return undefined; }, - /** - * Add instrumentation to JavaScript tree if coverage is enabled - * @param {String} type - what kind of tree - * @param {Tree} tree - tree to process - * @returns {[type]} processed tree - */ preprocessTree: function(type, tree) { var useBabelInstrumenter = this._getConfig().useBabelInstrumenter === true; - // If coverage isn't enabled or tree is not JavaScript tree then we don't need to alter the tree if (!this._isCoverageEnabled() || (type !== 'js' && type !=='addon-js')) { return tree; } - // Make sure we exclude files defined in the configuration as well as files from addons var appFiles = new Funnel(tree, { exclude: this._getExcludes() }); - // Instrument JavaScript for code coverage var instrumentedNode = new CoverageInstrumenter(appFiles, { annotation: 'Instrumenting for code coverage', appName: this._parentName(), @@ -72,22 +58,13 @@ module.exports = { templateExtensions: this.registry.extensionsForType('template') }); - // Return JavaScript tree with instrumented source return new BroccoliMergeTrees([tree, instrumentedNode], { overwrite: true }); }, - /** - * If coverage is enabled attach coverage middleware to the express server run by ember-cli - * @param {Object} startOptions - Express server start options - */ serverMiddleware: function(startOptions) { this.testemMiddleware(startOptions.app); }, - /** - * If coverage is enabled attach coverage middleware to the express server run by testem - * @param {Object} app - the Express app instance - */ testemMiddleware: function(app) { if (!this._isCoverageEnabled()) { return; } attachMiddleware(app, { root: this.project.root, ui: this.ui }); diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index ad75072f..099d2f4c 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -1,5 +1,17 @@