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.

The following example demonstrates using this feature to inject 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)
 }
}

Properties

Name Type Description
_instantiationArgs ConstructorParameters<Klass>
type Klass
create T
createMany T[]
Graycore, LLC © 2018 - 2024. Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.