@straw-hat/jest-config-chain
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@straw-hat/jest-config-chain

Usage

  • Reference guides Please use yarn docs:reference to generate the reference docs.

You can start creating a Jest configuration. For this guide, our example base configuration will be jest.config.js in the root of our project directory.

// jest.config.js
const { JestConfigChain } = require('@straw-hat/jest-config-chain');

const config = new JestConfigChain();

config.setupFilesAfterEnv
  .add('app', '<rootDir>/jest.setup.js')
  .end()
  .testMatch.add('<rootDir>/tests/jest/**/*.test.(js|jsx|ts|tsx)')
  .end()
  .moduleNameMapper.set('^@/(.*)$', '<rootDir>/src/$1', { alias: 'appRoot' })
  .set('^image![a-zA-Z0-9$_-]+$', 'GlobalImageStub', { alias: 'images' })
  .end()
  .transform.set('^.+\\.(ts|tsx)$', '<rootDir>/node_modules/babel-jest', { alias: 'babel' })
  .end();

// config.toConfig() returns the raw object
module.exports = config.toConfig();

Package Sidebar

Install

npm i @straw-hat/jest-config-chain

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

48.3 kB

Total Files

6

Last publish

Collaborators

  • ubi