Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getModelToken should be exported #830

Open
zaslavskyv opened this issue Jan 17, 2023 · 0 comments
Open

getModelToken should be exported #830

zaslavskyv opened this issue Jan 17, 2023 · 0 comments

Comments

@zaslavskyv
Copy link

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({}) },
  ],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant