@ggascoigne/jest-config

1.6.5 • Public • Published

Jest Config

My personal shareable jest configuration.

Install

pnpm add -D jest @ggascoigne/jest-config

Usage

jest.config.js

module.exports = {
  preset: '@ggascoigne/jest-config',
};

Extending

An example with testMatch that Jest uses to detect test files.

jest.config.js

module.exports = {
  preset: '@ggascoigne/jest-config',
  testMatch: [
    '<rootDir>/__tests__/**/**.+(ts|tsx|js|jsx)',
    '<rootDir>/src/**/?(*.)+(spec|test).+(ts|tsx|js|jsx)',
  ],
};

Add an NPM Script

Running this command:

npm set-script test "jest"

Will create:

package.json

"scripts": {
  "test": "jest"
},

Add a Pre-commit Hook

Note: Executes tests and coverage output related to files that have been changed in the current commit only.

lint-staged.config.js

module.exports = {
  '*.{js,jsx,ts,tsx}': [
    'pnpm test --bail --passWithNoTests --findRelatedTests --coverage',
  ],
};

Under The Hood

jest-preset.js

  • @types/jest
  • ts-jest
  • jest-environment-jsdom
  • jest-transform-stub

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @ggascoigne/jest-config

Weekly Downloads

0

Version

1.6.5

License

MIT

Unpacked Size

4.38 kB

Total Files

5

Last publish

Collaborators

  • ggascoigne