Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
How to mock the entire AbortController class using jest

I'm using Jest and AbortController at the same time. AbortController has a signal property which returns an AbortSignal, which itself has a reason property. However, the reason property isn't supported in node yet, thus all of my test are failing due to this.

I've tried

jest.spyOn(AbortController.prototype, 'AbortController').mockImplementation(...)

to mock the constructor but I still got the following error :

"Argument of type '"AbortController"' is not assignable to parameter of type '"abort"'."

I cannot use jest.mock() because AbortController isn't imported.

I don't really know what to do from now on, has anyone ever tried this ?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I solved this problem by adding these lines to my jest configuration, inside the package.json :

"jest": {
        [...yourConfig],
        "globals": {
            "ts-jest": {
                "isolatedModules": true
            }
        },
}

The tests weren't compiling because of a typing problem. Jest was using @types/node. This solved the problem.

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda