README
A set of helper utility functions that makes testing MongoDB-based projects quick, nimble and readable. Written in Typescript.
Installation
Example usage
import { initializeTestDB, getCollectionSnapshot, flushDb, closeDb } from 'mongo-test-suit'
import * as randomString from 'randomstring'
import { ObjectId } from 'mongodb'
const dbName = `my-db-${randomString.generate(7)}`
const uri = `mongodb://localhost/${dbName}`
beforeAll(async () => {
await initializeTestDB(uri)
})
afterAll(async () => {
await flushDb()
await closeDb()
})
describe('myNeatFunction()', () => {
test('It does what you think it does', async () => {
// Go about your business
// Now get a snapshot of the collection
expect(await getCollectionSnapshot({ collectionName: 'MyCollection' })).toMatchSnapshot()
})
})
Full API documentation here
Author
License
This project is licensed under the MIT License