jjzjj

mockFetchJsonResponse

全部标签

javascript - 用于使用 Jest 进行测试的共享实用程序函数

我在各种Jest测试中使用了一些实用程序函数,例如这样的函数,用于模拟获取响应:exportconstmockFetchJsonResponse=(data)=>{ok:()=>true,json:()=>data};我想以一种可以导入它们并在我的测试中重用的方式共享这些函数。例如://Some.spec.jsxfile//...import{mockFetchJsonResponse}from'some/path/to/shared/tests/utils.jsx'//ThenIcanusemockFetchJsonResponseinsidethistest//...我应该在哪里放