Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!