Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removes extra run dev and test setup #10006

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions test/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { parse } from 'url'

import { getNextRootDir } from './helpers/getNextRootDir.js'
import startMemoryDB from './helpers/startMemoryDB.js'
import { runInit } from './runInit.js'
import { child, safelyRunScriptFunction } from './safelyRunScript.js'
import { initDevAndTest } from './initDevAndTest.js'
import { createTestHooks } from './testHooks.js'

const prod = process.argv.includes('--prod')
Expand All @@ -34,25 +33,25 @@ const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)

const {
_: [testSuiteArg],
_: [testSuite],
...args
} = minimist(process.argv.slice(2))

if (!fs.existsSync(path.resolve(dirname, testSuiteArg))) {
console.log(chalk.red(`ERROR: The test folder "${testSuiteArg}" does not exist`))
if (!fs.existsSync(path.resolve(dirname, testSuite))) {
console.log(chalk.red(`ERROR: The test folder "${testSuite}" does not exist`))
process.exit(0)
}

if (args.turbo === true) {
process.env.TURBOPACK = '1'
}

const { beforeTest } = await createTestHooks(testSuiteArg)
const { beforeTest } = await createTestHooks(testSuite)
await beforeTest()

const { rootDir, adminRoute } = getNextRootDir(testSuiteArg)
const { rootDir, adminRoute } = getNextRootDir(testSuite)

await safelyRunScriptFunction(runInit, 4000, testSuiteArg, true)
await initDevAndTest({ testSuite, writeDBAdapter: true })

if (shouldStartMemoryDB) {
await startMemoryDB()
Expand Down Expand Up @@ -94,16 +93,3 @@ process.env.PAYLOAD_DROP_DATABASE = process.env.PAYLOAD_DROP_DATABASE === 'false
// fetch the admin url to force a render
void fetch(`http://localhost:${port}${adminRoute}`)
void fetch(`http://localhost:${port}/api/access`)
// This ensures that the next-server process is killed when this process is killed and doesn't linger around.
process.on('SIGINT', () => {
if (child) {
child.kill('SIGINT')
}
process.exit(0)
})
process.on('SIGTERM', () => {
if (child) {
child.kill('SIGINT')
}
process.exit(0) // Exit the parent process
})
Comment on lines -98 to -109
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlessioGr this threw me off because I could see that child was exported from safelyRunScript and assigned there in a function that I don't think was ever being called.

I need to know how this was supposed to work or risk having a regression.

Loading
Loading