We are using redux store in our project and fetch methods for getting data from backend. For testing we decided to create an additional method that creates fake server configuration to be able to correctly render components which uses that configuration. Here is this method:
export async function callGetMockConfiguration() {
try {
var data = {
method: "POST",
credentials: "same-origin",
headers: { "Content-Type": "application/json" }
};
const response = await fetch(getBaseUrl() + "auth/getmockconfiguration", data).then((x) => x.json());
return response;
} catch (e) {
throw e;
}
}
My test code fragment looks like this:
it("test", async () => {
await callGetMockConfiguration().then((response) => store.dispatch(configurationActionCreators.setConfiguration(response)));
const wrappe = mount(
<Provider store={store}>
<RecoilRoot>
<Component />
</RecoilRoot>
</Provider>
);
expect(wrapper).toMatchSnapshot();
});
So I want to create that fake configuration and set store by that. The problem is that I get this error:
and also this one at the same time:
Aucun commentaire:
Enregistrer un commentaire