我需要模拟一个提取调用,该调用返回带有Jest Fetch Mock的数组:
https://jsonplaceholder.typicode.com/todos/
it ('<Main />', () => {
const wrapper = render (<Main />);
fetch.mockResponseOnce (
JSON.stringify ([
{
id: '1',
title: 'hi',
},
])
);
wrapper.debug ();
});
但是我遇到错误:
(node:4667) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at undefined reason: Unexpected end of JSON input