DaffModelFactory
The base class for model factories.
The mock class is passed as the first constructor arg and any additional args are passed to the mock class constructor.
The constructor args can be omitted if the create
method is overridden.
Properties
Name | Type | Description |
---|---|---|
_instantiationArgs | ConstructorParameters<Klass> | |
type | Klass | |
create | T | |
createMany | T[] |
Examples
Injecting a different factory into a mock class
class MyMockModel {
constructor(
private otherFactory: MyOtherFactory
) {}
private createOtherModel() {
return this.otherFactory.create()
}
otherModel = this.createOtherModel()
}
@Injectable()
class TestFactory extends DaffModelFactory<MyMockModel> {
constructor(
otherFactory: MyOtherFactory
) {
super(MyMockModel, otherFactory)
}
}