()
| 154 | |
| 155 | // Mark a method to be used only in tests |
| 156 | export function testOnlyMethod() { |
| 157 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 158 | return function (_target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) { |
| 159 | const originalMethod = descriptor.value; |
| 160 | // eslint-disable-next-line , @typescript-eslint/no-explicit-any |
| 161 | descriptor.value = function (...args: any[]) { |
| 162 | if (!isTestExecution()) { |
| 163 | throw new Error(`Function: ${propertyKey} can only be called from test code`); |
| 164 | } |
| 165 | return originalMethod.apply(this, args); |
| 166 | }; |
| 167 | |
| 168 | return descriptor; |
| 169 | }; |
| 170 | } |
| 171 | |
| 172 | // Mark a method that returns a promise to chain it |
| 173 | export function chainable() { |
no test coverage detected