We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
So I'm using Jest and we are strictly doing unit tests -
I used the example
jest.mock('typeorm-transactional-cls-hooked', () => ({ Transactional: () => () => ({}), BaseRepository: class {}, }));
But it errors on initializeTransactionalContext(). Where would initializeTransactionalContext be used within a jest unit test ?
The text was updated successfully, but these errors were encountered:
When I added this it gives this message.
"ConnectionNotFoundError: Connection "default" was not found."
So is seems the mock is not handling mocking out the connection. ?
Sorry, something went wrong.
Same problem here.
I can't figure out how to mock this @transactional decorator.
Here is the used code.
let myService: MyService; let myRepository: MyRepository; beforeEach(async () => { jest.mock('typeorm-transactional-cls-hooked', () => ({ Transactional: () => () => ({}), BaseRepository: class {}, })); initializeTransactionalContext(); const module: TestingModule = await Test.createTestingModule({ providers: [ MyService, MyRepository, { provide: getRepositoryToken(MyRepository), useClass: MyRepositoryFake } ], }).compile(); myService = module.get(MyService); myRepository = module.get(MyRepository); });
Am I doing something wrong ?
I was able to mock it using
jest.mock('typeorm-transactional-cls-hooked', () => ({ Transactional: () => jest.fn(), }));
No branches or pull requests
So I'm using Jest and we are strictly doing unit tests -
I used the example
But it errors on initializeTransactionalContext(). Where would initializeTransactionalContext be used within a jest unit test ?
The text was updated successfully, but these errors were encountered: