chore: attach mongoMemoryServer to db and destroy in tests (#5326)
* chore: attach mongoMemoryServer to db and destroy in tests * bump mongodb-memory-server to 9.x --------- Co-authored-by: Paul Popus <paul@nouance.io>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getPayload } from '../../packages/payload/src/index.js'
|
||||
import { getPayload, type Payload } from '../../packages/payload/src/index.js'
|
||||
import { NextRESTClient } from '../helpers/NextRESTClient.js'
|
||||
import { startMemoryDB } from '../startMemoryDB.js'
|
||||
import configPromise from './config.js'
|
||||
@@ -12,15 +12,22 @@ import {
|
||||
rootEndpoint,
|
||||
} from './shared.js'
|
||||
|
||||
let payload: Payload
|
||||
let restClient: NextRESTClient
|
||||
|
||||
describe('Endpoints', () => {
|
||||
beforeAll(async () => {
|
||||
const config = await startMemoryDB(configPromise)
|
||||
await getPayload({ config })
|
||||
payload = await getPayload({ config })
|
||||
restClient = new NextRESTClient(config)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
if (typeof payload.db.destroy === 'function') {
|
||||
await payload.db.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
describe('Collections', () => {
|
||||
it('should GET a static endpoint', async () => {
|
||||
const response = await restClient.GET(`/${collectionSlug}/say-hello/joe-bloggs`)
|
||||
|
||||
Reference in New Issue
Block a user