Last active
June 21, 2019 17:17
-
-
Save drwpow/e7a1fc373b4bc41ec3a461201d2e6e58 to your computer and use it in GitHub Desktop.
Jest + TypeScript
This file contains hidden or 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 = { | |
| moduleNameMapper: { | |
| '^components(.*)$': '<rootDir>/src/components/$1', | |
| '^data(.*)$': '<rootDir>/src/data/$1', | |
| '^hooks(.*)$': '<rootDir>/src/hooks/$1', | |
| '^lib(.*)$': '<rootDir>/src/lib/$1', | |
| '^pages(.*)$': '<rootDir>/src/pages/$1', | |
| '^types(.*)$': '<rootDir>/src/types/$1', | |
| '^utils(.*)$': '<rootDir>/src/utils/$1', | |
| }, | |
| preset: 'ts-jest', | |
| setupFilesAfterEnv: ['jest-dom/extend-expect', '@testing-library/react/cleanup-after-each'], | |
| testPathIgnorePatterns: ['/node_modules/', '/dist/'], | |
| }; |
This file contains hidden or 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
| { | |
| "compilerOptions": { | |
| "allowSyntheticDefaultImports": true, | |
| "allowUnreachableCode": false, | |
| "baseUrl": "src", | |
| "declaration": false, | |
| "esModuleInterop": true, | |
| "experimentalDecorators": true, | |
| "forceConsistentCasingInFileNames": true, | |
| "jsx": "react", | |
| "lib": ["dom", "es2017"], | |
| "module": "esnext", | |
| "moduleResolution": "node", | |
| "noImplicitAny": true, | |
| "noImplicitReturns": true, | |
| "noUnusedLocals": true, | |
| "noUnusedParameters": true, | |
| "outDir": "dist", | |
| "strict": true, | |
| "strictNullChecks": true, | |
| "target": "esnext", | |
| "types": ["node", "jest", "react"], | |
| "paths": { | |
| "*": ["node_modules/*", "*"] | |
| } | |
| }, | |
| "include": ["src"], | |
| "exclude": ["node_modules"] | |
| } |
Author
You shouldn’t need transform, testRegex, or moduleFileExtensions with the ts-jest setup. At least not with Jest 24 (it now supports TS 🎉).
What does console.log(pathsToModuleNameMapper(compilerOptions.paths)) return? Something similar to the above?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🤔