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

Testing Services And Database e2e #984

Closed
alex-osman opened this issue Aug 20, 2018 · 5 comments
Closed

Testing Services And Database e2e #984

alex-osman opened this issue Aug 20, 2018 · 5 comments

Comments

@alex-osman
Copy link

alex-osman commented Aug 20, 2018

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

In regards to e2e testing, one can mock Repositories when not interfacing with a database, but it is unclear how to use actual Repositories on a database within the e2e tests.

There is no documentation regarding testing services. This is not intuitive with all the DI specifics with testing.

Expected behavior

I would like to see examples in the documentation about how to pass Repos into e2e tests and how to test services.

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

Be able to test services and increase coverage and confidence in code.

@BrunnerLivio
Copy link
Member

There is documentation how to test controllers. Services can be handled the same way. Still not enough? Check out the cat app sample
https://github.com/nestjs/nest/tree/master/sample/01-cats-app

@alex-osman alex-osman changed the title Testing Services Testing Services And Database e2e Aug 21, 2018
@BrunnerLivio
Copy link
Member

BrunnerLivio commented Aug 21, 2018

I saw you've changed the issue.
There is already an issue for that #409

I created an example for that: https://github.com/BrunnerLivio/nestjs-unit-test-db-example but it is written in Nest 4.x.x

@lucasmonstrox
Copy link

News?

@vpaul08
Copy link

vpaul08 commented Jul 8, 2019

Even, I'm struggling to find a way to test the services and increase the code coverage. The method defined in the sample app creates a mock for the service and the actual service never gets executed, hence reducing the coverage.

@lock
Copy link

lock bot commented Oct 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants