diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-14 11:23:15 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-03-14 11:23:15 +0000 |
commit | 810436e858886784b87756d5fa4b0b0a8aeabacd (patch) | |
tree | 9e984cf6230a8b34df6a75087e58d2845b51ced0 /spec | |
parent | d32a7c20ca1dc8a64494ac9e9e70f337e79d284b (diff) | |
parent | 0b5d8b9a838a48e119541a39a3f5a32e0a72411a (diff) | |
download | gitlab-ce-810436e858886784b87756d5fa4b0b0a8aeabacd.tar.gz |
Merge branch 'winh-single-test-bundle' into 'master'
Resolve differences in Karma test bundle between CE and EE
See merge request gitlab-org/gitlab-ce!26131
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/test_bundle.js | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 5eef5682bbd..235a17d13b0 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -69,7 +69,7 @@ window.gl = window.gl || {}; window.gl.TEST_HOST = TEST_HOST; window.gon = window.gon || {}; window.gon.test_env = true; -window.gon.ee = false; +window.gon.ee = process.env.EE; gon.relative_url_root = ''; let hasUnhandledPromiseRejections = false; @@ -122,19 +122,26 @@ afterEach(() => { const axiosDefaultAdapter = getDefaultAdapter(); // render all of our tests -const testsContext = require.context('.', true, /_spec$/); -testsContext.keys().forEach(function(path) { - try { - testsContext(path); - } catch (err) { - console.log(err); - console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path); - describe('Test bundle', function() { - it(`includes '${path}'`, function() { - expect(err).toBeNull(); +const testContexts = [require.context('spec', true, /_spec$/)]; + +if (process.env.EE) { + testContexts.push(require.context('ee_spec', true, /_spec$/)); +} + +testContexts.forEach(context => { + context.keys().forEach(path => { + try { + context(path); + } catch (err) { + console.log(err); + console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path); + describe('Test bundle', function() { + it(`includes '${path}'`, function() { + expect(err).toBeNull(); + }); }); - }); - } + } + }); }); describe('test errors', () => { @@ -204,24 +211,35 @@ if (process.env.BABEL_ENV === 'coverage') { ]; describe('Uncovered files', function() { - const sourceFiles = require.context('~', true, /\.(js|vue)$/); + const sourceFilesContexts = [require.context('~', true, /\.(js|vue)$/)]; + + if (process.env.EE) { + sourceFilesContexts.push(require.context('ee', true, /\.(js|vue)$/)); + } + + const allTestFiles = testContexts.reduce( + (accumulator, context) => accumulator.concat(context.keys()), + [], + ); $.holdReady(true); - sourceFiles.keys().forEach(function(path) { - // ignore if there is a matching spec file - if (testsContext.keys().indexOf(`${path.replace(/\.(js|vue)$/, '')}_spec`) > -1) { - return; - } - - it(`includes '${path}'`, function() { - try { - sourceFiles(path); - } catch (err) { - if (troubleMakers.indexOf(path) === -1) { - expect(err).toBeNull(); - } + sourceFilesContexts.forEach(context => { + context.keys().forEach(path => { + // ignore if there is a matching spec file + if (allTestFiles.indexOf(`${path.replace(/\.(js|vue)$/, '')}_spec`) > -1) { + return; } + + it(`includes '${path}'`, function() { + try { + context(path); + } catch (err) { + if (troubleMakers.indexOf(path) === -1) { + expect(err).toBeNull(); + } + } + }); }); }); }); |