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 test away from using enzyme.mount (editor/components/url-input/test/button.js) #7786

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Jul 8, 2018

Description

This switched the should close the form when user submits it test in editor/components/url-input/test/button.js from using enzyme.mount to React.TestUtilities. 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).

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 switched the `should close the form when user submits it` from using enzyme.mount to React.TestUtilities.  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). This specific test was the only one to fail in #7557 due to the test involving the EnhancedAutocomplete component that has forwardRef applied on it.
@nerrad nerrad self-assigned this Jul 8, 2018
@nerrad nerrad added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Jul 8, 2018
@nerrad nerrad requested a review from gziolo July 8, 2018 16:30
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.

I left one comment, but I don't consider it as a blocker given that we want to introduce some abstractions in the future.

TestUtils.Simulate.submit( formElement() );
expect( wrapper.state.expanded ).toBe( false );
/* eslint-disable react/no-find-dom-node */
ReactDOM.unmountComponentAtNode( ReactDOM.findDOMNode( wrapper ).parentNode );
Copy link
Member

Choose a reason for hiding this comment

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

This should happen in afterEach section to make sure it is executed also when the test fails.

However, I'm planning on introducing some helpers to take care of it behind the scenes. We can get back to it later.

@gziolo gziolo merged commit 96809cb into master Jul 12, 2018
@gziolo gziolo deleted the update/replace-usage-of-enzyme.mount-with-React.TestUtils-button.js branch July 12, 2018 12:25
@gziolo gziolo added this to the 3.3 milestone Jul 12, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants