Integration Test
const fetch = require('node-fetch')
const api = require('../../../src/server')
const apiPort = Math.round(Math.random() * 65535)
const baseURL = `http://localhost:${apiPort}/api/v1`
const db = require('../../../src/utils/db')
let dbConnection
const dbTestUtils = require('../../../tests/testUtils/dbTestUtil')
/**
* 1. Arrange
* - setup the world
*/
beforeAll(async () => {
await api.listen(apiPort) // start the application
dbConnection = await db() // start the database
})
beforeEach(async () => {
await dbTestUtils.setUpDatabase()
})
afterEach(async () => {
await dbTestUtils.clearDatabase()
})
afterAll(async () => {
await api.close()
await dbConnection.disconnect()
})
/**
* 2. Act
* - make the http call
* 3. Assert
* - response check
*/
describe('API Test - Register User', () => {
// Tests go here
})The Passing Test
The Failing Test
Last updated