-
Notifications
You must be signed in to change notification settings - Fork 15
Support async/await in jest tests #105
Comments
Given that we currently use Node v10.15.1 in liferay-portal (which has native |
@wincent It looks like we could do something like this example from the jest docs:
// babel.config.js
module.exports = api => {
const isTest = api.env('test');
// You can use isTest to determine what presets and plugins to use.
return {
// ...
};
}; We also might need to add
|
This reverts commit ccd62f4.
feat: support async/await in jest tests (#105)
Closing this because I am about to cut a release, so this will go to liferay-portal master today (at least, I'll submit the PR today). |
When using async/await in tests the following error is thrown:
Possible Solutions
Option 1
According to Jest docs:
In
.babelrc
(Sources: jestjs/jest#3126 (comment), babel/babel#7601 (comment))
Option 2
Installing
@babel/plugin-transform-runtime
and adding the following configuration to.babelrc
(Sources: jestjs/jest#3126 (comment), babel/babel#8829 (comment))
Option 3
Importing
babel-polyfill
to the jestsetup.js
file. Which would mean addingbabel-polyfill
as a new devDependency.(Source: babel/babel#5085 (comment))
Final Comments
I'm currently using Option 2 since it scopes the plugin to just the tests (where the issue is only occurring), but I'd like to hear everyone else's opinion since I haven't noticed any differences with any of these fixes besides Option 3 throwing a new error
Warning: Can't perform a React state update on an unmounted component
in the tests (but that's probably something I'd need to fix in the component/tests itself).The text was updated successfully, but these errors were encountered: