Hylozoic / hylo-evo

Hylo UI
Apache License 2.0
36 stars 10 forks source link

fix cannot log after tests are done warning #1685

Closed KevinTriplett closed 3 months ago

KevinTriplett commented 3 months ago

We get this warning occasionally:


src/components/PostCard/PostCard.test.js

    Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "Warning: An update to FinishRegistration 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 FinishRegistration
        in Router (created by MemoryRouter)
        in MemoryRouter
        in Provider
        in LayoutFlagsProvider
        in Unknown".

      52 |
      53 |     setError(null)
    > 54 |     setFormValues(prevState => ({ ...prevState, [name]: value }))
         |       ^
      55 |   }
      56 |
      57 |   return (

      at console.error (node_modules/@jest/console/build/BufferedConsole.js:163:10)
      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:88:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:60:5)
      at warnIfNotCurrentlyActingUpdatesInDEV (node_modules/react-dom/cjs/react-dom.development.js:23284:7)
      at dispatchAction (node_modules/react-dom/cjs/react-dom.development.js:15656:9)
      at handleSubmit (src/routes/NonAuthLayoutRouter/Signup/FinishRegistration/FinishRegistration.js:54:7)

  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
        in FinishRegistration
        in Router (created by MemoryRouter)
        in MemoryRouter
        in Provider
        in LayoutFlagsProvider
        in Unknown".

      52 |
      53 |     setError(null)
    > 54 |     setFormValues(prevState => ({ ...prevState, [name]: value }))
         |       ^
      55 |   }
      56 |
      57 |   return (

      at console.error (node_modules/@jest/console/build/BufferedConsole.js:163:10)
      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:88:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:60:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23161:5)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21169:5)
      at dispatchAction (node_modules/react-dom/cjs/react-dom.development.js:15660:5)
      at handleSubmit (src/routes/NonAuthLayoutRouter/Signup/FinishRegistration/FinishRegistration.js:54:7)