babel-jest
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@babel/core | 7.24.5 | 763.27 kB | MIT | prod peer | 1 1 |
@jest/transform | 29.7.0 | 12.12 kB | MIT | prod | 1 1 |
@types/babel__core | 7.20.5 | 9.48 kB | MIT | prod | |
babel-plugin-istanbul | 6.1.1 | 7.65 kB | BSD-3-Clause | prod | 1 1 |
babel-preset-jest | 29.6.3 | 1.53 kB | MIT | prod | 1 1 |
chalk | 4.1.2 | 11.31 kB | MIT | prod | |
graceful-fs | 4.2.11 | 9.57 kB | ISC | prod | |
slash | 3.0.0 | 1.8 kB | MIT | prod |
Babel-jest is a Jest plugin that uses Babel to transform JavaScript code. It enables developers to write tests in latest JavaScript syntax by automatically compiling the code using Babel. Babel-Jest ensures your test code base is in sync with modern JavaScript standards and practices while benefiting from Jest's robust testing capabilities.
To use babel-jest, if you already have jest-cli
installed, all you need to do is add babel-jest
and it will automatically compile your JavaScript code using Babel. You can add the package to your project by running the following command in your terminal:
yarn add --dev babel-jest @babel/core
If you wish to write your own preprocessor, you would need to uninstall and delete babel-jest, and then set the config.transform
option to your preprocessor.
For instances where you are using babel-jest
with additional code preprocessors, an explicit setup is required. In such cases, you need to define babel-jest
as a transformer for your JavaScript code by mapping .js files to the babel-jest
module. This also applies to Typescript files. The definition is done in your configuration file like this:
"transform": {
"\\.[jt]sx?$": "babel-jest"
},
You can find the babel-jest documentation on the Jest official website at https://jestjs.io/docs/configuration. These docs provide a comprehensive guide on how to install, use, and configure babel-jest, among other useful information for developers. The link to the babel-jest GitHub repository is git+https://github.com/jestjs/jest.git, where you can also find insights on the module usage as well as code examples.