diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-03-14 00:12:34 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-03-14 00:12:34 +0300 |
commit | 0c6e4b4c728c32923f1090eaf9927d84d7e78e36 (patch) | |
tree | 4332874efe65375457e7a192820813628a132661 /spec/javascripts/test_bundle.js | |
parent | 1715622c054434abc752c7be11ec4daec9231d5a (diff) |
Resolve differences in Karma test bundle between CE and EE
Diffstat (limited to 'spec/javascripts/test_bundle.js')
-rw-r--r-- | spec/javascripts/test_bundle.js | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 5eef5682bbd..32011375673 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -122,19 +122,25 @@ 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$/), + 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 +210,33 @@ if (process.env.BABEL_ENV === 'coverage') { ]; describe('Uncovered files', function() { - const sourceFiles = require.context('~', true, /\.(js|vue)$/); + const sourceFilesContexts = [ + require.context('~', true, /\.(js|vue)$/), + 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(); + } + } + }); }); }); }); |