Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#1,144 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
javascript, next.js, react
Área
frontend, testing

Línea de trabajo

No se mencionan archivos ni pruebas fallidas. Empieza reproduciendo la prueba del componente con las versiones indicadas de React 17, Next.js, @testing-library/react 12.1.5 y @testing-library/react-hooks 8.0.1; después, sigue la importación del hook personalizado que usa el componente. El trabajo estará terminado cuando se identifique una causa reproducible y se documente la corrección compatible.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

question

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?
Lenguaje dominante
JavaScript
Estrellas
19.7k
Forks
1.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testing-library/react-testing-library

Todos los issues de testing-library/react-testing-library

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.