Skip to content

Commit

Permalink
fix(build): reconfigure babel so it can run jest tests with async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
evansiroky committed Jul 25, 2019
1 parent 0a8fec1 commit f6f6744
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
4 changes: 4 additions & 0 deletions __tests__/lib/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ describe('jest.js', () => {
const indexWithYaml = require('../test-utils/mocks/index-with-yaml')
expect(indexWithYaml).toBeTruthy()
})

it('should be able to perform an async test', async () => {
await Promise.resolve()
})
})
4 changes: 4 additions & 0 deletions __tests__/test-utils/mocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default class MockTestComponentUniqueName extends Component {
test: 'hi'
}

doSomeFancyAsyncThingy = async () => {
await Promise.resolve('hi')
}

/**
* Render the component.
*/
Expand Down
8 changes: 5 additions & 3 deletions lib/babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const addExports = require('babel-plugin-add-module-exports')
const babelEnv = require('@babel/preset-env')
const flow = require('@babel/preset-flow')
const react = require('@babel/preset-react')
const reactRequire = require('babel-plugin-react-require').default
const istanbul = require('babel-plugin-istanbul')
const lodash = require('babel-plugin-lodash')
const reactDisplayName = require('@babel/plugin-transform-react-display-name')
const reactRequire = require('babel-plugin-react-require').default
const classProperties = require('@babel/plugin-proposal-class-properties')
const exportFrom = require('@babel/plugin-proposal-export-namespace-from')
const istanbul = require('babel-plugin-istanbul')
const reactDisplayName = require('@babel/plugin-transform-react-display-name')
const runtime = require('@babel/plugin-transform-runtime')

const browsers = require('./constants').BROWSER_SUPPORT

Expand All @@ -17,6 +18,7 @@ module.exports = function (env, instrument) {
classProperties,
exportFrom,
lodash,
[runtime, { corejs: 2 }],
reactDisplayName,
reactRequire
]
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
"mastarm-test": "bin/mastarm-test"
},
"scripts": {
"cover": "bin/mastarm test --env test --test-environment node --coverage --coverage-paths bin",
"cover": "yarn run jest -- --coverage --coverage-paths bin",
"flow": "bin/mastarm flow",
"jest": "bin/mastarm test --run-in-band --env test --test-environment node",
"lint": "bin/mastarm lint lib __tests__",
"semantic-release": "semantic-release",
"pretest": "yarn",
"test": "bin/mastarm lint lib __tests__ && bin/mastarm test --run-in-band --env test --test-environment node"
"test": "yarn run lint && yarn run flow && yarn run jest"
},
"repository": {
"type": "git",
Expand All @@ -48,11 +49,12 @@
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-react-display-name": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.4",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.3.4",
"@babel/runtime-corejs2": "^7.5.5",
"aws-sdk": "^2.414.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
Expand Down
28 changes: 22 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,16 @@
dependencies:
regenerator-transform "^0.13.4"

"@babel/plugin-transform-runtime@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.5.5.tgz#a6331afbfc59189d2135b2e09474457a8e3d28bc"
integrity sha512-6Xmeidsun5rkwnGfMOp6/z9nSzWpHFNVr2Jx7kwoq4mVatQfQx5S56drBgEHF+XQbKOdIaOiMIINvp/kAwMN+w==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/helper-plugin-utils" "^7.0.0"
resolve "^1.8.1"
semver "^5.5.1"

"@babel/plugin-transform-shorthand-properties@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0"
Expand Down Expand Up @@ -690,12 +700,13 @@
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"

"@babel/runtime@^7.3.4":
version "7.3.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83"
integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g==
"@babel/runtime-corejs2@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.5.5.tgz#c3214c08ef20341af4187f1c9fbdc357fbec96b2"
integrity sha512-FYATQVR00NSNi7mUfpPDp7E8RYMXDuO8gaix7u/w3GekfUinKgX1AcTxs7SoiEmoEW9mbpjrwqWSW6zCmw5h8A==
dependencies:
regenerator-runtime "^0.12.0"
core-js "^2.6.5"
regenerator-runtime "^0.13.2"

"@babel/template@^7.0.0", "@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2":
version "7.2.2"
Expand Down Expand Up @@ -2518,7 +2529,7 @@ copy-descriptor@^0.1.0:
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=

core-js@2:
core-js@2, core-js@^2.6.5:
version "2.6.9"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==
Expand Down Expand Up @@ -8810,6 +8821,11 @@ regenerator-runtime@^0.12.0:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==

regenerator-runtime@^0.13.2:
version "0.13.3"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5"
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==

regenerator-transform@^0.13.4:
version "0.13.4"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.4.tgz#18f6763cf1382c69c36df76c6ce122cc694284fb"
Expand Down

0 comments on commit f6f6744

Please sign in to comment.