npm.io
0.4.5 • Published 4 years ago

jest-simple-config

Licence
ISC
Version
0.4.5
Deps
0
Size
11 kB
Vulns
0
Weekly
0

jest-simple-config

Generates a Jest config with simple defaults and extendable options.

Build Status Coverage Status npm

Installation

Install as a dev dependency:

npm i -D jest-simple-config

Basic Usage

Create a new file jest.config.js at the root of your project:

// jest.config.js
const { makeJestConfig } = require('jest-simple-config');
module.exports = makeJestConfig();

That's it!

This will give you a basic Jest config, equivalent to the following:

const config = {
  clearMocks: true,
  collectCoverage: true,
  collectCoverageFrom: ['./src/**.js', '!**/__tests__/**', '!/node_modules'],
  coverageDirectory: 'coverage',
  coverageReporters: ['json', 'text', 'html'],
  moduleNameMapper: {
    '\\.(css|less|scss)

collectCoverage is true by default. If you don't want a coverage report, setting that option to false will remove the other coverage fields:

const config = makeJestConfig({ collectCoverage: false });

will give you the following config:

{
  clearMocks: true,
  moduleNameMapper: {
    '\\.(css|less|scss)
: 'identity-obj-proxy',
  },
  testMatch: ['**/__tests__/*.(test|spec|jest).js'],
  testPathIgnorePatterns: ['__tests__/(setup|testUtils).js'],
  verbose: true,
};

__INLINE_CODE_1__ is true by default. If you don't want a coverage report, setting that option to false will remove the other coverage fields:

__CODE_BLOCK_3__

will give you the following config:

__CODE_BLOCK_4__
: 'identity-obj-proxy', }, testMatch: ['**/__tests__/*.(test|spec|jest).js'], testPathIgnorePatterns: ['__tests__/(setup|testUtils).js'], verbose: true, };
: 'identity-obj-proxy', }, testMatch: ['**/__tests__/*.(test|spec|jest).js'], testPathIgnorePatterns: ['__tests__/(setup|testUtils).js'], verbose: true, };

__INLINE_CODE_1__ is true by default. If you don't want a coverage report, setting that option to false will remove the other coverage fields:

__CODE_BLOCK_3__

will give you the following config:

__CODE_BLOCK_4__

Keywords