Skip to content

Instantly share code, notes, and snippets.

@atomer
Created June 17, 2021 16:12
Show Gist options
  • Save atomer/c90d991dc6e96b94ce4d3429d46466bd to your computer and use it in GitHub Desktop.
Save atomer/c90d991dc6e96b94ce4d3429d46466bd to your computer and use it in GitHub Desktop.
非公開関数のモックを作りたい
TS + Jestの環境で非公開関数のモックを作りたい
試したこと
rewire
https://golang.hateblo.jp/entry/2021/03/12/214524
ここを参考に設定するといい感じのところまでいった
jest configで指定しているimportのmapperが効かない
https://qiita.com/mangano-ito/items/75e65071c9c482ddc335
ts-config-pathsで解決した
rewireした非公開関数を通らない
rewireした非公開関数を通るにはrewireした公開関数を経由する必要がある
rewireした先で呼ばれる関数をjest.mockした関数を通らない
未解決
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment