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:
Dan Ribbens
2024-03-14 15:41:20 -04:00
committed by GitHub
parent cbfc7c8b43
commit d193c677c7
36 changed files with 254 additions and 133 deletions

View File

@@ -1,13 +1,13 @@
import type { Payload } from '../../packages/payload/src/index.js'
import { getPayload } from '../../packages/payload/src/index.js'
import type { Form } from './payload-types.js'
import { ValidationError } from '../../packages/payload/src/errors/index.js'
import { getPayload } from '../../packages/payload/src/index.js'
import { serializeLexical } from '../../packages/plugin-form-builder/src/utilities/lexical/serializeLexical.js'
import { serializeSlate } from '../../packages/plugin-form-builder/src/utilities/slate/serializeSlate.js'
import { startMemoryDB } from '../startMemoryDB.js'
import configPromise from './config.js'
import { formSubmissionsSlug, formsSlug } from './shared.js'
import { formsSlug, formSubmissionsSlug } from './shared.js'
let payload: Payload
let form: Form
@@ -39,6 +39,12 @@ describe('@payloadcms/plugin-form-builder', () => {
})) as unknown as Form
})
afterAll(async () => {
if (typeof payload.db.destroy === 'function') {
await payload.db.destroy()
}
})
describe('plugin collections', () => {
it('adds forms collection', async () => {
const { docs: forms } = await payload.find({ collection: formsSlug })