azure-database
azure-database copied to clipboard
getModelToken should be exported
getModelToken should be exported so that it's possible to provide stable test doubles.
Given service like this:
export class SomeService {
constructor(@InjectModel(SomeEntity) private readonly container: Container) {}
}
What we have to do now:
Test.createTestingModule({
providers: [
SomeService,
{ provide: `${SomeEntity}AzureCosmosDbModel`, useValue: jest.mocked({}) },
],
});
How it should be:
Test.createTestingModule({
providers: [
SomeService,
{ provide: getModelToken(SomeEntity), useValue: jest.mocked({}) },
],
});