chore: avoids importing config into playwright tests
This commit is contained in:
10
package.json
10
package.json
@@ -70,7 +70,7 @@
|
||||
"@next/bundle-analyzer": "^14.1.0",
|
||||
"@octokit/core": "^5.1.0",
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@playwright/test": "1.42.1",
|
||||
"@playwright/test": "^1.42.1",
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/jest": "0.2.36",
|
||||
"@testing-library/jest-dom": "6.4.2",
|
||||
@@ -122,8 +122,8 @@
|
||||
"nodemon": "3.0.3",
|
||||
"pino": "8.15.0",
|
||||
"pino-pretty": "10.2.0",
|
||||
"playwright": "file:playwright-1.43.0-next.tgz",
|
||||
"playwright-core": "file:playwright-core-1.43.0-next.tgz",
|
||||
"playwright": "^1.42.1",
|
||||
"playwright-core": "^1.42.1",
|
||||
"prettier": "^3.0.3",
|
||||
"prompts": "2.4.2",
|
||||
"qs": "6.11.2",
|
||||
@@ -171,9 +171,7 @@
|
||||
"graphql": "^16.8.1",
|
||||
"react": "$react",
|
||||
"react-dom": "$react-dom",
|
||||
"typescript": "$typescript",
|
||||
"playwright": "file:playwright-1.43.0-next.tgz",
|
||||
"playwright-core": "file:playwright-core-1.43.0-next.tgz"
|
||||
"typescript": "$typescript"
|
||||
},
|
||||
"allowedDeprecatedVersions": {
|
||||
"uuid": "3.4.0",
|
||||
|
||||
@@ -47,7 +47,8 @@ export const getPayload = async (options: InitOptions): Promise<Payload> => {
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
try {
|
||||
const ws = new WebSocket('ws://localhost:3000/_next/webpack-hmr')
|
||||
const port = process.env.PORT || '3000'
|
||||
const ws = new WebSocket(`ws://localhost:${port}/_next/webpack-hmr`)
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
if (typeof event.data === 'string') {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
2225
pnpm-lock.yaml
generated
2225
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,6 @@ import { fileURLToPath } from 'url'
|
||||
import { initPageConsoleErrorCatch } from '../helpers.js'
|
||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||
import { initPayloadE2E } from '../helpers/configHelpers.js'
|
||||
import config from './config.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
@@ -19,7 +18,7 @@ describe('Admin Panel', () => {
|
||||
let url: AdminUrlUtil
|
||||
|
||||
beforeAll(async ({ browser }) => {
|
||||
const { serverURL } = await initPayloadE2E({ config, dirname })
|
||||
const { serverURL } = await initPayloadE2E({ dirname })
|
||||
url = new AdminUrlUtil(serverURL, 'posts')
|
||||
|
||||
const context = await browser.newContext()
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
import getPort from 'get-port'
|
||||
//import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import path from 'path'
|
||||
|
||||
import type { SanitizedConfig } from '../../packages/payload/src/config/types.js'
|
||||
import type { Payload } from '../../packages/payload/src/index.js'
|
||||
import wait from '../../packages/payload/src/utilities/wait.js'
|
||||
|
||||
import { getPayload } from '../../packages/payload/src/index.js'
|
||||
import { bootAdminPanel } from './bootAdminPanel.mjs'
|
||||
|
||||
type InitializedPayload = { payload: Payload; serverURL: string }
|
||||
|
||||
export async function initPayloadE2E(args: {
|
||||
config: Promise<SanitizedConfig>
|
||||
type Args = {
|
||||
dirname: string
|
||||
}): Promise<InitializedPayload> {
|
||||
const { config, dirname } = args
|
||||
}
|
||||
|
||||
console.log('dirname', dirname)
|
||||
|
||||
// process.env.TURBOPACK = '1' // Not working due to turbopack pulling in mongoose, pg
|
||||
process.env.PAYLOAD_CONFIG_PATH = path.resolve(dirname, './config.js')
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
//process.env.NODE_ENV = 'test'
|
||||
|
||||
const payload = await getPayload({ config })
|
||||
type Result = {
|
||||
serverURL: string
|
||||
}
|
||||
|
||||
export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
const port = await getPort()
|
||||
const serverURL = `http://localhost:${port}`
|
||||
process.env.PAYLOAD_CONFIG_PATH = path.resolve(dirname, './config.js')
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
process.env.PORT = String(port)
|
||||
|
||||
//process.env.NODE_ENV = 'test'
|
||||
//process.env.APP_ENV = 'test'
|
||||
//process.env.__NEXT_TEST_MODE = 'jest'
|
||||
|
||||
//await nextDev({ _: [path.resolve(dirname, '../../')], port }) // Running nextDev directly does not work for ports other than 3000
|
||||
await bootAdminPanel({ port, appDir: path.resolve(dirname, '../../') })
|
||||
return { serverURL, payload }
|
||||
nextDev({
|
||||
_: [path.resolve(dirname, '../../')],
|
||||
'--port': port,
|
||||
// '--turbo': '1',
|
||||
})
|
||||
|
||||
await wait(3000)
|
||||
return { serverURL }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user