Skip to content

Commit

Permalink
Revert "Support async/await in jest tests (liferay#105)"
Browse files Browse the repository at this point in the history
This reverts commit ccd62f4.
  • Loading branch information
thektan committed Jul 1, 2019
1 parent ccd62f4 commit f5b636f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 40 deletions.
16 changes: 0 additions & 16 deletions packages/liferay-npm-scripts/src/config/babel.test.json

This file was deleted.

9 changes: 3 additions & 6 deletions packages/liferay-npm-scripts/src/scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ module.exports = function(arrArgs = []) {
buildSoy();
}

withBabelConfig(
() => {
spawnSync('jest', ['--config', CONFIG_PATH, ...arrArgs.slice(1)]);
},
{test: true}
);
withBabelConfig(() => {
spawnSync('jest', ['--config', CONFIG_PATH, ...arrArgs.slice(1)]);
});

if (useSoy) {
cleanSoy();
Expand Down
7 changes: 0 additions & 7 deletions packages/liferay-npm-scripts/src/utils/getMergedConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ function getMergedConfig(type, property) {
);
break;

case 'babel.test':
mergedConfig = deepMerge(
[require('../config/babel.test'), getUserConfig('babel')],
deepMerge.MODE.BABEL
);
break;

case 'bundler':
mergedConfig = deepMerge([
require('../config/npm-bundler'),
Expand Down
16 changes: 5 additions & 11 deletions packages/liferay-npm-scripts/src/utils/withBabelConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ const getMergedConfig = require('./getMergedConfig');
const moveToTemp = require('../utils/moveToTemp');
const removeFromTemp = require('../utils/removeFromTemp');

/**
* Updates the .babelrc file with the merged configurations.
* @param {boolean} options.test True if the test babel config should be used.
*/
function setBabelConfig(options = {}) {
const babelConfig = options.test
? getMergedConfig('babel.test')
: getMergedConfig('babel');
const BABEL_CONFIG = getMergedConfig('babel');

function setBabelConfig() {
moveToTemp('.babelrc', 'babel');

fs.writeFileSync('.babelrc', JSON.stringify(babelConfig));
fs.writeFileSync('.babelrc', JSON.stringify(BABEL_CONFIG));
}

function removeBabelConfig() {
Expand All @@ -35,9 +29,9 @@ function removeBabelConfig() {
* be synchronous), and then restores the Babel environment to its original
* state.
*/
function withBabelConfig(callback, options) {
function withBabelConfig(callback) {
try {
setBabelConfig(options);
setBabelConfig();

callback();
} finally {
Expand Down

0 comments on commit f5b636f

Please sign in to comment.