diff --git a/test/e2e/app-dir/app/next.config.js b/test/e2e/app-dir/app/next.config.js index 085fe6d416a6..e794b8b1af67 100644 --- a/test/e2e/app-dir/app/next.config.js +++ b/test/e2e/app-dir/app/next.config.js @@ -5,7 +5,6 @@ module.exports = { algorithm: 'sha256', }, }, - // TODO: (wyattjoh) enable once we've resolved issues with app directory and standalone output mode // output: 'standalone', rewrites: async () => { return { diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index 6992e37fde50..a4e0278080c9 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -1,14 +1,10 @@ -import os from 'os' import { createNext, FileRef } from 'e2e-utils' import crypto from 'crypto' import { NextInstance } from 'test/lib/next-modes/base' import { check, fetchViaHTTP, - findPort, getRedboxHeader, - initNextServerScript, - killApp, renderViaHTTP, waitFor, waitForAndOpenRuntimeError, @@ -16,7 +12,6 @@ import { import path from 'path' import cheerio from 'cheerio' import webdriver from 'next-webdriver' -import fs from 'fs-extra' describe('app dir', () => { const isDev = (global as any).isNextDev @@ -2554,44 +2549,4 @@ describe('app dir', () => { } 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) - } - }) - } }) diff --git a/test/e2e/app-dir/standalone.test.ts b/test/e2e/app-dir/standalone.test.ts new file mode 100644 index 000000000000..4ed2da4beafd --- /dev/null +++ b/test/e2e/app-dir/standalone.test.ts @@ -0,0 +1,80 @@ +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) + } + }) +})