Tests: boot Payload without type generation, guard against the leak
Outside production getPayload() spawns a detached generate:types child. With no PAYLOAD_CONFIG_PATH it never finds a config (tsconfig rootDir './' sends Payload's findUpSync into an endless loop), so every full vitest run left six processes spinning at ~40% CPU. - test/helpers.ts: buildTestConfig() = buildConfig with typescript.autoGenerate false - the six tests that boot Payload use it - test/testConfig.test.ts: fails if a test calls buildConfig directly Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e53d09b720
commit
53a8920564
@@ -9,7 +9,7 @@ import { sqliteAdapter } from '@payloadcms/db-sqlite'
|
||||
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
import { buildConfig, getPayload } from 'payload'
|
||||
import { getPayload } from 'payload'
|
||||
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { buildConsentLogEndpoint } from '../src/modules/consent/consentLog.js'
|
||||
@@ -18,6 +18,7 @@ import { submitForm } from '../src/modules/forms/submitForm.js'
|
||||
import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js'
|
||||
import { createPageRoute } from '../src/modules/frontend/pageRoute.js'
|
||||
import { ipalKit } from '../src/plugin.js'
|
||||
import { buildTestConfig } from './helpers.js'
|
||||
|
||||
vi.mock('server-only', () => ({}))
|
||||
|
||||
@@ -26,7 +27,7 @@ let configPromise: Parameters<typeof getPayload>[0]['config']
|
||||
let formId: string
|
||||
|
||||
beforeAll(async () => {
|
||||
const config = buildConfig({
|
||||
const config = buildTestConfig({
|
||||
collections: [
|
||||
// Open sign-up, the risky setup the roles field guard exists for.
|
||||
{ slug: 'users', access: { create: () => true }, auth: true, fields: [] },
|
||||
|
||||
Reference in New Issue
Block a user