Jest

コンストラクタで非同期処理を実施しているクラスのテストをJestで書く

constructor()で非同期処理を実施しているクラスのテストを書きたかったときの備忘録 ↓みたいにconstructor()で非同期処理を実施していて、Promiseをreturnしていない export default class A { private readonly list: any; constructor() { new Repository…

TypeScriptでJestを使う

必要なパッケージのinstall *1 $ npm install --save-dev @babel/preset-typescript babel.config.js に追記 module.exports = { presets: [ ["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript" // 追加 ], }; テストの…