• Stars
    star
    2,892
  • Rank 15,687 (Top 0.4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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!

Commitizen friendly Continuous Integration Testing Coffee

Nest Logo

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!

Project Structure

Each folder is a fully functional Nest application on its own. All you need to do after cloning the repository is move into the folder, install the dependencies, and test! Or you could just, you know, look at the test on GitHub too, no big deal.

Motivation

I've noticed a lot of people seem to get stuck on testing, and how to do it using the utilities given to us by Nest. Hopefully with a community driven repository of tests it will help others get a better understanding and feel for how to get tests running.

Please Note

This is not necessarily the Nest canonical way to test an application, nor is it the only way in any scenario. I will do my best to show different ways to run tests, but I will more than likely miss certain ways of running the tests, whether it is mocking in a specific way or otherwise. Again, this is a community maintained project and not a part of the official documentation. If you find other ways to test applications, great, I'd love to see them, but please do not think this is the only way.

Running the Project

  1. git clone https://github.com/jmcdo29/testing-nestjs.git
  2. cd testing-nestjs/<folderName>
  3. npm install OR yarn add OR pnpm install
  4. npm run test OR yarn test OR pnpm test

Contributing

Did I miss your favorite topic? Did I miss out on something you absolutely need tested? Well then open an issue, or better yet, a pull request! I'll be happy to look over any topics and try to help figure out how to test them or to merge any PRs that add to the value of the repository. If you do end up making a pull request, please add a screenshot of the test coverage so others can see how well the tests run. The complex-sample branch has a good example.

Change log

The change log can be found on the Releases page.

Authors and license

Jay McDoniel and contributors. Thanks to everyone who's helping with this effort!

MIT License, see the included License.md file.

More Repositories

1

nest-commander

A module for using NestJS to build up CLI applications
TypeScript
429
star
2

nestjs-spelunker

A NestJS Module for generating a NestJS Applications Module Dependency Graph.
TypeScript
306
star
3

ogma

A monorepo for the ogma logger and related packages
TypeScript
292
star
4

zeldaPlay

A Single Page Application to help zeldaPlay players to track their characters and progress
TypeScript
115
star
5

nest-lab

A repository to hold "experimental" packages for Nest. Honestly, I'm just tired of not having a good scope to put packages under ๐Ÿ˜ธ
TypeScript
85
star
6

nest-docker-template

Small template for using NestJS and Docker together
TypeScript
43
star
7

unteris

Unteris is a TTRP homebrew setting filled with cults, ancient magic, and deities. This is the source code for the website and server
TypeScript
40
star
8

nest-samples

A repository to hold a bunch of Nest samples, cause I'm tired of remaking them and losing them. Now it's just a sinlge repo to hold them all
TypeScript
39
star
9

nest-e2e-sample

An E2E testing sample using uvu and pactumJS to test a NestJS application
TypeScript
28
star
10

retryable-http-nestjs

A small module to show off failing httpService calls in Nest and what you can do to retry them
TypeScript
25
star
11

wtf-is-a-minimum-reproduction

A Description of what the hell a minimum reproduction really is
23
star
12

nest-cookies

A repository to hold the nest-cookies package. This will be a placeholder until I hear back from the nestjsplus/cookies owner
TypeScript
17
star
13

nestjs-oauth

An OAuth Module the mimics Passport's functionality without some of passport's wonkiness
TypeScript
17
star
14

dev.to

A repo for holding my dev.to posts, to allow me to keep them n source control and easily deploy them
TypeScript
16
star
15

fastify-jwt

A sample application to show Fastify plus JWT with Nest without Passport
TypeScript
14
star
16

ogma-depricated

A simple, no-nonsense logging package for NodeJS
TypeScript
10
star
17

nestjs-graphql-e2e-plugin

A repo to show how the NestJS GraphQL CLI Plugin can be used in E2E tests with Jest.
TypeScript
10
star
18

dynamic-module-test

Small repository that reproduces an issue in my main project for testability sake.
TypeScript
9
star
19

nest-content-negotiation

A small server to show off a content negotiation interceptor
TypeScript
7
star
20

nx-uvu

An nx executor for the uvu test library
TypeScript
6
star
21

nestjs-dynamic-render

A repository to show a way to dynamically render a template without using Nest's `@Render()` decoraotr
TypeScript
6
star
22

nestjs-optional-body

A small repo to show how it is possible to use optional bodies and have them validated by class-validator with NestJS
TypeScript
5
star
23

DnDCharacters

Just a repository to hold my plain text D&D Characters, so I can access them practically anywhere
Shell
3
star
24

context-fastify-middleware

A simple minimum reproduction to show that middleware run slightly differnetly inside of Nest for Fastify and Express
TypeScript
3
star
25

nestjs-chained-interceptor

A repo to show how interceptors can be chained together
TypeScript
3
star
26

dotfiles

Making a repo for dotfiles, managed by chezmoi
Vim Script
3
star
27

inject-swaaping-example

A small repository to show swapping out class values to be injected in different modules based on custom providers, useClass, and the inject decorator
TypeScript
3
star
28

nest-super-guard

A small repo to show how two strategies from passport can be used in the same NestJS guard file.
TypeScript
3
star
29

gazer

A simple image upload and viewing server. Nx monorepo with NestJS fastify backend, kysely database connection, and react front end all together
TypeScript
2
star
30

nestjs-timeout-sample

A samll NestJS application that shows how a timeout interceptor can work
TypeScript
2
star
31

NestJS-Playground

A playground repository for me to play around with a lot of different Nest code configurations.
TypeScript
2
star
32

bcrypt-nest-docker

A simple repo to show the use of the docker file from the template and bcrypt, a library that needs bindings from a higher level OS than alpine has
TypeScript
1
star
33

nest-router-fastify-example

Example repo for nest-router working with Fastify
TypeScript
1
star
34

rxjs-timeout-and-retry-demo

A simple repo to work with RxJS and acquiring input on a rolling timeout and resetting the input otherwise
JavaScript
1
star
35

orphansNodeAuth

A Node.js project to test out and use authentication strategies with Passport and Express.
JavaScript
1
star
36

dynamic-metadata-controller-hack

TypeScript
1
star
37

fastify-crf-issue

TypeScript
1
star
38

nest-gql-passport-request-scoped

Sample repo with GQL and Passport-JWT having a request scoped service in the strategy
TypeScript
1
star
39

nest-graphql-union

Small repo to show using GraphQL Unions
TypeScript
1
star
40

pactum-cookie-parsing

JavaScript
1
star
41

kafka-import-error

Minimum Reproduction for Kafka Error I'm facing
TypeScript
1
star
42

NodePug

A Node.js tutorial to understand how to attach Node.js code and .pug files
CSS
1
star
43

nestjs-with-cv-allow

Small reproduction to show Class Validator working with using the @Allow() decorator
TypeScript
1
star
44

nest-dynamic-module-middleware

Showing the configuration of a Dynamic NestJS Module with middleware running successfully.
TypeScript
1
star
45

JUID

A quick Node package to generate a version 4 variant 1 UUID.
JavaScript
1
star
46

mcScribe

Yet another logger for NodeJS
TypeScript
1
star
47

nest-gql-validation-status

A simple repo to show that the HTTP status is still a 200 with the ValidationPipe throwing an error in GraphQL
TypeScript
1
star
48

nestjs-passport-session

Broken repository trying to implement Google OAuth via NestJS and Passport with working sessions. Note: Sessions are broken currently
TypeScript
1
star
49

gql-local-user-deco

TypeScript
1
star
50

fastify-code-failure

Minimum reproduction repository to show `response.code` is not a funciton
TypeScript
1
star
51

nestjs-graphql-guard-middleware

I kinda hate that I wrote this. It's a repository to sho how to use a guard as a middleware so the guard doesn't run multiple times in terms of graphql with NestJS
TypeScript
1
star