Files
payloadcms/test/plugins/int.spec.ts
Dan Ribbens d193c677c7 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>
2024-03-14 15:41:20 -04:00

31 lines
769 B
TypeScript

import type { Payload } from '../../packages/payload/src/index.js'
import { getPayload } from '../../packages/payload/src/index.js'
import { startMemoryDB } from '../startMemoryDB.js'
import configPromise, { pagesSlug } from './config.js'
let payload: Payload
describe('Collections - Plugins', () => {
beforeAll(async () => {
const config = await startMemoryDB(configPromise)
payload = await getPayload({ config })
})
afterAll(async () => {
if (typeof payload.db.destroy === 'function') {
await payload.db.destroy()
}
})
it('created pages collection', async () => {
const { id } = await payload.create({
collection: pagesSlug,
data: {
title: 'Test Page',
},
})
expect(id).toBeDefined()
})
})