mercredi 11 décembre 2019

An update to Component inside a test was not wrapped in act()

This error shows up even though I've wrapped anything that could possibly cause an update in act(). It still complains. I just tend to ignore it but still, I would like to know what am I doing wrong.

    beforeEach(async () => {
    await act(async () => {
      wrapper = mountWithIntl(
        <StoreContext.Provider>
          <MockedProvider mocks={mocks} addTypename>
            <InlineExposuresContainerWithStore {...props} />
          </MockedProvider>
        </StoreContext.Provider>
      )
    })

    await wait(0)
  })

  test('a call is made to mockedResult', async () => {
    await waitForExpect(() => {
      expect(mockedResult).toHaveBeenCalled()
    })
  })

  test('the right props are passed to <InlineExposures />', async () => {
    await act(async () => {
      wrapper.update()
    })

    // deep comparison
    expect(wrapper.find(InlineExposures).props().exposures).toEqual(InlineExposuresExpectedProps)
  })

Aucun commentaire:

Enregistrer un commentaire