nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to mock Connection in unit testing

devvaneio opened this issue · comments

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I can't find a way to mock a Connection in unit testing. I did that with with repository though

Expected behavior

Mock Connection

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.x
 
For Tooling issues:
- Node version: 14
- Platform:  Ubuntu

Thanks. I had to use Connection to get around the lack of support for MongoDB transactions in Typeorm. I did mock repositories using getRepositoryToken. But I couldn't do the same with Connection. I'm gonna keep doing my research anyway. I'll go back here If I found something.

Please, use our Discord channel (support) for further questions. We are using GitHub to track bugs, feature requests, and potential improvements.