1

I am trying to workout a simple way of creating swagger specs and client out of NestJS servers, the official solution is here https://docs.nestjs.com/openapi/introduction.

However, it requires the "server" to be spun up, which isn't ideal because some of the providers require complex setups (e.g. a connection to mongo).

For the sake of the task, thus, this complex setup isn't necessarily required, therefore it would be ideal some sort of TestingModule.stubAllControllerDependencies, so that you could just generate the swagger spec.

Hitmands
  • 13,491
  • 4
  • 34
  • 69

1 Answers1

1

There's an open PR that will allow for something like this. Any services that can't be found would then become automatically mocked. However, it seems this wouldn't be quite what you're looking for as technically all of the providers would exist in the context.

Instead, you could probably make use of the overrideProvider fluent method and provide a mock for the mongoose connection (.overrideProvider(getConnectionToken()).useValue(jest.fn()) or something similar which would allow you to mock out your mongoose server. Could do the same for other external services

Jay McDoniel
  • 57,339
  • 7
  • 135
  • 147