Change babel-core to peerDependency for compatibility with Babel 7 #4162
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.
Summary
This makes
babel-jest
compatible with whichever version of Babel is used in a given project, sincebabel-core@6
is not necessarily compatible with plugins made for Babel 7.Note that this is a breaking change (albeit low impact).
Fixes #4055 (
babel-jest
is incompatible with plugins made for Babel 7).Test plan
In a project using
jest@20.0.4
and the following Babel packages:Install
babel-jest
using:I run tests using a
.jestrc.js
config file (however the extra config can be omitted for this example):The command fails with errors such as the following (indicating that JSX has not been transformed by Babel):
I published this fork of
babel-jest
as an npm package and installed it in the project as follows (public so that anyone can reproduce this):Then modified the jest
transform
configuration to use it (instead ofbabel-jest
which is default):.jestrc.js
Then run the tests again using
jest --config .jestrc.js
and see that all is well:Note that although this is technically a breaking change, in general users should already have
babel-core
installed with their project, so I would expect impact to be minimal.Also note that I've run the unit tests on my own (Windows) machine and they all pass, including at least some that fail in the CI runs. From what I can see, these tests seem to have been failing in CI already prior to this commit.