1.6.5 • Published 5 months ago

@ggascoigne/jest-config v1.6.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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

1.6.5

5 months ago

1.6.4

6 months ago

1.6.3

7 months ago

1.6.2

8 months ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago