/** * Guard: a test that boots Payload with a raw buildConfig leaks a spinning * `payload generate:types` process per run (see buildTestConfig in helpers.ts). */ import { readdirSync, readFileSync } from 'node:fs' import path from 'node:path' import { describe, expect, test } from 'vitest' import { buildTestConfig } from './helpers.js' const dir = import.meta.dirname describe('test configs never auto-generate types', () => { test('buildTestConfig turns autoGenerate off', async () => { const config = await buildTestConfig({ collections: [], secret: 'x', typescript: { outputFile: 'types.ts' } } as never) expect(config.typescript).toMatchObject({ autoGenerate: false, outputFile: 'types.ts' }) }) test('no test calls buildConfig from payload directly', () => { const offenders = readdirSync(dir) .filter((f) => f.endsWith('.ts') && f !== 'helpers.ts' && f !== 'testConfig.test.ts') .filter((f) => /\bbuildConfig\b/.test(readFileSync(path.join(dir, f), 'utf8').replace(/buildTestConfig/g, ''))) expect(offenders).toEqual([]) }) })