Posts

Showing posts with the label supertest

Basic and effective NestJS Testing implementation guide

Image
Introduction Implementing testing in software development not only helps detect bugs early but also ensures system stability when performing upgrades or changing code. Testing helps programmers feel more confident, minimizes logic error risks, and creates a living document of how modules operate. In NestJS, we usually focus on three main concepts: Unit Test helps test each class or function independently End-to-End (e2e) Test tests the entire operation flow from request to response through a real server Test Coverage is an index measuring the percentage of source code that has been tested by test suites. Prerequisites In this article, I will continue to use the code from previous articles to implement tests; you can review those articles to get the source code to continue, or you can write similar tests based on the content according to your needs. Detail Update file package.json, focusing on the jest field { "jest" : { "moduleFileExtensions" : [ "j...