Unverified Commit c9715330 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix image-optimizer tests for Turbopack (#60972)

## What?

There were a bunch of Sharp related tests failing when running the test
suite with Turbopack. The reason for this was that we automatically
detect the root of the project based on the closest lockfile (i.e.
package-lock.json). In this particular test a new package-lock.json was
added and since this suite is not yet isolated it cases problems.

This PR adds `outputFileTracingRoot` to explicitly provide the root of
the project, which ensures the right files are resolved.

Closes NEXT-2180
parent 92265ccb
...@@ -1320,6 +1320,12 @@ export const setupTests = (ctx) => { ...@@ -1320,6 +1320,12 @@ export const setupTests = (ctx) => {
} }
beforeAll(async () => { beforeAll(async () => {
const json = JSON.stringify({
experimental: {
outputFileTracingRoot: join(__dirname, '../../../..'),
},
})
nextConfig.replace('{ /* replaceme */ }', json)
curCtx.nextOutput = '' curCtx.nextOutput = ''
curCtx.appPort = await findPort() curCtx.appPort = await findPort()
curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, { curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, {
...@@ -1336,6 +1342,7 @@ export const setupTests = (ctx) => { ...@@ -1336,6 +1342,7 @@ export const setupTests = (ctx) => {
await cleanImagesDir(ctx) await cleanImagesDir(ctx)
}) })
afterAll(async () => { afterAll(async () => {
nextConfig.restore()
if (curCtx.app) await killApp(curCtx.app) if (curCtx.app) await killApp(curCtx.app)
}) })
...@@ -1365,6 +1372,9 @@ export const setupTests = (ctx) => { ...@@ -1365,6 +1372,9 @@ export const setupTests = (ctx) => {
beforeAll(async () => { beforeAll(async () => {
const json = JSON.stringify({ const json = JSON.stringify({
images: curCtx.nextConfigImages, images: curCtx.nextConfigImages,
experimental: {
outputFileTracingRoot: join(__dirname, '../../../..'),
},
}) })
curCtx.nextOutput = '' curCtx.nextOutput = ''
nextConfig.replace('{ /* replaceme */ }', json) nextConfig.replace('{ /* replaceme */ }', json)
...@@ -1403,6 +1413,12 @@ export const setupTests = (ctx) => { ...@@ -1403,6 +1413,12 @@ export const setupTests = (ctx) => {
isDev: false, isDev: false,
} }
beforeAll(async () => { beforeAll(async () => {
const json = JSON.stringify({
experimental: {
outputFileTracingRoot: join(__dirname, '../../../..'),
},
})
nextConfig.replace('{ /* replaceme */ }', json)
curCtx.nextOutput = '' curCtx.nextOutput = ''
await nextBuild(curCtx.appDir) await nextBuild(curCtx.appDir)
await cleanImagesDir(ctx) await cleanImagesDir(ctx)
...@@ -1420,6 +1436,7 @@ export const setupTests = (ctx) => { ...@@ -1420,6 +1436,7 @@ export const setupTests = (ctx) => {
}) })
}) })
afterAll(async () => { afterAll(async () => {
nextConfig.restore()
if (curCtx.app) await killApp(curCtx.app) if (curCtx.app) await killApp(curCtx.app)
}) })
...@@ -1452,6 +1469,9 @@ export const setupTests = (ctx) => { ...@@ -1452,6 +1469,9 @@ export const setupTests = (ctx) => {
beforeAll(async () => { beforeAll(async () => {
const json = JSON.stringify({ const json = JSON.stringify({
images: curCtx.nextConfigImages, images: curCtx.nextConfigImages,
experimental: {
outputFileTracingRoot: join(__dirname, '../../../..'),
},
}) })
curCtx.nextOutput = '' curCtx.nextOutput = ''
nextConfig.replace('{ /* replaceme */ }', json) nextConfig.replace('{ /* replaceme */ }', json)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment