Skip to content

React is needed during testing #4080

@dgrcode

Description

@dgrcode

Describe the bug

I'm trying to reproduce an issue in a different library (for reference issue: flightcontrolhq/superjson#196, PR: flightcontrolhq/superjson#197). For that I'm using QueryClient and dehydrate, but I'm getting the following error:

Cannot find module 'react' from 'node_modules/@tanstack/react-query/build/cjs/react-query/src/useQueries.js'

    Require stack:
      node_modules/@tanstack/react-query/build/cjs/react-query/src/useQueries.js
      node_modules/@tanstack/react-query/build/cjs/react-query/src/index.js
      src/index.test.ts

This is the whole test:

  const queryClient = new QueryClient();
  const input = { props: { dehydratedState: dehydrate(queryClient) } };

  const stringified = SuperJSON.stringify(input);
  const parsed: any = SuperJSON.parse(stringified);

  expect(parsed).toEqual(input);

Your minimal, reproducible example

https://codesandbox.io/s/tanstack-query-react-dependency-bnkx3l?file=/src/index.test.js

Steps to reproduce

  1. Go to the reproduction codesandbox
  2. Go to the tests tab
  3. The test doesn't pass

Expected behavior

I think the test should pass, since it's not using any hook, just the QueryClient and dehydrate.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • Browser: Brave
  • Version: 1.39.11

react-query version

4.2.1

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions