問題タブ [spyon]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - Jest spyOn がコール チェーンの奥深くにあると呼び出されない
モジュールで関数を実行できると思ってspyOn
いましたが、明らかに呼び出されたとしても登録されません。ここに煮詰めたものがありsample.js
ます:
そして、ここにその冗談のテストがあり./__tests__/sample.test.js
ます:
テストは次のエラーで失敗します。
モック関数が呼び出されるはずでしたが、呼び出されませんでした。
func1
代わりにスパイすると正しく動作しますが、によって呼び出される関数を使用しないのはなぜfunc1
ですか?