From 7cbc9d1edd1bc2bcb11673d54e601c052bf5a2b3 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 9 Mar 2017 22:53:44 +0100 Subject: [PATCH] fix: coverage issue with saucelabs * Saucelabs seems to have issues with Edge and the `karma-coverage` plugin. * Running on Browserstack seems to be work without any flakiness and also makes the build faster (runs less browsers than on saucelabs) --- scripts/ci/build-and-test.sh | 4 ++-- test/karma.conf.js | 4 +++- tools/gulp/tasks/coverage.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/ci/build-and-test.sh b/scripts/ci/build-and-test.sh index 820bb1fe560f..53eca7120f6e 100755 --- a/scripts/ci/build-and-test.sh +++ b/scripts/ci/build-and-test.sh @@ -25,8 +25,8 @@ else $(npm bin)/gulp ci:test fi -# Don't upload coverage for both test modes (browserstack and saucelabs) and inside of PRs. -if [[ "$MODE" == "saucelabs_required" ]] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then +# Upload coverage results if those are present. +if [ -f dist/coverage/coverage-summary.json ]; then $(npm bin)/gulp ci:coverage fi diff --git a/test/karma.conf.js b/test/karma.conf.js index 49c1f7038ac0..c6ccd5ccf91c 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -100,7 +100,9 @@ module.exports = (config) => { if (process.env['TRAVIS']) { let buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`; - if (process.env['TRAVIS_PULL_REQUEST'] === 'false') { + if (process.env['TRAVIS_PULL_REQUEST'] === 'false' && + process.env['MODE'] === "browserstack_required") { + config.preprocessors['dist/@angular/material/**/!(*+(.|-)spec).js'] = ['coverage']; config.reporters.push('coverage'); } diff --git a/tools/gulp/tasks/coverage.ts b/tools/gulp/tasks/coverage.ts index ea12470bf172..494b01c9714a 100644 --- a/tools/gulp/tasks/coverage.ts +++ b/tools/gulp/tasks/coverage.ts @@ -9,7 +9,7 @@ task('coverage:upload', () => { throw new Error('No coverage file has been found!'); } - if (!isTravisPushBuild()) { + if (isTravisPushBuild()) { throw new Error('Coverage results will be only uploaded inside of Travis Push builds.'); }