Commit 7f2244ee authored by Lukas Eipert's avatar Lukas Eipert

move TEST_FILES variable to `process.env`

parent a8bf6a30
...@@ -21,7 +21,7 @@ var testFiles = process.argv.slice(ignoreUpTo).filter(arg => { ...@@ -21,7 +21,7 @@ var testFiles = process.argv.slice(ignoreUpTo).filter(arg => {
webpackConfig.plugins.push( webpackConfig.plugins.push(
new webpack.DefinePlugin({ new webpack.DefinePlugin({
TEST_FILES: JSON.stringify(testFiles), 'process.env.TEST_FILES': JSON.stringify(testFiles) ,
}) })
); );
......
...@@ -71,21 +71,20 @@ beforeEach(() => { ...@@ -71,21 +71,20 @@ beforeEach(() => {
const axiosDefaultAdapter = getDefaultAdapter(); const axiosDefaultAdapter = getDefaultAdapter();
// eslint-disable-next-line no-undef let testFiles = process.env.TEST_FILES;
let testFile = TEST_FILES; if (testFiles instanceof Array && testFiles.length > 0) {
if (testFile instanceof Array && testFile.length > 0) { console.log(`Running only tests: ${testFiles}`);
console.log(`Running only tests: ${testFile}`); testFiles = testFiles.map(path => path.replace(/^spec\/javascripts\//, '').replace(/\.js$/, ''));
testFile = testFile.map(path => path.replace(/^spec\/javascripts\//, '').replace(/\.js$/, ''));
} else { } else {
console.log('Running all tests'); console.log('Running all tests');
testFile = []; testFiles = [];
} }
// render all of our tests // render all of our tests
const testsContext = require.context('.', true, /_spec$/); const testsContext = require.context('.', true, /_spec$/);
testsContext.keys().forEach(function(path) { testsContext.keys().forEach(function(path) {
try { try {
if (testFile.length === 0 || testFile.some(p => path.includes(p))) { if (testFiles.length === 0 || testFiles.some(p => path.includes(p))) {
testsContext(path); testsContext(path);
} }
} catch (err) { } catch (err) {
......
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