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.