jmcdo29 / testing-nestjs

A repository to show off to the community methods of testing NestJS including Unit Tests, Integration Tests, E2E Tests, pipes, filters, interceptors, GraphQL, Mongo, TypeORM, and more!
MIT License
2.92k stars 379 forks source link

[e2e tests for mongo-sample] #1037

Open Mnigos opened 3 years ago

Mnigos commented 3 years ago

Just a e2e tests using mongo A clear and concise description of what feature you want to be shown tests for (e.g. Authentication): I tried to create e2e tests by when i started it it's connected to db and adding this data from tests to my db. Should i use mockingoose?

jmcdo29 commented 3 years ago

An e2e test usually should be using a database, that way you are testing the entire flow, from the request coming in, to the data being saved, to the data being retrieved. Usually it's also preferable to use a different database for testing that your dev or production database to ensure you don't have any collisions or pollution of your database. I can try to add an e2e sample for mongo though

omermorad commented 3 years ago

Hey guys :)

@jmcdo29 well done with the repo! Actually, when I looked at the tests I was looking exactly for what you have described here.

Thought about adding this e2e test, from the controller to an in-memory DB, what do you think?

jmcdo29 commented 3 years ago

@omermorad thanks for looking to continue! You can either use an in memory database, or you can add the mongo image to the docker-compose. Either way I look forward to the contribution

omermorad commented 3 years ago

Great, I will work on something and send you a PR

omermorad commented 3 years ago

Should I modify this test? Or work on a new one?

https://github.com/jmcdo29/testing-nestjs/blob/dff1168a019bd30458b1d8bae58bf8985a267095/apps/mongo-sample/test/app.e2e-spec.ts

jmcdo29 commented 3 years ago

Add a new cats.e2e-spec.ts. I'm pretty sure that's what the TypeORM sample does