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
@@ -4,13 +4,14 @@ import { sqliteAdapter } from '@payloadcms/db-sqlite'
|
||||
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { buildConfig, getPayload } from 'payload'
|
||||
import { getPayload } from 'payload'
|
||||
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { constructionNoticeHref, isPathAllowed, isPathVisibleIn, normalizePath } from '../src/modules/construction/logic.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', () => ({}))
|
||||
|
||||
@@ -36,7 +37,7 @@ describe('under construction — Site Settings → createPageRoute', () => {
|
||||
const i18n = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }, { code: 'en', label: 'English' }] } as const
|
||||
|
||||
beforeAll(async () => {
|
||||
configPromise = buildConfig({
|
||||
configPromise = buildTestConfig({
|
||||
collections: [
|
||||
{ slug: 'users', auth: true, fields: [] },
|
||||
{ slug: 'pages', fields: [{ name: 'title', type: 'text' }, { name: 'slug', type: 'text', index: true, localized: true }] },
|
||||
|
||||
Reference in New Issue
Block a user