nest icon indicating copy to clipboard operation
nest copied to clipboard

Add unit tests for sample 06-mongoose

Open martinvysnovsky opened this issue 1 year ago • 2 comments
trafficstars

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [x] Other... Improvements in samples

What is the current behavior?

Sample 06-mongoose is missing some unit tests.

Issue Number: N/A

What is the new behavior?

More unit tests in sample 06-mongoose.

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

martinvysnovsky avatar Aug 14 '24 11:08 martinvysnovsky

Pull Request Test Coverage Report for Build 2d502500-1db4-4ec5-b760-8610b6ab6adf

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.213%

Totals Coverage Status
Change from base Build 71551605-c356-4a76-8f46-8de2acf07906: 0.0%
Covered Lines: 6750
Relevant Lines: 7320

💛 - Coveralls

coveralls avatar Aug 14 '24 11:08 coveralls

I would like to include E2E tests too, but I need to use a database for that. Usually, I am using testcontainers in my E2E tests. Do you agree to use additional dependency (testcontainers) here?

(also for unit tests of services I do not like to mock the model. Usually, in a real codebase, you have to improve these mocks every time you change the service. I think, using a real database and actually run the queries give you more confidence in your tests. Previously I did use inmemory mongo db, now I am using testcontainers here too. The result is that these tests are not pure unit tests anymore but rather integration tests. Still, I think it makes more sense for services. So again. If you agree then I can rewrite this example to use testcontainers)

martinvysnovsky avatar Aug 14 '24 11:08 martinvysnovsky