lundi 24 août 2020

React testing library/ screen shot testing

Test:

const { getByTestId, unmount } = render(<Router history={history}><SideNavigationBar/></Router>);

expect(await generateImage()).toMatchImageSnapshot();

SideNavigation.tsx

async componentDidMount(){
await //apicall;
setState();
}

I am making an api call inside the componentDidMount of the SideNavigationBar after which I do setState . Is there a way to await for the api call inside componentDidMount and render after that as my screenshot depends on the state update that I do inside componentDidMount.

Aucun commentaire:

Enregistrer un commentaire