Skip to content

testing custom hook within a component scope throws TypeError not a function #1144

Open
@AhmedSarhanSwvl

Description

@AhmedSarhanSwvl

when I run my unit tests to test componernts, I recieve errors similar to this one in multiple places:
TypeError: (0 , _fileName.useCustomHook) is not a function
when I test the hook itself alone it works fine, but I don't want to test the hook I want to test the component and the component have data that depends on my custom hook

Notes:

  • this was working last week with no errors and I didn't edit any code
  • I have looked at the packages nothing was updated since then
  • the codebase is Next.js so we can't update RTL to v13 yet as we have React v17 and the dep. tree won't fit together so we have
    @testing-library/react": "^12.1.2 and @testing-library/react-hooks: "^8.0.1",
  • I have updated RTL to 12.1.5 which is the latest version of v12 but same error
    can someone please help with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions