Created
May 19, 2021 16:06
-
-
Save juliantrueflynn/63c0550750bbea38119eac118ee4db82 to your computer and use it in GitHub Desktop.
jest preset example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const babelJest = require('babel-jest'); | |
module.exports = babelJest.createTransformer({ | |
presets: [require.resolve('babel-preset-react-app')], | |
babelrc: false, | |
configFile: false, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
process() { | |
return 'module.exports = {};'; | |
}, | |
getCacheKey() { | |
// The output is always the same. | |
return 'cssTransform'; | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default () => { | |
return { | |
roots: ['<rootDir>/src'], | |
moduleDirectories: ['node_modules'], | |
setupFiles: [require.resolve('react-app-polyfill/jsdom')], | |
testEnvironment: 'jest-environment-jsdom-sixteen', | |
testMatch: [ | |
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', | |
'<rootDir>/src/**/*.test.{js,jsx,ts,tsx}', | |
], | |
transform: { | |
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': require.resolve('./babelTransform'), | |
'^.+\\.css$': require.resolve('./cssTransform'), | |
}, | |
transformIgnorePatterns: [ | |
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$', | |
'^.+\\.module\\.(css|sass|scss)$', | |
], | |
moduleNameMapper: { | |
'^src/(.*)$': '<rootDir>/src/$1', | |
}, | |
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'], | |
collectCoverageFrom: [ | |
'src/**/*.{js,jsx,ts,tsx}', | |
'!src/**/*.d.ts', | |
'!src/index.ts', | |
'!src/Plugin.tsx', | |
'!src/setupTests.ts', | |
'!src/types/**/*.ts', | |
], | |
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], | |
resetMocks: true, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment