From 6e55ea24830750c7c705213cb64c838e1d0a6491 Mon Sep 17 00:00:00 2001 From: Steve Brush Date: Thu, 9 Aug 2018 14:09:17 -0400 Subject: [PATCH] RC > Instrument different directory for libraries (#448) --- config/webpack/test.webpack.config.js | 14 +++++++++++--- test/config-webpack-test.spec.js | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/config/webpack/test.webpack.config.js b/config/webpack/test.webpack.config.js index f5d1bc73..ebfd5aa6 100644 --- a/config/webpack/test.webpack.config.js +++ b/config/webpack/test.webpack.config.js @@ -17,10 +17,16 @@ function outPath() { } function getWebpackConfig(skyPagesConfig, argv) { - const runCoverage = (!argv || argv.coverage !== false); - skyPagesConfig.runtime.includeRouteModule = false; const ENV = process.env.ENV = process.env.NODE_ENV = 'test'; - const srcPath = path.resolve(process.cwd(), 'src', 'app'); + const argvCoverage = (argv) ? argv.coverage : true; + const runCoverage = (argvCoverage !== false); + + let srcPath; + if (argvCoverage === 'library') { + srcPath = path.resolve(process.cwd(), 'src', 'app', 'public'); + } else { + srcPath = path.resolve(process.cwd(), 'src', 'app'); + } const resolves = [ process.cwd(), @@ -33,6 +39,8 @@ function getWebpackConfig(skyPagesConfig, argv) { outPath('node_modules') ]; + skyPagesConfig.runtime.includeRouteModule = false; + let alias = aliasBuilder.buildAliasList(skyPagesConfig); let config = { diff --git a/test/config-webpack-test.spec.js b/test/config-webpack-test.spec.js index 7e56f717..7505e5bc 100644 --- a/test/config-webpack-test.spec.js +++ b/test/config-webpack-test.spec.js @@ -1,6 +1,7 @@ /*jshint jasmine: true, node: true */ 'use strict'; +const path = require('path'); const runtimeUtils = require('../utils/runtime-test-utils'); describe('config webpack test', () => { @@ -104,4 +105,18 @@ describe('config webpack test', () => { expect(foundMatch).toBe(true); } }); + + it('should run coverage differently for libraries', () => { + let instrumentLoader = getInstrumentLoader(); + let index = instrumentLoader.include.indexOf(path.resolve('src', 'app')); + + expect(index > -1).toEqual(true); + + instrumentLoader = getInstrumentLoader({ + coverage: 'library' + }); + + index = instrumentLoader.include.indexOf(path.resolve('src', 'app', 'public')); + expect(index > -1).toEqual(true); + }); });