Alberto Cubeddu
Feb 12, 2024

Hi Joaquin,

I would need to see the codebase to give you a more exhaustive answer, nonetheless, i'll try to guide you.

As you're testing an ASYNC component, you're getting back a object:Promise. Why? Because the async call has not been completed and you're receiving a promise vs the result you're expecting.

To solve the situation, your test must wait for the response.

//Page

it('should render an async page', async () => {

render(await Page({params: {username: 'Joaquin Lobo' }}))

});

//Component

it('should rendere an async component', async () => {

await act(async() => {

render(await MyComponent());

});

});

If you have any call inside those components, i recommend you to mock them, therefore your test will run faster, and you stick with the unit-testing vs integration.

Alberto Cubeddu
Alberto Cubeddu

Written by Alberto Cubeddu

Leadership || Management || Innovation - Technology Director & Former Head Of Engineering

Responses (1)