The Jest "An Async Example" guide starts with:
First, enable Babel support in Jest...
But I miss to see why and where does Jest needs Babel for.
Node.js has supported async
functions by default since version 7.6.0, so (as you suspected) Babel
is not needed for Jest
to run tests using async
functions.
I just confirmed this by installing only Jest
v24.6.0 and ran this test with Node.js v10.15.1:
test('hi', async () => {
const val = await Promise.resolve('hello');
expect(val).toBe('hello');
});
...and it passed just fine.
On the other hand, Babel
is required to use ES6 module syntax.
Many of the examples in the "An Async Example" doc use ES6 module syntax (export default ...
, import * as ...
, etc.) so Babel
is required for any of those examples to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With