Unverified Commit 05909885 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix output: standalone test for app directory (#43618)

This test was ensuring `app` directory is working correctly with
`output: 'standalone'`. Instead of removing config we should
conditionally set it for the test.

Reverts vercel/next.js#43607

x-ref:
https://github.com/vercel/next.js/actions/runs/3594732606/jobs/6055832699
x-ref:
https://github.com/vercel/next.js/actions/runs/3594732606/jobs/6055832421
parent 70d89bc8
...@@ -5,7 +5,6 @@ module.exports = { ...@@ -5,7 +5,6 @@ module.exports = {
algorithm: 'sha256', algorithm: 'sha256',
}, },
}, },
// TODO: (wyattjoh) enable once we've resolved issues with app directory and standalone output mode
// output: 'standalone', // output: 'standalone',
rewrites: async () => { rewrites: async () => {
return { return {
......
import os from 'os'
import { createNext, FileRef } from 'e2e-utils' import { createNext, FileRef } from 'e2e-utils'
import crypto from 'crypto' import crypto from 'crypto'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { import {
check, check,
fetchViaHTTP, fetchViaHTTP,
findPort,
getRedboxHeader, getRedboxHeader,
initNextServerScript,
killApp,
renderViaHTTP, renderViaHTTP,
waitFor, waitFor,
waitForAndOpenRuntimeError, waitForAndOpenRuntimeError,
...@@ -16,7 +12,6 @@ import { ...@@ -16,7 +12,6 @@ import {
import path from 'path' import path from 'path'
import cheerio from 'cheerio' import cheerio from 'cheerio'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import fs from 'fs-extra'
describe('app dir', () => { describe('app dir', () => {
const isDev = (global as any).isNextDev const isDev = (global as any).isNextDev
...@@ -2554,44 +2549,4 @@ describe('app dir', () => { ...@@ -2554,44 +2549,4 @@ describe('app dir', () => {
} }
runTests() runTests()
if ((global as any).isNextStart) {
it('should work correctly with output standalone', async () => {
const tmpFolder = path.join(os.tmpdir(), 'next-standalone-' + Date.now())
await fs.move(path.join(next.testDir, '.next/standalone'), tmpFolder)
let server
try {
const testServer = path.join(tmpFolder, 'server.js')
const appPort = await findPort()
server = await initNextServerScript(
testServer,
/Listening on/,
{
...process.env,
PORT: appPort,
},
undefined,
{
cwd: tmpFolder,
}
)
for (const testPath of [
'/',
'/api/hello',
'/blog/first',
'/dashboard',
'/dashboard/deployments/123',
'/catch-all/first',
]) {
const res = await fetchViaHTTP(appPort, testPath)
expect(res.status).toBe(200)
}
} finally {
if (server) await killApp(server)
await fs.remove(tmpFolder)
}
})
}
}) })
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'
import {
fetchViaHTTP,
findPort,
initNextServerScript,
killApp,
} from 'next-test-utils'
describe('output: standalone with app dir', () => {
let next: NextInstance
if (!(global as any).isNextStart) {
it('should skip for non-next start', () => {})
return
}
beforeAll(async () => {
next = await createNext({
files: new FileRef(path.join(__dirname, 'app')),
dependencies: {
swr: '2.0.0-rc.0',
react: 'latest',
'react-dom': 'latest',
sass: 'latest',
},
skipStart: true,
})
await next.patchFile(
'next.config.js',
(await next.readFile('next.config.js')).replace('// output', 'output')
)
await next.start()
})
afterAll(async () => {
await next.destroy()
})
it('should work correctly with output standalone', async () => {
const tmpFolder = path.join(os.tmpdir(), 'next-standalone-' + Date.now())
await fs.move(path.join(next.testDir, '.next/standalone'), tmpFolder)
let server
try {
const testServer = path.join(tmpFolder, 'server.js')
const appPort = await findPort()
server = await initNextServerScript(
testServer,
/Listening on/,
{
...process.env,
PORT: appPort,
},
undefined,
{
cwd: tmpFolder,
}
)
for (const testPath of [
'/',
'/api/hello',
'/blog/first',
'/dashboard',
'/dashboard/deployments/123',
'/catch-all/first',
]) {
const res = await fetchViaHTTP(appPort, testPath)
expect(res.status).toBe(200)
}
} finally {
if (server) await killApp(server)
await fs.remove(tmpFolder)
}
})
})
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