-
-
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
feat: add async support to babel-jest #11192
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6e4c1c7
feat: add async support to babel-jest
SimenB 960d6d2
changelog
SimenB 0c86e33
snap
SimenB 536efaa
async config loading as well
SimenB dca6de2
update peer dep for async config support
SimenB 8eb6234
snap
SimenB 8608fc1
move things out of closure
SimenB d052f81
fix test
SimenB 809380d
add async test
SimenB 6275f6a
integration test
SimenB 00c2a0e
Merge branch 'master' into babel-jest-async
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
e2e/transform/babel-jest-async/__tests__/babelJest.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import nullReturningFunc from '../only-file-to-transform.js'; | ||
|
||
it('strips flowtypes using babel-jest', () => { | ||
expect(nullReturningFunc()).toBe(null); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const someFunction = (): null => null; | ||
|
||
export default someFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "module", | ||
"dependencies": { | ||
"@babel/preset-flow": "^7.0.0" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node", | ||
"transform": { | ||
"only-file-to-transform\\.js$": "<rootDir>/transformer.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {fileURLToPath} from 'url'; | ||
import babelJest from 'babel-jest'; | ||
|
||
export default { | ||
...babelJest.default.createTransformer({ | ||
presets: ['@babel/preset-flow'], | ||
root: fileURLToPath(import.meta.url), | ||
}), | ||
// remove the synchronous functions | ||
getCacheKey: undefined, | ||
process: undefined, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This file is generated by running "yarn install" inside your project. | ||
# Manual changes might be lost - proceed with caution! | ||
|
||
__metadata: | ||
version: 4 | ||
cacheKey: 7 | ||
|
||
"@babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.13.0": | ||
version: 7.13.0 | ||
resolution: "@babel/helper-plugin-utils@npm:7.13.0" | ||
checksum: 229ac1917b43ad38732d2d4a9a826f87d8945719249efe1d6191f3e25ba6027a289af70380d82d62a03fc9e82558a0ea6f12739cbb55b64bb280d6b511b4ca65 | ||
languageName: node | ||
linkType: hard | ||
|
||
"@babel/plugin-syntax-flow@npm:^7.12.13": | ||
version: 7.12.13 | ||
resolution: "@babel/plugin-syntax-flow@npm:7.12.13" | ||
dependencies: | ||
"@babel/helper-plugin-utils": ^7.12.13 | ||
peerDependencies: | ||
"@babel/core": ^7.0.0-0 | ||
checksum: de8845354dda62b7857a518a54f85bf30809ed1d7cc5ace93ced6da16d095cba78487d18651f1b2277db58d8e749cb910c703f96529af198369226e374df5f73 | ||
languageName: node | ||
linkType: hard | ||
|
||
"@babel/plugin-transform-flow-strip-types@npm:^7.12.13": | ||
version: 7.13.0 | ||
resolution: "@babel/plugin-transform-flow-strip-types@npm:7.13.0" | ||
dependencies: | ||
"@babel/helper-plugin-utils": ^7.13.0 | ||
"@babel/plugin-syntax-flow": ^7.12.13 | ||
peerDependencies: | ||
"@babel/core": ^7.0.0-0 | ||
checksum: 60903f5e3619b4f4a19d6d00a4d10c5b97566f5d4c56dd35ccdaa6e621fc955ec4003f12cd73ec99475894a7eca6a34aa4b38f87c7c81e93d5fe03d006aae77b | ||
languageName: node | ||
linkType: hard | ||
|
||
"@babel/preset-flow@npm:^7.0.0": | ||
version: 7.12.13 | ||
resolution: "@babel/preset-flow@npm:7.12.13" | ||
dependencies: | ||
"@babel/helper-plugin-utils": ^7.12.13 | ||
"@babel/plugin-transform-flow-strip-types": ^7.12.13 | ||
peerDependencies: | ||
"@babel/core": ^7.0.0-0 | ||
checksum: 47fe1001194a57fbdb33250adcb4c3aa9ff551cfb4eea1a16b123ff5fe78730a7ebfb839bacbe18390fc50fa4bf67fdd5293703b859876de45d52f50d4da0d44 | ||
languageName: node | ||
linkType: hard | ||
|
||
"root-workspace-0b6124@workspace:.": | ||
version: 0.0.0-use.local | ||
resolution: "root-workspace-0b6124@workspace:." | ||
dependencies: | ||
"@babel/preset-flow": ^7.0.0 | ||
languageName: unknown | ||
linkType: soft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
not too happy about this one 🙁 We should output ESM from Jest 28 or something
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.
I think adding
export { createTransformer }
to babel-jest would be enough.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.
yep that'd work, but "real" ESM should use a single
default
export of an object, so the issue is a "fake" esm module imported directly in native ESM. Edge casey enough that I don't think it's worth changing before just using native ESMThere 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.
Oh, and just to be explicit - the
.default
change is not because of this PR, but the change made in #11193