Commit 810436e8 authored by Phil Hughes's avatar Phil Hughes

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
parents d32a7c20 0b5d8b9a
...@@ -324,6 +324,10 @@ module.exports = { ...@@ -324,6 +324,10 @@ module.exports = {
reportFilename: path.join(ROOT_PATH, 'webpack-report/index.html'), reportFilename: path.join(ROOT_PATH, 'webpack-report/index.html'),
statsFilename: path.join(ROOT_PATH, 'webpack-report/stats.json'), statsFilename: path.join(ROOT_PATH, 'webpack-report/stats.json'),
}), }),
new webpack.DefinePlugin({
'process.env.EE': JSON.stringify(IS_EE),
}),
].filter(Boolean), ].filter(Boolean),
devServer: { devServer: {
......
...@@ -69,7 +69,7 @@ window.gl = window.gl || {}; ...@@ -69,7 +69,7 @@ window.gl = window.gl || {};
window.gl.TEST_HOST = TEST_HOST; window.gl.TEST_HOST = TEST_HOST;
window.gon = window.gon || {}; window.gon = window.gon || {};
window.gon.test_env = true; window.gon.test_env = true;
window.gon.ee = false; window.gon.ee = process.env.EE;
gon.relative_url_root = ''; gon.relative_url_root = '';
let hasUnhandledPromiseRejections = false; let hasUnhandledPromiseRejections = false;
...@@ -122,19 +122,26 @@ afterEach(() => { ...@@ -122,19 +122,26 @@ afterEach(() => {
const axiosDefaultAdapter = getDefaultAdapter(); const axiosDefaultAdapter = getDefaultAdapter();
// render all of our tests // render all of our tests
const testsContext = require.context('.', true, /_spec$/); const testContexts = [require.context('spec', true, /_spec$/)];
testsContext.keys().forEach(function(path) {
try { if (process.env.EE) {
testsContext(path); testContexts.push(require.context('ee_spec', true, /_spec$/));
} catch (err) { }
console.log(err);
console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path); testContexts.forEach(context => {
describe('Test bundle', function() { context.keys().forEach(path => {
it(`includes '${path}'`, function() { try {
expect(err).toBeNull(); 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', () => { describe('test errors', () => {
...@@ -204,24 +211,35 @@ if (process.env.BABEL_ENV === 'coverage') { ...@@ -204,24 +211,35 @@ if (process.env.BABEL_ENV === 'coverage') {
]; ];
describe('Uncovered files', function() { 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); $.holdReady(true);
sourceFiles.keys().forEach(function(path) { sourceFilesContexts.forEach(context => {
// ignore if there is a matching spec file context.keys().forEach(path => {
if (testsContext.keys().indexOf(`${path.replace(/\.(js|vue)$/, '')}_spec`) > -1) { // ignore if there is a matching spec file
return; if (allTestFiles.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();
}
} }
it(`includes '${path}'`, function() {
try {
context(path);
} catch (err) {
if (troubleMakers.indexOf(path) === -1) {
expect(err).toBeNull();
}
}
});
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment