I have a typescript class:
export class SystemUnderTest {
@LogThisAction('sth was done')
public doSomething() {}
}
As you can see it uses a reflection to execute some decoration function:
export declare function LogThisAction(action: string): (target: any) =>
void;
When I run test in I do not care about the actual impl. of this decorator function, so I try to mock it like this:
myModule = require(./DecoratorFunctions);
myModule.LogThisAction = jest.fn();
But that does not seem to work. When I run tests I get:
ā Test suite failed to run
TypeError: decorator is not a function
at DecorateProperty (node_modules/reflect-metadata/Reflect.js:553:33)
How to achieve my goal in JEST framework ?