@ggascoigne/jest-config
v1.7.0
Published
A shareable jest configuration for projects.
Downloads
92
Readme
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