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

Error when rendering Link during tests #185

Closed
zenhob opened this issue Mar 10, 2021 · 3 comments
Closed

Error when rendering Link during tests #185

zenhob opened this issue Mar 10, 2021 · 3 comments

Comments

@zenhob
Copy link
Contributor

zenhob commented Mar 10, 2021

What is the problem?

I am getting the same test errors described in this NextJS ticket: vercel/next.js#20048

When I use the Link component in tested code, I get errors that cause the test to fail. If I put prefetch={false) in the Link attributes, I still see the errors in the console but the test does not fail.

Paste all your error logs here:

PASS   CLIENT  app/cafes/components/GroupNavigation.test.tsx
  ● Console

    console.error
      Warning: An update to Link 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
://reactjs.org/link/wrap-tests-with-act
          at Link
          at div
          at div
          at div
          at GroupNavigation
          at wrapper

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnIfNotCurrentlyActingUpdatesInDEV (node_modules/react-dom/cjs/react-dom.development.js:25800:9
)
      at dispatchAction (node_modules/react-dom/cjs/react-dom.development.js:16798:9)
      at node_modules/next/client/use-intersection.tsx:47:3
      at node_modules/next/client/request-idle-callback.ts:27:9


Paste all relevant code snippets here:

$ jest

What are detailed steps to reproduce this?

  1. run a test that renders the Link component
  2. observe the errors

Run blitz -v and paste the output here:

You are using beta software - if you have any problems, please open an issue here:
      https://github.com/blitz-js/blitz/issues/new/choose

Linux 5.4 | linux-x64 | Node: v14.8.0

blitz: 0.32.1 (local)

  Package manager: npm
  System:
    OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 1.03 GB / 15.33 GB
    Shell: 5.0.16 - /bin/bash
  Binaries:
    Node: 14.8.0 - ~/.nvm/versions/node/v14.8.0/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.8.0/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: 2.13.1 => 2.13.1
    blitz: 0.32.1 => 0.32.1
    prisma: Not Found
    react: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    react-dom: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    typescript: 4.0.5 => 4.0.5



@zenhob zenhob changed the title Warning during tests Error when rendering Link during tests Mar 10, 2021
@flybayer
Copy link
Member

@zenhob did you try adding wrapping it in act as described in the error message?

@zenhob
Copy link
Contributor Author

zenhob commented Mar 15, 2021

@flybayer well I am not taking any actions, I am just rendering a component with a <Link>. I cannot wrap a render in act, I get an error.

@zenhob
Copy link
Contributor Author

zenhob commented Mar 15, 2021

This is caused by some sort of cross-test interaction, I can't reproduce when this is the only running test. Closing since I don't think this is a Blitz issue.

@zenhob zenhob closed this as completed Mar 15, 2021
@itsdillon itsdillon transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants