-
I would love to write some reusable extension methods for the MockBuilder. But as MockBuilder is a function and not a class, I'm struggling a bit how to achieve this.
.ts:
test.spec.ts:
The type is recognized correctly but it will not run, as 'MockBuilder.prototype' cant work on a function. Can you tell me if can extend it on another way externally? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Ok, now I got it. The function MockBuilder returns a MockBuilderPerformance which extends MockBuilderPromise which implements IMockBuilder. But as IMockBuilder is an interface, I have to extend the prototype of MockBuilderPerformance or MockBuilderPromise. Both of them are not exported, so its not possible for me. Do you know another way or do you think its impossible to do this with external code? I think the only way would be a a CustomMockBuilder that creates a MockBuilder instance, extends the variable and returns it. |
Beta Was this translation helpful? Give feedback.
He solution is described here: https://ng-mocks.sudo.eu/api/MockBuilder#extending-mockbuilder