MCPcopy
hub / github.com/jmcdo29/testing-nestjs

github.com/jmcdo29/testing-nestjs @1.1 sqlite

repository ↗ · DeepWiki ↗ · release 1.1 ↗
176 symbols 377 edges 88 files 1 documented · 1%
README

testing-nestjs

Quality Gate StatusActions Status Actions Status Actions Status Actions Status Actions Status Actions Status Actions StatusActions Status

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
  4. npm run test OR yarn 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.

MIT License, see the included License.md file.

Extension points exported contracts — how you extend this code

CatDTO (Interface)
(no doc)
apps/typeorm-sample/src/cat/cat.dto.ts
CatDTO (Interface)
(no doc)
apps/mongo-sample/src/cat/cat.dto.ts
RxJSRetryOptions (Interface)
(no doc)
apps/rxjs-sample/src/rxjs/interfaces/rxjs-options.interface.ts
Cat (Interface)
(no doc)
apps/mongo-sample/src/cat/interfaces/cat.interface.ts
CatDoc (Interface)
(no doc)
apps/mongo-sample/src/cat/interfaces/cat-document.interface.ts

Core symbols most depended-on inside this repo

create
called by 11
apps/typeorm-graphql-sample/src/cat/cat.resolvers.ts
transform
called by 9
apps/complex-sample/src/cat/cat.pipe.ts
getAll
called by 5
apps/complex-sample/src/cat/cat.service.ts
getById
called by 4
apps/complex-sample/src/cat/cat.service.ts
deleteCat
called by 4
apps/complex-sample/src/cat/cat.service.ts
getHello
called by 4
apps/simple-sample/src/app.service.ts
getHello
called by 4
apps/rxjs-sample/src/app.controller.ts
genericRetryStrategy
called by 4
apps/rxjs-sample/src/rxjs/rxjs.service.ts

Shape

Class 85
Method 74
Function 12
Interface 5

Languages

TypeScript100%

Modules by API surface

apps/typeorm-sample/src/cat/cat.service.ts9 symbols
apps/typeorm-sample/src/cat/cat.controller.ts9 symbols
apps/typeorm-graphql-sample/src/cat/cat.service.ts9 symbols
apps/mongo-sample/src/cat/cat.service.ts9 symbols
apps/mongo-sample/src/cat/cat.controller.ts9 symbols
apps/complex-sample/src/cat/cat.controller.ts7 symbols
apps/typeorm-graphql-sample/src/cat/cat.resolvers.ts6 symbols
apps/complex-sample/src/cat/cat.service.ts6 symbols
apps/typeorm-graphql-sample/src/graphql/protocol.schema.ts5 symbols
apps/simple-sample/src/app.controller.ts4 symbols
apps/rxjs-sample/src/rxjs/rxjs.service.ts4 symbols
apps/rxjs-sample/src/app.service.ts4 symbols

Dependencies from manifests, versioned

@commitlint/cli8.2.0 · 1×
@commitlint/config-conventional8.2.0 · 1×
@golevelup/nestjs-testing0.1.2 · 1×
@nestjs/cli6.12.6 · 1×
@nestjs/common6.10.3 · 1×
@nestjs/core6.10.3 · 1×
@nestjs/graphql6.5.3 · 1×
@nestjs/mongoose6.1.2 · 1×
@nestjs/platform-express6.10.3 · 1×
@nestjs/platform-socket.io6.10.3 · 1×
@nestjs/schematics6.7.4 · 1×
@nestjs/serve-static1.0.2 · 1×

Datastores touched

(mongodb)Database · 1 repos

For agents

$ claude mcp add testing-nestjs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact