diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2017-12-22 00:01:51 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-12-22 00:01:51 +0100 |
commit | daa6195f84f53cc484ad0730f2c5a88c6e654b15 (patch) | |
tree | 8ef78c6688c247dc57a0c94b4e88a902fc4015a8 | |
parent | 539996f7daf9115f713c0802dea85c53c5f6838a (diff) | |
download | gitlab-ce-daa6195f84f53cc484ad0730f2c5a88c6e654b15.tar.gz |
Add option to run a single Karma spec filewinh-single-karma-test
-rw-r--r-- | config/karma.config.js | 8 | ||||
-rw-r--r-- | spec/javascripts/test_bundle.js | 15 |
2 files changed, 21 insertions, 2 deletions
diff --git a/config/karma.config.js b/config/karma.config.js index 9f018d14b8f..609c4780ccc 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -12,8 +12,16 @@ if (webpackConfig.plugins) { plugin instanceof webpack.DefinePlugin ); }); +} else { + webpackConfig.plugins = []; } +webpackConfig.plugins.push( + new webpack.DefinePlugin({ + TEST_FILE: JSON.stringify(process.env.TEST_FILE), + }) +); + webpackConfig.devtool = 'cheap-inline-source-map'; // Karma configuration diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 6897c991066..8145f905181 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -6,6 +6,7 @@ import '~/commons'; import Vue from 'vue'; import VueResource from 'vue-resource'; +import Translate from '~/vue_shared/translate'; const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent); Vue.config.devtools = !isHeadlessChrome; @@ -24,6 +25,7 @@ Vue.config.errorHandler = function (err) { }; Vue.use(VueResource); +Vue.use(Translate); // enable test fixtures jasmine.getFixtures().fixturesPath = '/base/spec/javascripts/fixtures'; @@ -61,11 +63,20 @@ beforeEach(() => { Vue.http.interceptors = builtinVueHttpInterceptors.slice(); }); -// render all of our tests +// eslint-disable-next-line no-undef +let testFile = TEST_FILE; +if (testFile) { + console.log(`Running only ${testFile}`); + testFile = testFile.replace(/^spec\/javascripts\//, ''); + testFile = testFile.replace(/\.js$/, ''); +} + const testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(function (path) { try { - testsContext(path); + if (!testFile || path.indexOf(testFile) > -1) { + testsContext(path); + } } catch (err) { console.error('[ERROR] Unable to load spec: ', path); describe('Test bundle', function () { |