summaryrefslogtreecommitdiff
path: root/config/karma.config.js
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2019-05-23 17:32:56 +0000
committerClement Ho <clemmakesapps@gmail.com>2019-05-23 17:32:56 +0000
commit57d9f88fd5659da349473e1636f1271b0995c7b0 (patch)
treefe9b356135e0694d90bf7e910edb56aeee496cae /config/karma.config.js
parentdd454852bc941130820b1c647a8580d56acb2a4f (diff)
parent334cfe472a2c6bc1a13f4971303fd7a89ec3ed5d (diff)
downloadgitlab-ce-57d9f88fd5659da349473e1636f1271b0995c7b0.tar.gz
Merge branch '58869-unified-fe-test-script' into 'master'
Create a unified script to run Jest & Karma tests Closes #58869 See merge request gitlab-org/gitlab-ce!27239
Diffstat (limited to 'config/karma.config.js')
-rw-r--r--config/karma.config.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/config/karma.config.js b/config/karma.config.js
index b2fc3a32816..2a5bf3581e0 100644
--- a/config/karma.config.js
+++ b/config/karma.config.js
@@ -9,11 +9,22 @@ const IS_EE = require('./helpers/is_ee_env');
const ROOT_PATH = path.resolve(__dirname, '..');
const SPECS_PATH = /^(?:\.[\\\/])?(ee[\\\/])?spec[\\\/]javascripts[\\\/]/;
-function fatalError(message) {
+function exitError(message) {
console.error(chalk.red(`\nError: ${message}\n`));
process.exit(1);
}
+function exitWarn(message) {
+ console.error(chalk.yellow(`\nWarn: ${message}\n`));
+ process.exit(0);
+}
+
+function exit(message, isError = true) {
+ const fn = isError ? exitError : exitWarn;
+
+ fn(message);
+}
+
// disable problematic options
webpackConfig.entry = undefined;
webpackConfig.mode = 'development';
@@ -31,7 +42,8 @@ webpackConfig.plugins.push(
}),
);
-const specFilters = argumentsParser
+const options = argumentsParser
+ .option('--no-fail-on-empty-test-suite')
.option(
'-f, --filter-spec [filter]',
'Filter run spec files by path. Multiple filters are like a logical OR.',
@@ -41,7 +53,9 @@ const specFilters = argumentsParser
},
[],
)
- .parse(process.argv).filterSpec;
+ .parse(process.argv);
+
+const specFilters = options.filterSpec;
const createContext = (specFiles, regex, suffix) => {
const newContext = specFiles.reduce((context, file) => {
@@ -73,11 +87,13 @@ if (specFilters.length) {
filteredSpecFiles = [...new Set(filteredSpecFiles)];
if (filteredSpecFiles.length < 1) {
- fatalError('Your filter did not match any test files.');
+ const isError = options.failOnEmptyTestSuite;
+
+ exit('Your filter did not match any test files.', isError);
}
if (!filteredSpecFiles.every(file => SPECS_PATH.test(file))) {
- fatalError('Test files must be located within /spec/javascripts.');
+ exitError('Test files must be located within /spec/javascripts.');
}
const CE_FILES = filteredSpecFiles.filter(file => !file.startsWith('ee'));