Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: migrate from Enzyme to RTL #88

Merged
merged 2 commits into from
Jun 15, 2022
Merged

deps: migrate from Enzyme to RTL #88

merged 2 commits into from
Jun 15, 2022

Commits on Jun 15, 2022

  1. deps: migrate from Enzyme to RTL

    - Enzyme only has unofficial support for React 17 and no support what-so-ever for React 18, so forced to migrate
    
    - RTL is most certainly more of an integration testing library than a unit test library
      - can't access the instance through RTL, even though this component actually _needs_ to use refs (bc canvas)
        - I managed to hack around this by using refs, but I honestly wasn't even sure that this was possible
          - notably hooks like `useRef` don't work since they can only be used inside of a React component or another hook
          - but callback refs and `createRef` do work fortunately
        - tried to use `react-dom-instance` initially, as suggested in blog post by the author, but it only works with React 16
          - in React 17 and React 18 it just returns `false` and doesn't get an instance
      - `querySelector` is an escape hatch that is not recommended, enough so that I read through the docs multiple times before finding it was even possible
        - was using `document.querySelector` directly before finding this
        - somewhat replaces Enzyme's `exists`
      - `rerender` is also a bit of an escape hatch
        - notably, you can't set props directly on a `ref`, `.props` is a read-only property, so had to find some alternative to be able to run the tests
        - replaces Enzyme's `setProps`
    
    - had to change `clearOnResize` to an optional type as it was required without this
      - despite that it's in `defaultProps`; the interface itself can't infer this, so probably makes sense to make it optional here as well
    agilgur5 committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    264ee36 View commit details
    Browse the repository at this point in the history
  2. fix lint issues

    agilgur5 committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    08b4f1b View commit details
    Browse the repository at this point in the history