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

Fixing jest component test output errors #11139

Merged
merged 3 commits into from
May 20, 2021
Merged

Fixing jest component test output errors #11139

merged 3 commits into from
May 20, 2021

Conversation

ryanml
Copy link
Contributor

@ryanml ryanml commented May 20, 2021

There were quite a few non-fatal errors in our jest component tests related to missing required properties. Examples:

 console.error
      Warning: Failed prop type: The prop `customPriceIsExcessive` is marked as required in `GasModalPageContainer`, but its value is `undefined`.
          in GasModalPageContainer

      65 |   beforeEach(() => {
      66 |     wrapper = shallowWithContext(
    > 67 |       <GasModalPageContainer
         |       ^
      68 |         cancelAndClose={propsMethodSpies.cancelAndClose}
      69 |         onSubmit={propsMethodSpies.onSubmit}
      70 |         fetchBasicGasEstimates={propsMethodSpies.fetchBasicGasEstimates}
    console.error
      Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://fb.me/react-uselayouteffect-ssr for common fixes.
          in NetworkDisplay
          in div
          in div
          in ConfirmPageContainerHeader
          in Context.Provider

The following error was fixed for the MenuBar test:

    console.error
      Warning: An update to Menu inside a test was not wrapped in act(...).
      
      When testing, code that causes React state updates should be wrapped into act(...):
      
      act(() => {
        /* fire events that update state */
      });
      /* assert on the output */
      
      This ensures that you're testing the behavior the user would see in the browser. Learn more at https://fb.me/react-wrap-tests-with-act
          in Menu (created by AccountOptionsMenu)
          in AccountOptionsMenu (created by MenuBar)
          in div (created by MenuBar)
          in MenuBar
          in Provider
          in Router (created by MemoryRouter)
          in MemoryRouter (created by Wrapper)
          in Wrapper (created by WrapperComponent)
          in WrapperComponent

The tests for IntroPopup, an unused component which has been removed in this change, was causing:

    console.error
      Warning: Failed prop type: The prop `title` is marked as required in `PopoverPortal`, but its value is `null`.
          in PopoverPortal (created by IntroPopup)
          in IntroPopup
          in LegacyI18nProvider (created by WithoutStore)
          in I18nProvider (created by WithoutStore)
          in Router (created by MemoryRouter)
          in MemoryRouter (created by WithoutStore)
          in WithoutStore (created by Wrapper)
          in Provider (created by Wrapper)
          in Wrapper

      40 |   return (
      41 |     <div className="intro-popup">
    > 42 |       <Popover
         |       ^
      43 |         className="intro-popup__popover"
      44 |         title={t('swapIntroPopupTitle')}
      45 |         subtitle={t('swapIntroPopupSubTitle')}

@ryanml ryanml self-assigned this May 20, 2021
@ryanml ryanml requested a review from a team as a code owner May 20, 2021 00:11
@ryanml ryanml requested a review from danjm May 20, 2021 00:11
@ryanml ryanml changed the title Adding missing required props to component tests Fixing jest component test output errors May 20, 2021
@MetaMask MetaMask deleted a comment from metamaskbot May 20, 2021
@MetaMask MetaMask deleted a comment from metamaskbot May 20, 2021
@MetaMask MetaMask deleted a comment from metamaskbot May 20, 2021
@metamaskbot
Copy link
Collaborator

Builds ready [ccba2c9]
Page Load Metrics (634 ± 89 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint458462136
domContentLoaded380123363218489
load382123463418589
domInteractive380123263218488

@ryanml ryanml merged commit 6640973 into develop May 20, 2021
@ryanml ryanml deleted the fix-test-errors branch May 20, 2021 18:28
@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants