Skip to content

Commit

Permalink
Fixes #28229 - upgrade babel to v7
Browse files Browse the repository at this point in the history
Include an upgrade for jest so test works with babel v7
  • Loading branch information
sharvit authored and amirfefer committed Dec 3, 2019
1 parent f3f68ca commit 0bbca6c
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 41 deletions.
13 changes: 5 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"presets": [
"env",
"react"
],
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
"transform-object-assign",
"syntax-dynamic-import"
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-object-assign",
"@babel/plugin-syntax-dynamic-import"
],
"env": {
"test": {
Expand Down
12 changes: 6 additions & 6 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ module.exports = env => {
loader: 'babel-loader',
options: {
'presets': [
path.join(__dirname, '..', 'node_modules/babel-preset-react'),
path.join(__dirname, '..', 'node_modules/babel-preset-env')
path.join(__dirname, '..', 'node_modules/@babel/preset-react'),
path.join(__dirname, '..', 'node_modules/@babel/preset-env')
],
'plugins': [
path.join(__dirname, '..', 'node_modules/babel-plugin-transform-class-properties'),
path.join(__dirname, '..', 'node_modules/babel-plugin-transform-object-rest-spread'),
path.join(__dirname, '..', 'node_modules/babel-plugin-transform-object-assign'),
path.join(__dirname, '..', 'node_modules/babel-plugin-syntax-dynamic-import')
path.join(__dirname, '..', 'node_modules/@babel/plugin-proposal-class-properties'),
path.join(__dirname, '..', 'node_modules/@babel/plugin-proposal-object-rest-spread'),
path.join(__dirname, '..', 'node_modules/@babel/plugin-transform-object-assign'),
path.join(__dirname, '..', 'node_modules/@babel/plugin-syntax-dynamic-import')
]
}
},
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "./node_modules/.bin/eslint -c .eslintrc webpack/ script/",
"foreman-js:link": "./script/npm_link_foreman_js.sh",
"postlint": "./script/npm_lint_plugins.js",
"test": "node node_modules/.bin/jest --no-cache --config config/jest.config.js",
"test": "node --max_old_space_size=8192 node_modules/.bin/jest --no-cache --config config/jest.config.js",
"test:watch": "node node_modules/.bin/jest --watchAll --config config/jest.config.js",
"test:current": "node node_modules/.bin/jest --watch --config config/jest.config.js",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
Expand All @@ -20,7 +20,7 @@
"create-react-component": "yo react-domain"
},
"dependencies": {
"@theforeman/vendor": "^2.0.0",
"@theforeman/vendor": "^3.0.0",
"intl": "~1.2.5",
"jed": "^1.1.1",
"react-intl": "^2.8.0"
Expand All @@ -34,22 +34,22 @@
"@storybook/addon-storysource": "^3.4.12",
"@storybook/react": "~3.4.12",
"@storybook/storybook-deployer": "^2.0.0",
"@theforeman/vendor-dev": "^2.0.0",
"@theforeman/vendor-dev": "^3.0.0",
"argv-parse": "^1.0.1",
"axios-mock-adapter": "^1.10.0",
"babel-cli": "^6.10.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.1",
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.7.0",
"@babel/preset-react": "^7.7.0",
"@babel/register": "^7.7.0",
"babel-eslint": "^10.0.0",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.0",
"babel-plugin-dynamic-import-node": "^2.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.9.0",
"compression-webpack-plugin": "~1.1.11",
"coveralls": "^3.0.0",
"cross-env": "^5.2.0",
Expand All @@ -67,7 +67,7 @@
"file-loader": "^0.9.0",
"highlight.js": "~9.14.0",
"identity-obj-proxy": "^3.0.0",
"jest-cli": "^23.6.0",
"jest-cli": "^24.9.0",
"jest-prop-type-error": "^1.1.0",
"node-sass": "^4.5.0",
"prettier": "^1.19.1",
Expand Down
8 changes: 4 additions & 4 deletions webpack/assets/javascripts/bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'babel-polyfill';
import 'core-js/shim';
import 'regenerator-runtime/runtime';

import compute from './foreman_compute_resource';
import componentRegistry from './react_app/components/componentRegistry';
import i18n from './react_app/common/I18n';
Expand Down Expand Up @@ -30,9 +32,7 @@ import './bundle_novnc';
// Set the public path for dynamic imports
if (process.env.NODE_ENV !== 'production') {
/* eslint-disable-next-line */
__webpack_public_path__ = `${window.location.protocol}//${
window.location.hostname
}:3808/webpack/`;
__webpack_public_path__ = `${window.location.protocol}//${window.location.hostname}:3808/webpack/`;
}

window.tfm = Object.assign(window.tfm || {}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import {

jest.mock('../../../redux/API');

const runWithGetState = (state, params, action) => dispatch => {
const runWithGetState = (state, params, action) => async dispatch => {
const getState = () => ({
editor: state,
});
action(params)(dispatch, getState);
await action(params)(dispatch, getState);
};

const runRenderTemplate = (state, serverMock) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import {

jest.mock('../../../../API');

const runWithGetState = (state, action, ...params) => dispatch => {
const runWithGetState = (state, action, ...params) => async dispatch => {
const getState = () => ({
auditsPage: state,
});
action(...params)(dispatch, getState);
await action(...params)(dispatch, getState);
};

const runFetchAuditsAPI = (state, resourceMock, serverMock) => {
Expand All @@ -44,7 +44,12 @@ const fixtures = {

'should fetch Audits and fail': () =>
runFetchAuditsAPI(stateMock.auditsPage, getMock, async () => {
throw new Error('some-error');
const error = new Error('some-error');
error.response = {
status: 'some-status',
statusText: 'some status text',
};
throw error;
}),

'should fetchAndPush': () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ Array [
"type": "AUDITS_PAGE_SHOW_LOADING",
},
],
Array [
Object {
"payload": Object {
"message": Object {
"text": "some-status some status text",
"type": "error",
},
},
"type": "AUDITS_PAGE_DATA_FAILED",
},
],
]
`;

Expand Down
4 changes: 3 additions & 1 deletion webpack/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'core-js/shim';
import 'regenerator-runtime/runtime';

import React from 'react';
import { configure, storiesOf } from '@storybook/react';
import 'babel-polyfill';
import Markdown from './components/Markdown';
import Story from './components/Story';

Expand Down
4 changes: 3 additions & 1 deletion webpack/test_setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'babel-polyfill';
import 'core-js/shim';
import 'regenerator-runtime/runtime';

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Expand Down

0 comments on commit 0bbca6c

Please sign in to comment.