Skip to content

Commit

Permalink
fix(testUnit): correctly disable coverage when debugging browser unit…
Browse files Browse the repository at this point in the history
… tests

fix/add-angular2-router-to-vendor-scripts
  • Loading branch information
Brett Uglow committed Nov 27, 2016
1 parent 9570387 commit 4418a05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/buildTool/webpack/testUnit/templates/karma.conf.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
}
Expand Down
24 changes: 12 additions & 12 deletions test/spec/integration/testUnitTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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');
}
});


Expand Down

0 comments on commit 4418a05

Please sign in to comment.