我正在测试我的反应组件,我想模拟几个get
运营。我想做的是这样的:
test(`Created correctly`, async () => {
fetchMock.get(`*`, JSON.stringify(FIRSTGETOBJ));
fetchMock.get(`*`, JSON.stringify(SECONDGETOBJ));
fetchMock.get(`*`, JSON.stringify(THIRDGETOBJ));
//...
}
每个的网址get
是一样的,但是有效负载改变了。但是,使用上面的代码我会得到:
Error: Adding route with same name as existing route. See `overwriteRoutes` option.
我怎样才能做到这一点?
Use overwriteRoutes
option
test(`Created correctly`, async () => {
fetchMock.get(`*`, JSON.stringify(FIRSTGETOBJ));
fetchMock.get(`*`, JSON.stringify(SECONDGETOBJ), { overwriteRoutes: false });
fetchMock.get(`*`, JSON.stringify(THIRDGETOBJ), { overwriteRoutes: false });
//...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)