-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests fail with async
#1160
Comments
The problem seems to be caused by some interaction between the return value of an E.g.: const getId = async () => {
const p = await dispatch(42)
return p.id
} works, while const getId = async () => {
const { id } = await dispatch(42)
return id
} or const getId = async () => {
const p = await dispatch(42)
const { id } = p
return id
} don't work. |
In facts, tapping into var p, null;return _regenerator2.default.wrap
^^^^ |
Did it work before? |
Yes, we're migrating a project from v0.6.1 to the latest |
I'm getting a lot of "strange" errors. Another one, for example, is that while using const { Record } = require("immutable")
const User = new Record({ id: NaN })
new User({ id: 42 }) while it worked before (and works now, same version). and the error is:
|
I was able to fix all the errors by reintroducing |
Also removing |
Can you try:
? |
If you mean like this: // ...
const plugins = [
// ...
// Polyfills the runtime needed for async/await and generators
[require.resolve('babel-plugin-transform-runtime'), {
helpers: false,
polyfill: false,
regenerator: true,
// Resolve the Babel runtime relative to the config.
moduleName: path.dirname(require.resolve('babel-runtime/package'))
}],
// The following two plugins are currently necessary to get
// babel-preset-env to work with rest/spread. More info here:
// https://github.com/babel/babel-preset-env#caveats
// https://github.com/babel/babel/issues/4074
// const { a, ...z } = obj;
require.resolve('babel-plugin-transform-es2015-destructuring'),
// const fn = ({ a, ...otherProps }) => otherProps;
require.resolve('babel-plugin-transform-es2015-parameters')
];
// ...
if (env === 'test') {
module.exports = {
presets: [
// ES features necessary for user's Node version
[require('babel-preset-env').default, {
targets: {
node: 'current',
},
}],
// ... no, unfortunately it doesn't work (I always double-check it by reintroducing |
@hzoo Any ideas? |
The result I get from
I'll try to reintroduce them one by one.. |
Thanks for your help debugging this. |
No worries ^_^ Apparently what I need are:
so yeah, the two you were saying before, plus Although we use es6+ a lot, and we have approx 230 unit tests, I have to say that these could be only our needs, and others might need more plugins.. |
So these are likely Babel bugs about hidden plugin dependencies? Can you reduce each to an isolated Babel bug report? |
Either that, or some bug in In either case should I make a PR reverting to using |
I won't be able to cut a release today anyway so might as well wait for more details (or investigate myself tomorrow if I get there first). Once we know more we'll decide and cut a release. |
Seems reasonable |
@EnoahNetzach I'll try and take a look at this later tonight as well |
It seems that I think that definitely we should ask help from @kittens? |
btw, this seems to be already issued on babel, maybe I'll continue the conversation there. |
Is this issue underlying for all the problems listed here? |
Not entirely sure, I checked only |
I'm closing this issue in favor to #1156 |
Not completely sure this is an issue of this repo, could be a
jest
's one. I'm reporting it here because it could be a configuration problem.Description
Running
npm test
fails when usingasync
/await
.Expected behavior
The test runs
Actual behavior
I receive an error:
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
: v0.8.1node -v
: v6.9.1npm -v
: v3.10.8Operating system: Fedora 24
Browser and version: --
Reproducible Demo
Just a new "cra" project, with an
async
/await
function tested.I have a demonstration here, just
git clone
,npm install
andnpm test
.The text was updated successfully, but these errors were encountered: