Skip to content

Commit 0590988

Browse files
authored
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 #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
1 parent 70d89bc commit 0590988

File tree

3 files changed

+80
-46
lines changed

3 files changed

+80
-46
lines changed

test/e2e/app-dir/app/next.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = {
55
algorithm: 'sha256',
66
},
77
},
8-
// TODO: (wyattjoh) enable once we've resolved issues with app directory and standalone output mode
98
// output: 'standalone',
109
rewrites: async () => {
1110
return {

test/e2e/app-dir/index.test.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
import os from 'os'
21
import { createNext, FileRef } from 'e2e-utils'
32
import crypto from 'crypto'
43
import { NextInstance } from 'test/lib/next-modes/base'
54
import {
65
check,
76
fetchViaHTTP,
8-
findPort,
97
getRedboxHeader,
10-
initNextServerScript,
11-
killApp,
128
renderViaHTTP,
139
waitFor,
1410
waitForAndOpenRuntimeError,
1511
} from 'next-test-utils'
1612
import path from 'path'
1713
import cheerio from 'cheerio'
1814
import webdriver from 'next-webdriver'
19-
import fs from 'fs-extra'
2015

2116
describe('app dir', () => {
2217
const isDev = (global as any).isNextDev
@@ -2554,44 +2549,4 @@ describe('app dir', () => {
25542549
}
25552550

25562551
runTests()
2557-
2558-
if ((global as any).isNextStart) {
2559-
it('should work correctly with output standalone', async () => {
2560-
const tmpFolder = path.join(os.tmpdir(), 'next-standalone-' + Date.now())
2561-
await fs.move(path.join(next.testDir, '.next/standalone'), tmpFolder)
2562-
let server
2563-
2564-
try {
2565-
const testServer = path.join(tmpFolder, 'server.js')
2566-
const appPort = await findPort()
2567-
server = await initNextServerScript(
2568-
testServer,
2569-
/Listening on/,
2570-
{
2571-
...process.env,
2572-
PORT: appPort,
2573-
},
2574-
undefined,
2575-
{
2576-
cwd: tmpFolder,
2577-
}
2578-
)
2579-
2580-
for (const testPath of [
2581-
'/',
2582-
'/api/hello',
2583-
'/blog/first',
2584-
'/dashboard',
2585-
'/dashboard/deployments/123',
2586-
'/catch-all/first',
2587-
]) {
2588-
const res = await fetchViaHTTP(appPort, testPath)
2589-
expect(res.status).toBe(200)
2590-
}
2591-
} finally {
2592-
if (server) await killApp(server)
2593-
await fs.remove(tmpFolder)
2594-
}
2595-
})
2596-
}
25972552
})
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { createNext, FileRef } from 'e2e-utils'
2+
import { NextInstance } from 'test/lib/next-modes/base'
3+
import fs from 'fs-extra'
4+
import os from 'os'
5+
import path from 'path'
6+
import {
7+
fetchViaHTTP,
8+
findPort,
9+
initNextServerScript,
10+
killApp,
11+
} from 'next-test-utils'
12+
13+
describe('output: standalone with app dir', () => {
14+
let next: NextInstance
15+
16+
if (!(global as any).isNextStart) {
17+
it('should skip for non-next start', () => {})
18+
return
19+
}
20+
21+
beforeAll(async () => {
22+
next = await createNext({
23+
files: new FileRef(path.join(__dirname, 'app')),
24+
dependencies: {
25+
swr: '2.0.0-rc.0',
26+
react: 'latest',
27+
'react-dom': 'latest',
28+
sass: 'latest',
29+
},
30+
skipStart: true,
31+
})
32+
33+
await next.patchFile(
34+
'next.config.js',
35+
(await next.readFile('next.config.js')).replace('// output', 'output')
36+
)
37+
await next.start()
38+
})
39+
afterAll(async () => {
40+
await next.destroy()
41+
})
42+
43+
it('should work correctly with output standalone', async () => {
44+
const tmpFolder = path.join(os.tmpdir(), 'next-standalone-' + Date.now())
45+
await fs.move(path.join(next.testDir, '.next/standalone'), tmpFolder)
46+
let server
47+
48+
try {
49+
const testServer = path.join(tmpFolder, 'server.js')
50+
const appPort = await findPort()
51+
server = await initNextServerScript(
52+
testServer,
53+
/Listening on/,
54+
{
55+
...process.env,
56+
PORT: appPort,
57+
},
58+
undefined,
59+
{
60+
cwd: tmpFolder,
61+
}
62+
)
63+
64+
for (const testPath of [
65+
'/',
66+
'/api/hello',
67+
'/blog/first',
68+
'/dashboard',
69+
'/dashboard/deployments/123',
70+
'/catch-all/first',
71+
]) {
72+
const res = await fetchViaHTTP(appPort, testPath)
73+
expect(res.status).toBe(200)
74+
}
75+
} finally {
76+
if (server) await killApp(server)
77+
await fs.remove(tmpFolder)
78+
}
79+
})
80+
})

0 commit comments

Comments
 (0)