generated at
Jestの導入



いろいろ入れる
$ npm install --save-dev typescript jest ts-jest @types/jest

package.jsonに追記
jest.config.jsに書いても良いが面倒なのでいったんpackage.jsonに書いている
package.json
{ "jest": { "moduleFileExtensions": [ "ts", "js" ], "transform": { "^.+\\.ts$": "ts-jest" }, "globals": { "ts-jest": { "tsConfig": "tsconfig.json" } }, "testMatch": [ "**/test/**/*.test.ts" ], "moduleNameMapper": { "^app/(.+)": "<rootDir>/src/$1" } } }
一つ一つの指定の意味をあまり理解していない #??
$ npm test で実行するために下記も追記
package.json
{ "scripts": { "test": "jest" }, }

tsconfig.jsonの指定はこんな感じ
tsconfig.json
{ "compilerOptions": { "baseUrl": "src", "paths": { "app/*": ["./*"], }, }, }


参考
ほぼほぼここを参考にしている
ただし、pathの指定だけは参考にしていない