diff --git a/lib/buildTool/webpack/testUnit/templates/karma.conf.js.tpl b/lib/buildTool/webpack/testUnit/templates/karma.conf.js.tpl index 6fff462..f780c55 100644 --- a/lib/buildTool/webpack/testUnit/templates/karma.conf.js.tpl +++ b/lib/buildTool/webpack/testUnit/templates/karma.conf.js.tpl @@ -30,7 +30,7 @@ function getConfitConfig(config) { // No point checking threshold if we removing the the coverage tool commonConfig.reporters = commonConfig.reporters.filter(function(reporter) { - return reporter !== 'threshold' || reporter !== 'coverage'; + return reporter !== 'threshold' && reporter !== 'coverage'; }); } diff --git a/test/spec/integration/testUnitTest.js b/test/spec/integration/testUnitTest.js index 3ec06e6..24ca7b6 100644 --- a/test/spec/integration/testUnitTest.js +++ b/test/spec/integration/testUnitTest.js @@ -23,15 +23,15 @@ function runCommand(cmd) { module.exports = function(confitConfig, unitTestPath, commandToRun, hasCodeCoverage) { describe(commandToRun, () => { - it.only(`should pass the unit tests in the sampleApp code ${hasCodeCoverage ? 'WITH' : 'WITHOUT'} code coverage`, function() { - assert.doesNotThrow(() => runCommand(commandToRun)); - + it(`should pass the unit tests in the sampleApp code ${hasCodeCoverage ? 'WITH' : 'WITHOUT'} code coverage`, function() { let reportDir = path.join(process.env.TEST_DIR, confitConfig.paths.output.reportDir); + fs.removeSync(reportDir); // Remove the directory + + assert.doesNotThrow(() => runCommand(commandToRun)); if (hasCodeCoverage) { assert(fs.existsSync(reportDir + 'coverage/') === true, 'Coverage dir exists'); assert(fs.existsSync(reportDir + 'coverage/lcov/lcov.info') === true, 'lcov/lcov.info exists'); - fs.removeSync(reportDir); // Remove the directory } else { assert(fs.existsSync(reportDir + 'coverage/') === false, 'Coverage directory does NOT exist'); } @@ -62,18 +62,18 @@ module.exports = function(confitConfig, unitTestPath, commandToRun, hasCodeCover if (hasCodeCoverage) { assert(filesCovered > 3, 'Files were covered'); - } else { - assert(filesCovered === 3, 'Files were not covered'); - } - let summaryLine = results.filter((item) => item.indexOf('All files') === 0); + let summaryLine = results.filter((item) => item.indexOf('All files') === 0); - assert(summaryLine.length === 1, 'Summary line array contains 1 item'); + assert(summaryLine.length === 1, 'Summary line array contains 1 item'); - let summaryParts = summaryLine[0].split('|'); + let summaryParts = summaryLine[0].split('|'); - assert(summaryParts[0].indexOf('All files') === 0); - assert(parseFloat(summaryParts[2], 10) >= 50, 'Branches have at-least 50% coverage'); + assert(summaryParts[0].indexOf('All files') === 0); + assert(parseFloat(summaryParts[2], 10) >= 50, 'Branches have at-least 50% coverage'); + } else { + assert(filesCovered === 0, 'Files were not covered'); + } });