Created
October 15, 2019 15:22
-
-
Save Kjaer/45c9a15ecf1e7a9cb19907105e4d21b8 to your computer and use it in GitHub Desktop.
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
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 = { | |
"testEnvironment": "node", | |
"roots": [ | |
"<rootDir>/components" | |
], | |
"preset": 'ts-jest', | |
"setupFilesAfterEnv": ["<rootDir>/tests/setupTests.ts"], | |
"transform": { | |
"^.+\\.tsx?$": "ts-jest" | |
}, | |
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx", | |
"js", | |
"jsx", | |
"json", | |
"node" | |
], | |
"testPathIgnorePatterns": ["<rootDir>/.next/", "<rootDir>/node_modules/"], | |
"snapshotSerializers": ["enzyme-to-json/serializer"], | |
// https://github.com/zeit/next.js/issues/8663#issue-490553899 | |
"globals": { | |
// we must specify a custom tsconfig for tests because we need the typescript transform | |
// to transform jsx into js rather than leaving it jsx such as the next build requires. you | |
// can see this setting in tsconfig.jest.json -> "jsx": "react" | |
"ts-jest": { | |
"tsConfig": "<rootDir>/tsconfig.jest.json" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment