Skip to content

Unit Test

[Startup MVP recipes #11] Nest.js Run Unit Tests with Github Actions

If interested, please also check previous two articles on setting up the tests: https://jczhang.com/2022/08/08/startup-mvp-recipes-9-nest-js-typeorm-postgres-unit-testing-service-onlywith-jest-pg-mem/ https://jczhang.com/2022/08/09/startup-mvp-recipes-10-nest-js-unit-testing-mocking-service-and-the-universal-mock/ References https://medium.com/swlh/jest-and-github-actions-eaf3eaf2427d https://github.com/marketplace/actions/run-jest https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs Config On PR open, we will trigger this github action workflow on the cloud and let it run the checks remotely. Demo

[Startup MVP recipes #10] Nest.js Unit Testing: Mocking service and the universal mock

Intro and TL; DR In last article: https://jczhang.com/2022/08/08/startup-mvp-recipes-9-nest-js-typeorm-postgres-unit-testing-service-onlywith-jest-pg-mem/, we had a first glance at how to setup unit test with jest, and inject an in-memory postgres for testing the services. Now we move back to write unit tests for resolvers, and the idea and philosophy… Read More »[Startup MVP recipes #10] Nest.js Unit Testing: Mocking service and the universal mock

[Startup MVP recipes #9] Nest.js TypeORM Postgres Unit Testing (service only)with Jest, pg-mem

In this tutorial we will cover basic strategy of unit testing a service in Nest.js + TypeORM setup. We don’t create an environment for test purpose, but instead, we use pg-mem adapter to run a local in-memory Postgres simulator instance. In this way the db… Read More »[Startup MVP recipes #9] Nest.js TypeORM Postgres Unit Testing (service only)with Jest, pg-mem