-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore: add babel plugin to make sure Jest is unaffected by fake Promise implementations #7225
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
title: testResult.testPath[testResult.testPath.length - 1], | ||
}; | ||
}); | ||
const assertionResults: Array<AssertionResult> = runResult.testResults.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore whitespace when looking at this diff. I only added the type annotation
@@ -9,7 +9,7 @@ | |||
|
|||
export type DoneFn = (reason?: string | Error) => void; | |||
export type BlockFn = () => void; | |||
export type BlockName = string | Function; | |||
export type BlockName = string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronabramov whenever you find the time, does this make sense? We do not support just a function in describe
.
This comment has been minimized.
This comment has been minimized.
e7adbf3
to
77b8e82
Compare
This has been sitting without objections for a few days, so I'll merge if CI is happy after the rebase |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Since users have access to the same globals that Jest does inside the sandbox, they can mess with things Jest needs to function, like doing
global.Promise = undefined
. Our approach of just assigning our own localPromise
is brittle in that we have to remember to do it, and it breaks in babel 7. I've verified that at least for Babel 6, this plugin changes the injectedasynToGenerator
helper from Babel, so the approach should hopefully work for Babel 7 as well.See #7016 (comment)
/cc @loganfsmyth
Test plan
I've looked at the generated code, and it looks correct. I've never written a babel plugin before though, so there might be gotchas?
🤞 for CI