React-testing-library fetches XML data and allows user to continue

17 Views Asked by At

trying to do testing for the Post API call wherein the response is xml data. And also trying to achieve the passing of the test case

below is the code to resolve

enter image description here

describe('CardDesignTestPage', () => {
    test('fetches XML data and allows user to continue', async () => {
        userEvent.setup();
        const promise = Promise.resolve(<xml>...</xml>);
        axios.post.mockImplementationOnce(() => promise);
        await waitFor(() => promise)
        render(
            <CardDesignTestPage />
        )
        userEvent.change(screen.getByRole('textbox'), { target: { value: <xml>...</xml> } })
    })
})
0

There are 0 best solutions below