bruderstein/react-render-hook

Create React App

Closed this issue · 1 comments

I'm trying to use with Jest in a create-react-app application but it doesn't work:

import RenderHook from 'react-render-hook';
import React from 'react';

it('identifies as attached', () => {
  expect(React).not.toBeFalsy();

  expect(RenderHook.isAttached).toBe(true);
});

Output:

 FAIL  src/RenderHook.test.js
  ✕ identifies as attached (9ms)

  ● identifies as attached

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: undefined

    Difference:

      Comparing two different types of values. Expected boolean but received undefined.

      5 |   expect(React).not.toBeFalsy();
      6 |
    > 7 |   expect(RenderHook.isAttached).toBe(true);
        |                                 ^
      8 | });
      9 |

      at Object.toBe (src/RenderHook.test.js:7:33)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total

Example repository: https://github.com/isi-gach/hook-jest-example

Do I need to do something more to attach the render hook?

Never mind it's solved when I also import react-dom now I'm trying to make it work with react-devtools standalone.