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

114
Vistas
Spy on a decorator using Sinon

I want to spy on a decorator using Sinon to ensure the string I am passing to it is correct

export class MyClass {
  @example('mystring')
  async myMeth() {
    console.log('do stuff')
  }
}

Originally I used reflection on the myMeth method of MyClass to see what the decorator was doing to the method but I realised this is testing the internals of the decorator and the decorator itself. The decorator already has tests.

I just want to ensure there are no typos in the 'mystring` I am passing.

Spying on functions with sinon is easy;

mySpy = Sinon.spy(MyClass, 'myMeth')

And decorators are in essence just functions that wrap functions, but I am totally clueless on how to achieve this.

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