Skip to content

Instantly share code, notes, and snippets.

@shun-shobon
Last active May 17, 2020 02:58
Show Gist options
  • Save shun-shobon/3f3a8ded6665fd2be37fcc09437a15e9 to your computer and use it in GitHub Desktop.
Save shun-shobon/3f3a8ded6665fd2be37fcc09437a15e9 to your computer and use it in GitHub Desktop.
TypeScript + Jest環境構築例
yarn add -D \
typescript \
jest \
ts-jest \
@types/jest
module.exports = {
moduleFileExtensions: ["js", "ts"],
moduleNameMapper: {
"^~/(.*)$": "<rootDir>/src/$1",
},
transform: {
"^.+\\.ts$": "ts-jest",
},
globals: {
"ts-jest": { tsConfig: "<rootDir>/tsconfig.json" },
},
testMatch: ["<rootDir>/tests/**/*.spec.{js,ts}"],
collectCoverage: true,
collectCoverageFrom: ["<rootDir>/src/**/*.{js,ts}"]
}
{
"scripts": {
"test": "jest"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"jest": "^25.4.0",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3"
}
}
{
"compilerOptions": {
"baseUrl": "./src",
"paths": { "~/*": ["*"] },
"types": ["@types/jest"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment