React-hooks-testing-library: (0 , _reactTestRenderer.act) is not a function

Created on 9 May 2019  路  3Comments  路  Source: testing-library/react-hooks-testing-library

  • react-hooks-testing-library version: 0.5.0
  • react-testing-library version: 16.8.3
  • react version: 16.8.2
  • node version: 10.15.1
  • npm (or yarn) version: 1.13.0

Relevant code or config:

  it('allows to upload photos through the mutation', async () => {
    const { result, nextUpdate } = renderHook(() =>
      usePhotosUpload({
        photosUploadMutation,
      }),
    );

    act(() => {
      result.current.onPhotoUpload({
        files: [file],
        accountId: 'my-account',
      });
    });

    await nextUpdate();

    expect(photosUploadMutation).toHaveBeenCalled();
  });

What you did:

Run yarn test

What happened:

TypeError: (0 , _reactTestRenderer.act) is not a function

      13 | 
      14 |   it('allows to upload photos through the mutation', async () => {
    > 15 |     const { result, nextUpdate } = renderHook(() =>
         |                                    ^
      16 |       usePhotosUpload({
      17 |         photosUploadMutation,
      18 |       }),

      at renderHook (../../../node_modules/react-hooks-testing-library/lib/index.js:151:30)
      at Object._callee$ (__test__/hooks/usePhotosUpload.test.js:15:36)
      at tryCatch (../../../node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (../../../node_modules/regenerator-runtime/runtime.js:296:22)
      at Generator.prototype.(anonymous function) [as next] (../../../node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (__test__/hooks/usePhotosUpload.test.js:13:103)
      at _next (__test__/hooks/usePhotosUpload.test.js:15:194)
      at __test__/hooks/usePhotosUpload.test.js:15:364
      at Object.<anonymous> (__test__/hooks/usePhotosUpload.test.js:15:97)

Problem description:

Getting the error above whenever I try to use renderHook.

bug

Most helpful comment

Do you have react-test-renderer installed too? Requiring that was the breaking change for v0.5.0

All 3 comments

Reinstalled all packages and it worked. Sorry for the trouble.

馃 Seeing the same thing...

  • react-hooks-testing-library: ^0.5.0
  • react-testing-library: ^6.0.2
  • react: ^16.8.6,
  • node: v11.10.1
  • yarn: 1.16.0

Do you have react-test-renderer installed too? Requiring that was the breaking change for v0.5.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elenajdanova picture elenajdanova  路  7Comments

stramel picture stramel  路  3Comments

jrschumacher picture jrschumacher  路  7Comments

davidgtu picture davidgtu  路  6Comments

alexkrolick picture alexkrolick  路  5Comments