Skip to content

A modified version of babel-jest, adding support for .babelrc files in sub-folders

License

Notifications You must be signed in to change notification settings

lehni/babel-jest-nested

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-jest-nested

Babel jest plugin

Usage

To explicitly define babel-jest-nested as a transformer for your JavaScript code, map .js files to the babel-jest-nested module.

transform: {
  '^.+\\.jsx?$': 'babel-jest-nested'
}

Note: If you are using babel version 7 you have to install babel-jest with

yarn add --dev babel-jest babel-core@^7.0.0-0 @babel/core

Example with Lerna:

  1. Specify the Lerna packages as Jest projects at the root level of your mono-repo in jest.config.js:

    module.exports = {
      projects: ['<rootDir>/packages/*']
    }
  2. Create a jest.base.config.js on the root level that each project / package will load, in which you use babel-jest-nested as the transformer:

    module.exports = {
      transform: {
        '^.+\\.jsx?$': 'babel-jest-nested'
      }
    }
  3. Then, within each Lerna package, simply provide a jest.config.js file that redirects to jest.base.config.js:

    module.exports = {
      ...require('../../jest.base.config.js')
    }
  4. Bingo!

About

A modified version of babel-jest, adding support for .babelrc files in sub-folders

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published