1.0.0 • Published 7 months ago
nestjs-mongo-testing v1.0.0
NestJS MongoDB testing
A package providing testing utilities for NestJS APIs using MongoDB.
Table of contents
Installation
You can install the package using the following commands:
# yarn
yarn add -D nestjs-mongo-testing
# npm
npm install -d nestjs-mongo-testing
Documentation
Create a test MongoDB database by importing the TestMongooseModule
in your test module.
import { TestMongooseModule } from 'nestjs-mongo-testing';
async function setup(): Promise<void> {
const rootModule: TestingModule = await Test.createTestingModule({
imports: [TestMongooseModule]
}).compile();
}
Stop the memory server in your teardown function:
import { MemoryServer } from 'nestjs-mongo-testing';
// Execute this at the end of your test.
async function teardown(): Promise<void> {
await MemoryServer.getInstance().stop();
}
1.0.0
7 months ago