Skip to content

vehikl/nestjs-testing

 
 

Repository files navigation

NestJs Testing

CI

What be this? What be this? There be bits errywhere!

This application is to be used as an exemplary setup for NestJs using modern best practices such as TDD, CI/CD and Aspect Oriented Programming.

Dynamic Providers

The concept is to have a single controller entrypoint that dynamically resolves the required service. In this application design, the dynamic providers are the unique VEHIKL offices (forest-city, kw, hammer-squad) which each have their own unique interfaces and interaction methods.

The resolved service provider supports a common interface and data shape.

Setup

  1. Ensure you are using the correct version of node by running nvm use
  2. Install dependencies using yarn
  3. There yah go!

Debugging

There are two different debugging scenarios:

Running the application

To debug the running application run :

yarn debug:api

Then connect your vscode debugger by using the included launch.json configuration for Debug Nest App.

Boom!

Tests

To debug your test suite, run the included configuration in the launch.json for Jest Tests.

Scaffolded using NX

Build

Run nx build my-app to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run nx test my-app to execute the unit tests via Jest.

Run nx affected:test to execute the unit tests affected by a change.

Running end-to-end tests

Run ng e2e my-app to execute the end-to-end tests via Cypress.

Run nx affected:e2e to execute the end-to-end tests affected by a change.

Understand your workspace

Run nx dep-graph to see a diagram of the dependencies of your projects.

Further help

Visit the Nx Documentation to learn more.

Continuous Integration

Continuous Integration (CI) has been setup using GitHub Actions. Please refer to the ci.yml file for specifics.

Linting and tests are executed, and a test coverage report is posted to the corresponding PR.

The current CI build status is displayed on the README as a badge:

CI

(If the above is red, someone screwed up.)

Coverage Reports

Coverage reports are posted as an autogenerated PR comment, if the CI pipeline is configured with a valid NX_GITHUB_API_TOKEN.

To run the coverage report locally, it is easiest done with

yarn test:api:coverage

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.6%
  • JavaScript 2.4%