fix: tests running with local API imported from the payload package instead of the HMR from the next package

This commit is contained in:
Paul Popus
2024-03-13 18:00:41 -03:00
parent 5c2bcba000
commit 171144be80
2 changed files with 3 additions and 4 deletions

View File

@@ -64,7 +64,7 @@ export const getPayloadHMR = async (options: InitOptions): Promise<Payload> => {
try {
cached.payload = await cached.promise
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
try {
const port = process.env.PORT || '3000'
const ws = new WebSocket(`ws://localhost:${port}/_next/webpack-hmr`)

View File

@@ -6,7 +6,7 @@ import path from 'path'
import type { SanitizedConfig } from '../../packages/payload/src/config/types.js'
import type { Payload } from '../../packages/payload/src/index.js'
import { getPayload } from '../../packages/payload/src/index.js'
import { getPayloadHMR } from '../../packages/next/src/utilities/getPayloadHMR.js'
import wait from '../../packages/payload/src/utilities/wait.js'
import { beforeTest } from '../beforeTest.js'
@@ -30,10 +30,9 @@ export async function initPayloadE2E({ config, dirname }: Args): Promise<Result>
process.env.PAYLOAD_DROP_DATABASE = 'true'
process.env.PORT = String(port)
const payload = await getPayload({ config })
// @ts-expect-error
process.env.NODE_ENV = 'test'
const payload = await getPayloadHMR({ config })
nextDev({
_: [path.resolve(dirname, '../../')],