Skip to content
Snippets Groups Projects
Commit daa6195f authored by Winnie Hellmann's avatar Winnie Hellmann
Browse files

Add option to run a single Karma spec file

parent 539996f7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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;
Loading
Loading
@@ -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';
Loading
Loading
@@ -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 () {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment