-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#7] feat: add mongodb test container to test
- Loading branch information
Showing
4 changed files
with
2,566 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
import { MongoDBContainer, StartedMongoDBContainer } from '@testcontainers/mongodb' | ||
import request from 'supertest' | ||
import app from '../src/index' | ||
|
||
describe('GET /', () => { | ||
it('should return 200 OK', async () => { | ||
const response = await request(app).get('/') | ||
expect(response.status).toBe(200) | ||
describe('Index', () => { | ||
let startedContainer: StartedMongoDBContainer | ||
|
||
beforeAll(async () => { | ||
const container: MongoDBContainer = new MongoDBContainer().withExposedPorts(27017) | ||
startedContainer = await container.start() | ||
process.env.DB_URL = `mongodb://${startedContainer.getHost()}:${startedContainer.getMappedPort(27017)}/user-service` | ||
}) | ||
|
||
afterAll(async () => { | ||
await startedContainer.stop() | ||
}) | ||
|
||
describe('GET /', () => { | ||
it('should return 200 OK', async () => { | ||
const response = await request(app).get('/') | ||
expect(response.status).toBe(200) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.