I currently have a typescript class setup like this:
export class SystemUnderTest {
@LogThisAction('something was done')
public doSomething() {}
}
It is clear that reflection is being used to execute a specific decoration function:
export declare function LogThisAction(action: string): (target: any) =>
void;
When running tests, I am not concerned with the actual implementation of the decorator function, so I attempt to mock it in this way:
myModule = require(./DecoratorFunctions);
myModule.LogThisAction = jest.fn();
However, this approach does not seem to be effective. Test results show:
● Test suite failed to run
TypeError: decorator is not a function
at DecorateProperty (node_modules/reflect-metadata/Reflect.js:553:33)
How can I accomplish my objective within the JEST framework?