enzyme mount is not working for component code example
Example: enzyme mount is not working for component
it('should display message retrieved with ajax request',
async (done) => {
const fakePromise = Promise.resolve(mockResponse(
200,
null,
JSON.stringify({message: message})
));
window.fetch = jest.fn().mockImplementationOnce(() => {
return fakePromise
});
expect.assertions(2); //check if all assertions called
const info = mount(<Info infoUrl = {url} />);
await Promise.all([fakePromise]);
setImmediate(() => {
try {
expect(info).toHaveState('message', message);
expect(info).toIncludeText(message);
} catch (e) {
done.fail(e);
}
done();
});
});