4.2.0 • Published 1 year ago
testcontainers-mongoose v4.2.0
Testcontainers-mongoose
a mongoose helper for using testcontainers with mongodb
https://www.npmjs.com/package/testcontainers-mongoose
Installation
npm i -D testcontainers-mongoose
if using mongoose 7.x
version
npm i -D testcontainers-mongoose@2.2.2
Configuration
Logs
DEBUG=testcontainers
Enable testcontainers logsDEBUG=testcontainers:containers
Enable container logsDEBUG=testcontainers*
Enable all logs
Testcontainers
TESTCONTAINERS_RYUK_DISABLED=true
Disable ryukRYUK_CONTAINER_IMAGE=registry.mycompany.com/mirror/ryuk:0.3.0
Custom image for ryuk
Usage
Testing with Vitest
import * as dbHandler from 'testcontainers-mongoose'
import { describe, beforeAll, afterAll, afterEach, it, expect } from 'vitest'
describe('testcontainers-mongoose test', () => {
beforeAll(async () => {
await dbHandler.connect('harbor.yourcompany.com/mongo:4.4.4')
// ...
})
afterAll(async () => {
await dbHandler.closeDatabase()
})
afterEach(async () => {
await dbHandler.clearDatabase()
})
it('some test using mongoose', async () => {
// ...
})
})
Start Mongo Container without connect with mongoose
In case you want to connect the mongo by yourself
using startedMongoTestContainerOf
Get the mongo connection string by .getUri()
Example
import { startedMongoTestContainerOf, StartedMongoTestContainer } from 'testcontainers-mongoose'
import { describe, beforeAll, afterAll, afterEach, it, expect } from 'vitest'
describe('testcontainers-mongoose test', () => {
let mongoTestContainer: StartedMongoTestContainer
beforeAll(async () => {
mongoTestContainer = await startedMongoTestContainerOf('harbor.yourcompany.com/mongo:4.4.4')
// connect to mongoTestContainer by yourself
// mongoTestContainer.getUri() is the connection string of the mongo container
})
afterAll(async () => {
await mongoTestContainer.closeDatabase()
})
afterEach(async () => {
await mongoTestContainer.clearDatabase()
})
it('some test case', async () => {
// ...
})
})
4.2.0
1 year ago
4.1.6
1 year ago
4.1.4
1 year ago
4.1.3
1 year ago
4.1.2
1 year ago
4.1.1
2 years ago
4.1.0
2 years ago
4.0.0
2 years ago
3.0.2
2 years ago
3.0.1
2 years ago
2.2.1
2 years ago
2.2.2
2 years ago
3.0.0
2 years ago
2.1.2
2 years ago
2.0.3
2 years ago
2.2.0
2 years ago
2.1.1
2 years ago
2.0.2
2 years ago
2.1.4
2 years ago
2.1.3
2 years ago
2.0.4
2 years ago
2.1.6
2 years ago
2.1.5
2 years ago
2.1.7
2 years ago
2.1.0
2 years ago
1.1.1
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.1.0
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
0.2.3
3 years ago
0.2.0
3 years ago
0.2.2
3 years ago
0.1.3
3 years ago
0.1.0
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago