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

329
Vistas
Catch call to new AbortController()

I have this piece of code:

if (this.isRequestPending) {
  this.conversationsAbortController.abort()
  this.conversationsAbortController = new AbortController()
}

I'm already able to catch the call to .abort() using jest.spyOn(AbortController.prototype, 'abort') but I'd like to also catch the new AbortController().

I've tried:

  • jest.spyOn(AbortController.prototype, 'new')
  • jest.spyOn(AbortController.prototype, 'constructor')
  • jest.spyOn(AbortController.prototype, 'AbortController')

But it doesn't seem to work.

I did look at the global.d.ts file for this:

interface AbortController {
  /**
   * Returns the AbortSignal object associated with this object.
   */

  readonly signal: AbortSignal;
  /**
   * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
   */
  abort(): void;
}

/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
interface AbortSignal {
  /**
   * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
   */
  readonly aborted: boolean;
}

declare var AbortController: {
  prototype: AbortController;
  new(): AbortController;
};

declare var AbortSignal: {
  prototype: AbortSignal;
  new(): AbortSignal;
  // TODO: Add abort() static
};

But I'm not sure what to make of it.

about 4 years ago · Juan Pablo Isaza
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