Created
December 23, 2016 11:57
-
-
Save benbarber/7841d6de2d57bc124c7bbe773199a12f to your computer and use it in GitHub Desktop.
Config for using Jest in a TypeScript + Webpack project
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 = 'test-file-stub' |
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
{ | |
"jest": { | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx" | |
], | |
"moduleNameMapper": { | |
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": | |
"<rootDir>/fileMock.js", | |
"\\.(css|scss|less)$": "<rootDir>/styleMock.js" | |
}, | |
"transform": { | |
"^.+\\.(ts|tsx)$": "<rootDir>/transform.js" | |
} | |
} | |
} |
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 = {} |
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 tsc = require('typescript') | |
const tsConfig = require('tsconfig.json') | |
module.exports = { | |
process(src, path) { | |
if (path.endsWith('.ts') || path.endsWith('.tsx')) { | |
return tsc.transpile( | |
src, | |
tsConfig.compilerOptions, | |
path, | |
[] | |
) | |
} | |
return src | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment