Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created June 25, 2021 08:23
Show Gist options
  • Save sabesansathananthan/cfdb05217b28e74daf1df4f2b53e446b to your computer and use it in GitHub Desktop.
Save sabesansathananthan/cfdb05217b28e74daf1df4f2b53e446b to your computer and use it in GitHub Desktop.
Enforce JavaScript Code Quality While Commit
module.exports = {
roots: ['<rootDir>/src'], // Find files in the src/root directory
collectCoverage: true, // Statistical coverage
coverageDirectory: 'coverage', // The folder where coverage results are output
coverageThreshold: {
// Total coverage requirements for all documents
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
// Coverage requirement of the matched single file
// Wildcard configuration is also supported here
'./src/**/*.{ts,tsx}': {
branches: 60,
functions: 60,
lines: 60,
statements: 60,
},
},
// File matching unit test case
testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'],
// Is the current environment jsdom or node
testEnvironment: 'jsdom',
// Set alias, if not set, the @ symbol will not be recognized when running single test
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment