diff options
| author | Mike Greiling <mgreiling@gitlab.com> | 2017-03-20 22:29:45 +0000 |
|---|---|---|
| committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-03-20 22:29:45 +0000 |
| commit | fde335bfb755e766e058b25c65cbc514df9b33f9 (patch) | |
| tree | d829eaccef8913b269b2915f2d9ee615c1adaffe /spec/javascripts/test_bundle.js | |
| parent | b26d4d2ac4cdf3a66e16918dae28d9b724557dd2 (diff) | |
| download | gitlab-ce-fde335bfb755e766e058b25c65cbc514df9b33f9.tar.gz | |
Only add frontend code coverage instrumentation when generating coverage report
Diffstat (limited to 'spec/javascripts/test_bundle.js')
| -rw-r--r-- | spec/javascripts/test_bundle.js | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index c12b44cea89..5cdb6473eda 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -32,10 +32,11 @@ testsContext.keys().forEach(function (path) { } }); -// workaround: include all source files to find files with 0% coverage -// see also https://github.com/deepsweet/istanbul-instrumenter-loader/issues/15 -describe('Uncovered files', function () { - // the following files throw errors because of undefined variables +// if we're generating coverage reports, make sure to include all files so +// that we can catch files with 0% coverage +// see: https://github.com/deepsweet/istanbul-instrumenter-loader/issues/15 +if (process.env.BABEL_ENV === 'coverage') { + // exempt these files from the coverage report const troubleMakers = [ './blob_edit/blob_edit_bundle.js', './cycle_analytics/components/stage_plan_component.js', @@ -48,21 +49,23 @@ describe('Uncovered files', function () { './network/branch_graph.js', ]; - const sourceFiles = require.context('~', true, /^\.\/(?!application\.js).*\.js$/); - sourceFiles.keys().forEach(function (path) { - // ignore if there is a matching spec file - if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) { - return; - } + describe('Uncovered files', function () { + const sourceFiles = require.context('~', true, /\.js$/); + sourceFiles.keys().forEach(function (path) { + // ignore if there is a matching spec file + if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) { + return; + } - it(`includes '${path}'`, function () { - try { - sourceFiles(path); - } catch (err) { - if (troubleMakers.indexOf(path) === -1) { - expect(err).toBeNull(); + it(`includes '${path}'`, function () { + try { + sourceFiles(path); + } catch (err) { + if (troubleMakers.indexOf(path) === -1) { + expect(err).toBeNull(); + } } - } + }); }); }); -}); +} |
