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

Switch away from using enzyme for tests (components/higher-order/with-focus-return/test/index.js) #7815

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Jul 9, 2018

Description

This switches all tests in components/higher-order/with-focus-return/test/index.js from using enzyme.shallow and enzyme.mount to React.TestRenderer. This is because enzyme does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such as forwardRef usage in #7557).

I had to switch away from using shallow in this case because HOC’s are wrapped in forwardRef and assertions thus could not be properly made on the shallowly rendered HOC.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

This switches all tests in `components/higher-order/with-focus-return/test/index.js` from using enzyme.shallow  and enzyme.mount to `React.TestRenderer`.  This is because `enzyme` does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such as `forwardRef` usage in #7557).

I had to switch away from using shallow in this case because HOC’s are wrapped in forwardRef and assertions thus could not be properly made on the shallowly rendered HOC.
@nerrad nerrad self-assigned this Jul 9, 2018
@nerrad nerrad added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Refactoring labels Jul 9, 2018
this makes the test more resilient so it works with the forwardRef work as well.
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for working on it 🚢

@nerrad nerrad merged commit d11bbf8 into master Jul 9, 2018
@gziolo gziolo added this to the 3.3 milestone Jul 10, 2018
@ellatrix ellatrix added [Type] Code Quality Issues or PRs that relate to code quality and removed [Type] Code Quality Issues or PRs that relate to code quality labels Nov 27, 2018
@aduth aduth deleted the update/with-focus-return.js-replace-enzyme-with-React.TestRenderer branch January 25, 2019 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants