From 69f5fb260a4d2ca4e83365ad2b64913ead57b005 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 25 Mar 2024 18:37:34 +0100 Subject: [PATCH] Skip test/integration development tests during Turbopack build test run (#63671) ## What? Follow-up to #63665. Ensures development tests are skipped during the production build run for Turbopack (i.e. used to create the turbopack-build-tests-manifest). Adds `pnpm test-dev-turbo` and `pnpm test-start-turbo` (and their `testonly` equivalent) for running tests. Closes NEXT-2915 --- package.json | 4 + .../404-page-app/test/index.test.js | 50 +-- .../404-page-custom-error/test/index.test.js | 20 +- .../404-page-ssg/test/index.test.js | 36 +- test/integration/404-page/test/index.test.js | 19 +- .../500-page/test/gsp-gssp.test.js | 92 +++-- test/integration/500-page/test/index.test.js | 21 +- .../test/index.test.js | 34 +- .../amphtml-ssg/test/index.test.js | 19 +- .../test/dynamic-missing-gsp-dev.test.ts | 39 +- .../test/dynamicapiroute-dev.test.ts | 37 +- .../test/dynamicpage-dev.test.ts | 37 +- .../test/trailing-slash-dev.test.ts | 19 +- .../test/index.test.js | 50 +-- test/integration/app-tree/test/index.test.js | 19 +- .../async-modules/test/index.test.js | 23 +- test/integration/bigint/test/index.test.js | 19 +- .../test/index.test.js | 21 +- .../integration/client-404/test/index.test.js | 27 +- .../client-shallow-routing/test/index.test.js | 21 +- .../test/index.test.js | 31 +- test/integration/css/test/css-modules.test.js | 29 +- .../custom-page-extension/test/index.test.js | 19 +- .../custom-routes-catchall/test/index.test.js | 21 +- .../test/index.test.js | 20 +- .../custom-routes-i18n/test/index.test.js | 20 +- .../custom-routes/test/index.test.js | 65 +-- .../data-fetching-errors/test/index.test.js | 10 +- .../integration/disable-js/test/index.test.js | 58 +-- test/integration/dist-dir/test/index.test.js | 46 ++- .../document-head-warnings/test/index.test.js | 38 +- .../integration/draft-mode/test/index.test.ts | 174 ++++---- .../test/index.test.js | 21 +- .../test/index.test.js | 19 +- .../test/index.test.js | 37 +- .../dynamic-routing/test/index.test.js | 23 +- .../test/index.test.js | 169 ++++---- .../test/index.test.js | 76 ++-- .../test/index.test.ts | 26 +- .../test/index.test.ts | 89 ++-- .../integration/env-config/test/index.test.js | 385 +++++++++--------- .../fallback-false-rewrite/test/index.test.js | 21 +- .../fallback-route-params/test/index.test.js | 21 +- .../test/index.test.js | 33 +- .../fetch-polyfill/test/index.test.js | 33 +- .../file-serving/test/index.test.js | 33 +- .../getinitialprops/test/index.test.js | 19 +- .../test/index.test.js | 204 +++++----- .../gip-identifier/test/index.test.js | 9 +- .../gssp-pageProps-merge/test/index.test.js | 21 +- .../test/index.test.js | 19 +- .../gssp-redirect/test/index.test.js | 19 +- test/integration/hashbang/test/index.test.js | 19 +- test/integration/hydration/test/index.test.js | 21 +- .../i18n-support-base-path/test/index.test.js | 36 +- .../i18n-support-catchall/test/index.test.js | 21 +- .../test/index.test.js | 19 +- .../test/index.test.js | 27 +- .../test/index.test.js | 27 +- .../test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../i18n-support/test/index.test.js | 112 ++--- .../index-index/test/index.test.js | 19 +- .../initial-ref/test/index.test.js | 20 +- .../invalid-custom-routes/test/index.test.js | 40 +- .../invalid-href/test/index.test.js | 100 ++--- .../test/index.test.js | 36 +- .../invalid-multi-match/test/index.test.js | 25 +- test/integration/link-ref/test/index.test.js | 53 +-- .../link-without-router/test/index.test.js | 27 +- .../middleware-basic/test/index.test.js | 19 +- .../test/index.test.ts | 51 +-- .../middleware-src/test/index.test.js | 20 +- .../next-dynamic-css/test/index.test.js | 21 +- .../test/index.test.js | 19 +- .../next-dynamic/test/index.test.js | 19 +- .../asset-prefix/test/index.test.ts | 55 +-- .../base-path/test/index.test.ts | 19 +- .../base-path/test/static.test.ts | 28 +- .../default/test/index.test.ts | 23 +- .../svgo-webpack/test/index.test.ts | 40 +- .../trailing-slash/test/index.test.ts | 51 +-- .../typescript/test/index.test.ts | 53 +-- .../unicode/test/index.test.ts | 31 +- .../unoptimized/test/index.test.ts | 23 +- .../next-image-new/app-dir/test/index.test.ts | 23 +- .../app-dir/test/static.test.ts | 30 +- .../asset-prefix/test/index.test.js | 74 ++-- .../base-path/test/index.test.js | 23 +- .../base-path/test/static.test.js | 30 +- .../test/index.test.ts | 19 +- .../next-image-new/default/test/index.test.ts | 23 +- .../default/test/static.test.ts | 30 +- .../export-config/test/index.test.ts | 45 +- .../invalid-image-import/test/index.test.ts | 35 +- .../test/index.test.ts | 31 +- .../middleware/test/index.test.ts | 47 ++- .../svgo-webpack/test/index.test.ts | 46 ++- .../trailing-slash/test/index.test.ts | 51 +-- .../typescript/test/index.test.ts | 53 +-- .../next-image-new/unicode/test/index.test.ts | 31 +- .../no-page-props/test/index.test.js | 21 +- .../nullish-config/test/index.test.js | 34 +- .../test/index.test.js | 19 +- .../port-env-var/test/index.test.js | 25 +- .../test/index.test.js | 23 +- .../prerender-preview/test/index.test.js | 240 ++++++----- .../preview-fallback/test/index.test.js | 19 +- .../test/index.test.js | 46 ++- .../test/index.test.js | 21 +- .../test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../rewrites-has-condition/test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../route-index/test/index.test.js | 19 +- .../route-indexes/test/index.test.js | 19 +- .../route-load-cancel/test/index.test.js | 19 +- .../router-hash-navigation/test/index.test.js | 23 +- .../test/index.test.js | 25 +- .../router-is-ready/test/index.test.js | 27 +- .../router-prefetch/test/index.test.js | 41 +- .../router-rerender/test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../server-asset-modules/test/index.test.js | 21 +- .../test/index.test.js | 21 +- .../src-dir-support/test/index.test.js | 19 +- .../ssg-data-404/test/index.test.js | 53 +-- .../test/index.test.js | 20 +- .../static-page-name/test/index.test.js | 19 +- .../trailing-slash-dist/test/index.test.js | 19 +- .../test/index.test.js | 19 +- .../test/index.test.js | 48 +-- .../test/index.test.js | 20 +- .../webpack-require-hook/test/index.test.js | 34 +- .../worker-webpack5/test/index.test.js | 19 +- 137 files changed, 2816 insertions(+), 2387 deletions(-) diff --git a/package.json b/package.json index b12733f7562b7..f12a64a6e3bab 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,14 @@ "test-types": "tsc", "test-unit": "jest test/unit/ packages/next/ packages/font", "test-dev": "cross-env NEXT_TEST_MODE=dev pnpm testheadless", + "test-dev-turbo": "cross-env NEXT_TEST_MODE=dev TURBOPACK=1 TURBOPACK_DEV=1 pnpm testheadless", "test-start": "cross-env NEXT_TEST_MODE=start pnpm testheadless", + "test-start-turbo": "cross-env NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 pnpm testheadless", "test-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testheadless", "testonly-dev": "cross-env NEXT_TEST_MODE=dev pnpm testonly", + "testonly-dev-turbo": "cross-env NEXT_TEST_MODE=dev TURBOPACK=1 TURBOPACK_DEV=1 pnpm testonly", "testonly-start": "cross-env NEXT_TEST_MODE=start pnpm testonly", + "testonly-start-turbo": "cross-env NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 pnpm testonly", "testonly-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testonly", "test": "pnpm testheadless", "testonly": "jest --runInBand", diff --git a/test/integration/404-page-app/test/index.test.js b/test/integration/404-page-app/test/index.test.js index dba8466e66eae..48ab47a17af7b 100644 --- a/test/integration/404-page-app/test/index.test.js +++ b/test/integration/404-page-app/test/index.test.js @@ -61,31 +61,33 @@ describe('404 Page Support with _app', () => { }) } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let stderr = '' + let stdout = '' - describe('development mode', () => { - let stderr = '' - let stdout = '' - - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg - }, - onStdout(msg) { - stdout += msg - }, + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg + }, + onStdout(msg) { + stdout += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should not show pages/404 GIP error if _app has GIP', async () => { - const res = await fetchViaHTTP(appPort, '/abc') - expect(res.status).toBe(404) - const $ = cheerio.load(await res.text()) - expect($('#404-title').text()).toBe('Hi There') - expect(stderr).not.toMatch(gip404Err) - expect(stdout).not.toMatch(gip404Err) - }) - }) + it('should not show pages/404 GIP error if _app has GIP', async () => { + const res = await fetchViaHTTP(appPort, '/abc') + expect(res.status).toBe(404) + const $ = cheerio.load(await res.text()) + expect($('#404-title').text()).toBe('Hi There') + expect(stderr).not.toMatch(gip404Err) + expect(stdout).not.toMatch(gip404Err) + }) + } + ) }) diff --git a/test/integration/404-page-custom-error/test/index.test.js b/test/integration/404-page-custom-error/test/index.test.js index 45f3d3588e124..cd4d78f7218a0 100644 --- a/test/integration/404-page-custom-error/test/index.test.js +++ b/test/integration/404-page-custom-error/test/index.test.js @@ -72,14 +72,16 @@ describe('Default 404 Page with custom _error', () => { runTests('server') } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests('dev') - }) + runTests('dev') + } + ) }) diff --git a/test/integration/404-page-ssg/test/index.test.js b/test/integration/404-page-ssg/test/index.test.js index 8a0ac89f9e347..2d682f1e0e191 100644 --- a/test/integration/404-page-ssg/test/index.test.js +++ b/test/integration/404-page-ssg/test/index.test.js @@ -113,23 +113,25 @@ describe('404 Page Support SSG', () => { runTests() } ) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - stderr = '' - stdout = '' - app = await launchApp(appDir, appPort, { - onStdout(msg) { - stdout += msg - }, - onStderr(msg) { - stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + stderr = '' + stdout = '' + app = await launchApp(appDir, appPort, { + onStdout(msg) { + stdout += msg + }, + onStderr(msg) { + stderr += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) }) diff --git a/test/integration/404-page/test/index.test.js b/test/integration/404-page/test/index.test.js index 7f385cf2e6fd9..ca76076108567 100644 --- a/test/integration/404-page/test/index.test.js +++ b/test/integration/404-page/test/index.test.js @@ -70,15 +70,18 @@ const runTests = (mode = 'server') => { } describe('404 Page Support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests('dev') - }) + runTests('dev') + } + ) describe('development mode 2', () => { it('falls back to _error correctly without pages/404', async () => { await fs.move(pages404, `${pages404}.bak`) diff --git a/test/integration/500-page/test/gsp-gssp.test.js b/test/integration/500-page/test/gsp-gssp.test.js index 10ac6a3ffcd84..2e65116210fdc 100644 --- a/test/integration/500-page/test/gsp-gssp.test.js +++ b/test/integration/500-page/test/gsp-gssp.test.js @@ -183,64 +183,66 @@ describe('gsp-gssp', () => { }) } ) - - describe('development mode', () => { - it('does not show error with getStaticProps in pages/500 dev', async () => { - await fs.move(pages500, `${pages500}.bak`) - await fs.writeFile( - pages500, - ` + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('does not show error with getStaticProps in pages/500 dev', async () => { + await fs.move(pages500, `${pages500}.bak`) + await fs.writeFile( + pages500, + ` const page = () => 'custom 500 page' export const getStaticProps = () => ({ props: { a: 'b' } }) export default page ` - ) - - let stderr = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg || '' - }, - }) - await renderViaHTTP(appPort, '/abc') - await waitFor(1000) + ) - await killApp(app) + let stderr = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg || '' + }, + }) + await renderViaHTTP(appPort, '/abc') + await waitFor(1000) - await fs.remove(pages500) - await fs.move(`${pages500}.bak`, pages500) + await killApp(app) - expect(stderr).not.toMatch(gip500Err) - }) + await fs.remove(pages500) + await fs.move(`${pages500}.bak`, pages500) - it('shows error with getServerSideProps in pages/500 dev', async () => { - await fs.move(pages500, `${pages500}.bak`) - await fs.writeFile( - pages500, - ` + expect(stderr).not.toMatch(gip500Err) + }) + + it('shows error with getServerSideProps in pages/500 dev', async () => { + await fs.move(pages500, `${pages500}.bak`) + await fs.writeFile( + pages500, + ` const page = () => 'custom 500 page' export const getServerSideProps = () => ({ props: { a: 'b' } }) export default page ` - ) - - let stderr = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg || '' - }, - }) - await renderViaHTTP(appPort, '/500') - await waitFor(1000) + ) + + let stderr = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg || '' + }, + }) + await renderViaHTTP(appPort, '/500') + await waitFor(1000) - await killApp(app) + await killApp(app) - await fs.remove(pages500) - await fs.move(`${pages500}.bak`, pages500) + await fs.remove(pages500) + await fs.move(`${pages500}.bak`, pages500) - expect(stderr).toMatch(gip500Err) - }) - }) + expect(stderr).toMatch(gip500Err) + }) + } + ) }) diff --git a/test/integration/500-page/test/index.test.js b/test/integration/500-page/test/index.test.js index f33cae20c8271..ccc64bc84b10e 100644 --- a/test/integration/500-page/test/index.test.js +++ b/test/integration/500-page/test/index.test.js @@ -60,16 +60,19 @@ const runTests = (mode = 'server') => { } describe('500 Page Support', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests('dev') - }) + runTests('dev') + } + ) describe('development mode 2', () => { it('shows error with getInitialProps in pages/500 dev', async () => { await fs.move(pages500, `${pages500}.bak`) diff --git a/test/integration/amphtml-custom-validator/test/index.test.js b/test/integration/amphtml-custom-validator/test/index.test.js index 54d3c3a76183d..ac5d128ab5253 100644 --- a/test/integration/amphtml-custom-validator/test/index.test.js +++ b/test/integration/amphtml-custom-validator/test/index.test.js @@ -35,24 +35,26 @@ const appDir = join(__dirname, '../') }) } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('should run in development mode successfully', async () => { + let stderr = '' - describe('development mode', () => { - it('should run in development mode successfully', async () => { - let stderr = '' - - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg || '' - }, - }) + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg || '' + }, + }) - const html = await renderViaHTTP(appPort, '/') - await killApp(app) + const html = await renderViaHTTP(appPort, '/') + await killApp(app) - expect(stderr).not.toContain('error') - expect(html).toContain('Hello from AMP') - }) - }) + expect(stderr).not.toContain('error') + expect(html).toContain('Hello from AMP') + }) + } + ) } ) diff --git a/test/integration/amphtml-ssg/test/index.test.js b/test/integration/amphtml-ssg/test/index.test.js index 03f773739af39..dbee797d452f1 100644 --- a/test/integration/amphtml-ssg/test/index.test.js +++ b/test/integration/amphtml-ssg/test/index.test.js @@ -113,14 +113,17 @@ describe('AMP SSG Support', () => { runTests() } ) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) describe('export mode', () => { ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', diff --git a/test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts b/test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts index c5c23a71e5fcd..3c436a4d4e90c 100644 --- a/test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts +++ b/test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts @@ -1,25 +1,28 @@ import { runTests } from './utils' describe('app dir - with output export - dynamic missing gsp dev', () => { - describe('development mode', () => { - it('should error when dynamic route is missing generateStaticParams', async () => { - await runTests({ - isDev: true, - dynamicPage: 'undefined', - generateStaticParamsOpt: 'set noop', - expectedErrMsg: - 'Page "/another/[slug]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config.', + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('should error when dynamic route is missing generateStaticParams', async () => { + await runTests({ + isDev: true, + dynamicPage: 'undefined', + generateStaticParamsOpt: 'set noop', + expectedErrMsg: + 'Page "/another/[slug]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config.', + }) }) - }) - it('should error when client component has generateStaticParams', async () => { - await runTests({ - isDev: true, - dynamicPage: 'undefined', - generateStaticParamsOpt: 'set client', - expectedErrMsg: - 'Page "/another/[slug]/page" cannot use both "use client" and export function "generateStaticParams()".', + it('should error when client component has generateStaticParams', async () => { + await runTests({ + isDev: true, + dynamicPage: 'undefined', + generateStaticParamsOpt: 'set client', + expectedErrMsg: + 'Page "/another/[slug]/page" cannot use both "use client" and export function "generateStaticParams()".', + }) }) - }) - }) + } + ) }) diff --git a/test/integration/app-dir-export/test/dynamicapiroute-dev.test.ts b/test/integration/app-dir-export/test/dynamicapiroute-dev.test.ts index f860cd0021ba4..a0e968e45bd78 100644 --- a/test/integration/app-dir-export/test/dynamicapiroute-dev.test.ts +++ b/test/integration/app-dir-export/test/dynamicapiroute-dev.test.ts @@ -1,21 +1,24 @@ import { runTests } from './utils' describe('app dir - with output export - dynamic api route dev', () => { - describe('development mode', () => { - it.each([ - { dynamicApiRoute: 'undefined' }, - { dynamicApiRoute: "'error'" }, - { dynamicApiRoute: "'force-static'" }, - { - dynamicApiRoute: "'force-dynamic'", - expectedErrMsg: - 'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".', - }, - ])( - 'should work in dev with dynamicApiRoute $dynamicApiRoute', - async ({ dynamicApiRoute, expectedErrMsg }) => { - await runTests({ isDev: true, dynamicApiRoute, expectedErrMsg }) - } - ) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it.each([ + { dynamicApiRoute: 'undefined' }, + { dynamicApiRoute: "'error'" }, + { dynamicApiRoute: "'force-static'" }, + { + dynamicApiRoute: "'force-dynamic'", + expectedErrMsg: + 'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".', + }, + ])( + 'should work in dev with dynamicApiRoute $dynamicApiRoute', + async ({ dynamicApiRoute, expectedErrMsg }) => { + await runTests({ isDev: true, dynamicApiRoute, expectedErrMsg }) + } + ) + } + ) }) diff --git a/test/integration/app-dir-export/test/dynamicpage-dev.test.ts b/test/integration/app-dir-export/test/dynamicpage-dev.test.ts index 74ea4a7c308c3..0220d9c28e298 100644 --- a/test/integration/app-dir-export/test/dynamicpage-dev.test.ts +++ b/test/integration/app-dir-export/test/dynamicpage-dev.test.ts @@ -1,21 +1,24 @@ import { runTests } from './utils' describe('app dir - with output export - dynamic page dev', () => { - describe('development mode', () => { - it.each([ - { dynamicPage: 'undefined' }, - { dynamicPage: "'error'" }, - { dynamicPage: "'force-static'" }, - { - dynamicPage: "'force-dynamic'", - expectedErrMsg: - 'Page with `dynamic = "force-dynamic"` couldn\'t be exported. `output: "export"` requires all pages be renderable statically', - }, - ])( - 'should work in dev with dynamicPage $dynamicPage', - async ({ dynamicPage, expectedErrMsg }) => { - await runTests({ isDev: true, dynamicPage, expectedErrMsg }) - } - ) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it.each([ + { dynamicPage: 'undefined' }, + { dynamicPage: "'error'" }, + { dynamicPage: "'force-static'" }, + { + dynamicPage: "'force-dynamic'", + expectedErrMsg: + 'Page with `dynamic = "force-dynamic"` couldn\'t be exported. `output: "export"` requires all pages be renderable statically', + }, + ])( + 'should work in dev with dynamicPage $dynamicPage', + async ({ dynamicPage, expectedErrMsg }) => { + await runTests({ isDev: true, dynamicPage, expectedErrMsg }) + } + ) + } + ) }) diff --git a/test/integration/app-dir-export/test/trailing-slash-dev.test.ts b/test/integration/app-dir-export/test/trailing-slash-dev.test.ts index e60383fa10078..e0d8c6a3dc0aa 100644 --- a/test/integration/app-dir-export/test/trailing-slash-dev.test.ts +++ b/test/integration/app-dir-export/test/trailing-slash-dev.test.ts @@ -1,12 +1,15 @@ import { runTests } from './utils' describe('app dir - with output export - trailing slash dev', () => { - describe('development mode', () => { - it.each([{ trailingSlash: false }, { trailingSlash: true }])( - "should work in dev with trailingSlash '$trailingSlash'", - async ({ trailingSlash }) => { - await runTests({ isDev: true, trailingSlash }) - } - ) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it.each([{ trailingSlash: false }, { trailingSlash: true }])( + "should work in dev with trailingSlash '$trailingSlash'", + async ({ trailingSlash }) => { + await runTests({ isDev: true, trailingSlash }) + } + ) + } + ) }) diff --git a/test/integration/app-document-import-order/test/index.test.js b/test/integration/app-document-import-order/test/index.test.js index 103b3d561601a..f0f597369a835 100644 --- a/test/integration/app-document-import-order/test/index.test.js +++ b/test/integration/app-document-import-order/test/index.test.js @@ -72,28 +72,30 @@ describe('Root components import order', () => { } ) }) +;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(join(__dirname, '../'), appPort) + }) + + afterAll(() => killApp(app)) + + it( + 'root components should be imported in this order _document > _app > page in order to respect side effects', + respectsSideEffects + ) -describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(join(__dirname, '../'), appPort) - }) - - afterAll(() => killApp(app)) - - it( - 'root components should be imported in this order _document > _app > page in order to respect side effects', - respectsSideEffects - ) - - // Test relies on webpack splitChunks overrides. - ;(process.env.TURBOPACK ? describe.skip : describe)( - 'Skipped in Turbopack', - () => { - it( - '_app chunks should be attached to de dom before page chunks', - respectsChunkAttachmentOrder - ) - } - ) -}) + // Test relies on webpack splitChunks overrides. + ;(process.env.TURBOPACK ? describe.skip : describe)( + 'Skipped in Turbopack', + () => { + it( + '_app chunks should be attached to de dom before page chunks', + respectsChunkAttachmentOrder + ) + } + ) + } +) diff --git a/test/integration/app-tree/test/index.test.js b/test/integration/app-tree/test/index.test.js index d8ed0a28d4c8e..8cc5814e64dd3 100644 --- a/test/integration/app-tree/test/index.test.js +++ b/test/integration/app-tree/test/index.test.js @@ -48,14 +48,17 @@ const runTests = () => { } describe('AppTree', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/async-modules/test/index.test.js b/test/integration/async-modules/test/index.test.js index 64b9cb1909e91..705ae47aeb797 100644 --- a/test/integration/async-modules/test/index.test.js +++ b/test/integration/async-modules/test/index.test.js @@ -104,17 +104,20 @@ function runTests(dev = false) { } describe('Async modules', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/bigint/test/index.test.js b/test/integration/bigint/test/index.test.js index a26ca956abca6..6924b2779fc8e 100644 --- a/test/integration/bigint/test/index.test.js +++ b/test/integration/bigint/test/index.test.js @@ -33,15 +33,18 @@ const runTests = () => { } describe('bigint API route support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/catches-missing-getStaticProps/test/index.test.js b/test/integration/catches-missing-getStaticProps/test/index.test.js index f8132f40ad7a5..ba34fdeaf9912 100644 --- a/test/integration/catches-missing-getStaticProps/test/index.test.js +++ b/test/integration/catches-missing-getStaticProps/test/index.test.js @@ -13,16 +13,19 @@ const appDir = join(__dirname, '../') const errorRegex = /getStaticPaths was added without a getStaticProps in/ describe('Catches Missing getStaticProps', () => { - describe('development mode', () => { - it('should catch it in development mode', async () => { - const appPort = await findPort() - const app = await launchApp(appDir, appPort) - const html = await renderViaHTTP(appPort, '/hello') - await killApp(app) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('should catch it in development mode', async () => { + const appPort = await findPort() + const app = await launchApp(appDir, appPort) + const html = await renderViaHTTP(appPort, '/hello') + await killApp(app) - expect(html).toMatch(errorRegex) - }) - }) + expect(html).toMatch(errorRegex) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/client-404/test/index.test.js b/test/integration/client-404/test/index.test.js index c7a1c1673ac44..ab8004c861a69 100644 --- a/test/integration/client-404/test/index.test.js +++ b/test/integration/client-404/test/index.test.js @@ -23,18 +23,21 @@ const runTests = (isProd = false) => { } describe('Client 404', () => { - describe('development mode', () => { - beforeAll(async () => { - context.appPort = await findPort() - context.server = await launchApp(appDir, context.appPort) - - // pre-build page at the start - await renderViaHTTP(context.appPort, '/') - }) - afterAll(() => killApp(context.server)) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + context.appPort = await findPort() + context.server = await launchApp(appDir, context.appPort) + + // pre-build page at the start + await renderViaHTTP(context.appPort, '/') + }) + afterAll(() => killApp(context.server)) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/client-shallow-routing/test/index.test.js b/test/integration/client-shallow-routing/test/index.test.js index d74f1f6e99203..5c1b4d0dfb451 100644 --- a/test/integration/client-shallow-routing/test/index.test.js +++ b/test/integration/client-shallow-routing/test/index.test.js @@ -88,15 +88,18 @@ const runTests = () => { } describe('Client Shallow Routing', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/conflicting-public-file-page/test/index.test.js b/test/integration/conflicting-public-file-page/test/index.test.js index fed51224e51de..0140b05f49eb4 100644 --- a/test/integration/conflicting-public-file-page/test/index.test.js +++ b/test/integration/conflicting-public-file-page/test/index.test.js @@ -12,21 +12,24 @@ import { const appDir = path.join(__dirname, '..') describe('Errors on conflict between public file and page file', () => { - describe('development mode', () => { - it('Throws error during development', async () => { - const appPort = await findPort() - const app = await launchApp(appDir, appPort) - const conflicts = ['/another/conflict', '/hello'] + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('Throws error during development', async () => { + const appPort = await findPort() + const app = await launchApp(appDir, appPort) + const conflicts = ['/another/conflict', '/hello'] - for (const conflict of conflicts) { - const html = await renderViaHTTP(appPort, conflict) - expect(html).toMatch( - /A conflicting public file and page file was found for path/ - ) - } - await killApp(app) - }) - }) + for (const conflict of conflicts) { + const html = await renderViaHTTP(appPort, conflict) + expect(html).toMatch( + /A conflicting public file and page file was found for path/ + ) + } + await killApp(app) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/css/test/css-modules.test.js b/test/integration/css/test/css-modules.test.js index 00e8487e97002..90b19b8824843 100644 --- a/test/integration/css/test/css-modules.test.js +++ b/test/integration/css/test/css-modules.test.js @@ -509,20 +509,23 @@ module.exports = { }) } - describe('Development Mode', () => { - beforeAll(async () => { - await remove(join(appDir, '.next')) - }) - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await remove(join(appDir, '.next')) + }) + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - tests(true) - }) + tests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/custom-page-extension/test/index.test.js b/test/integration/custom-page-extension/test/index.test.js index 2450085644235..ba045d4efc9d6 100644 --- a/test/integration/custom-page-extension/test/index.test.js +++ b/test/integration/custom-page-extension/test/index.test.js @@ -27,14 +27,17 @@ const runTests = () => { } describe('Custom page extension', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/custom-routes-catchall/test/index.test.js b/test/integration/custom-routes-catchall/test/index.test.js index cc83de23db1d1..aa9beb92dd489 100644 --- a/test/integration/custom-routes-catchall/test/index.test.js +++ b/test/integration/custom-routes-catchall/test/index.test.js @@ -44,15 +44,18 @@ const runTests = () => { } describe('Custom routes', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - buildId = 'development' - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + buildId = 'development' + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/custom-routes-i18n-index-redirect/test/index.test.js b/test/integration/custom-routes-i18n-index-redirect/test/index.test.js index 95792dfb1a2e5..4317d5c2d5229 100644 --- a/test/integration/custom-routes-i18n-index-redirect/test/index.test.js +++ b/test/integration/custom-routes-i18n-index-redirect/test/index.test.js @@ -60,15 +60,17 @@ describe('Custom routes i18n with index redirect', () => { afterAll(async () => { server.close() }) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/custom-routes-i18n/test/index.test.js b/test/integration/custom-routes-i18n/test/index.test.js index 0bb9641f00770..3d20b4ff8f96d 100644 --- a/test/integration/custom-routes-i18n/test/index.test.js +++ b/test/integration/custom-routes-i18n/test/index.test.js @@ -167,15 +167,17 @@ describe('Custom routes i18n', () => { server.close() nextConfig.restore() }) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/custom-routes/test/index.test.js b/test/integration/custom-routes/test/index.test.js index 43092ea79dded..5c630efa4570e 100644 --- a/test/integration/custom-routes/test/index.test.js +++ b/test/integration/custom-routes/test/index.test.js @@ -2635,37 +2635,39 @@ describe('Custom routes', () => { externalServer.close() await fs.writeFile(nextConfigPath, nextConfigRestoreContent) }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let nextConfigContent - describe('development mode', () => { - let nextConfigContent - - beforeAll(async () => { - // ensure cache with rewrites disabled doesn't persist - // after enabling rewrites - await fs.remove(join(appDir, '.next')) - nextConfigContent = await fs.readFile(nextConfigPath, 'utf8') - await fs.writeFile( - nextConfigPath, - nextConfigContent.replace('// no-rewrites comment', 'return []') - ) + beforeAll(async () => { + // ensure cache with rewrites disabled doesn't persist + // after enabling rewrites + await fs.remove(join(appDir, '.next')) + nextConfigContent = await fs.readFile(nextConfigPath, 'utf8') + await fs.writeFile( + nextConfigPath, + nextConfigContent.replace('// no-rewrites comment', 'return []') + ) - const tempPort = await findPort() - const tempApp = await launchApp(appDir, tempPort) - await renderViaHTTP(tempPort, '/') + const tempPort = await findPort() + const tempApp = await launchApp(appDir, tempPort) + await renderViaHTTP(tempPort, '/') - await killApp(tempApp) - await fs.writeFile(nextConfigPath, nextConfigContent) + await killApp(tempApp) + await fs.writeFile(nextConfigPath, nextConfigContent) - appPort = await findPort() - app = await launchApp(appDir, appPort) - buildId = 'development' - }) - afterAll(async () => { - await fs.writeFile(nextConfigPath, nextConfigContent) - await killApp(app) - }) - runTests(true) - }) + appPort = await findPort() + app = await launchApp(appDir, appPort) + buildId = 'development' + }) + afterAll(async () => { + await fs.writeFile(nextConfigPath, nextConfigContent) + await killApp(app) + }) + runTests(true) + } + ) describe('no-op rewrite', () => { beforeAll(async () => { @@ -2810,9 +2812,12 @@ describe('Custom routes', () => { }) } - describe('development mode', () => { - runSoloTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + runSoloTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/data-fetching-errors/test/index.test.js b/test/integration/data-fetching-errors/test/index.test.js index 33062cb3a39f8..05e2fee035ba8 100644 --- a/test/integration/data-fetching-errors/test/index.test.js +++ b/test/integration/data-fetching-errors/test/index.test.js @@ -128,10 +128,12 @@ describe('GS(S)P Page Errors', () => { origIndexPage = await fs.readFile(indexPage, 'utf8') }) afterAll(() => fs.writeFile(indexPage, origIndexPage)) - - describe('development mode', () => { - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/disable-js/test/index.test.js b/test/integration/disable-js/test/index.test.js index 2d2dca111c15a..e291d3295f4ae 100644 --- a/test/integration/disable-js/test/index.test.js +++ b/test/integration/disable-js/test/index.test.js @@ -56,38 +56,42 @@ describe('disabled runtime JS', () => { }) } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let appPort + let app - describe('development mode', () => { - let appPort - let app - - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(join(__dirname, '../'), appPort) - }) + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(join(__dirname, '../'), appPort) + }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should render the page', async () => { - const html = await renderViaHTTP(appPort, '/') - expect(html).toMatch(/Hello World/) - }) + // eslint-disable-next-line jest/no-identical-title + it('should render the page', async () => { + const html = await renderViaHTTP(appPort, '/') + expect(html).toMatch(/Hello World/) + }) - it('should not have __NEXT_DATA__ script', async () => { - const html = await renderViaHTTP(appPort, '/') + // eslint-disable-next-line jest/no-identical-title + it('should not have __NEXT_DATA__ script', async () => { + const html = await renderViaHTTP(appPort, '/') - const $ = cheerio.load(html) - expect($('script#__NEXT_DATA__').length).toBe(1) - }) + const $ = cheerio.load(html) + expect($('script#__NEXT_DATA__').length).toBe(1) + }) - it('should have a script for each preload link', async () => { - const html = await renderViaHTTP(appPort, '/') - const $ = cheerio.load(html) - const preloadLinks = $('link[rel=preload]') - preloadLinks.each((idx, element) => { - const url = $(element).attr('href') - expect($(`script[src="${url}"]`).length).toBe(1) + it('should have a script for each preload link', async () => { + const html = await renderViaHTTP(appPort, '/') + const $ = cheerio.load(html) + const preloadLinks = $('link[rel=preload]') + preloadLinks.each((idx, element) => { + const url = $(element).attr('href') + expect($(`script[src="${url}"]`).length).toBe(1) + }) }) - }) - }) + } + ) }) diff --git a/test/integration/dist-dir/test/index.test.js b/test/integration/dist-dir/test/index.test.js index b331722f3ec72..93e06e5f16d7a 100644 --- a/test/integration/dist-dir/test/index.test.js +++ b/test/integration/dist-dir/test/index.test.js @@ -47,30 +47,32 @@ describe('distDir', () => { } ) }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + await fs.remove(join(appDir, 'dist')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - await fs.remove(join(appDir, 'dist')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - it('should render the page', async () => { - const html = await renderViaHTTP(appPort, '/') - expect(html).toMatch(/Hello World/) - }) + it('should render the page', async () => { + const html = await renderViaHTTP(appPort, '/') + expect(html).toMatch(/Hello World/) + }) - it('should build the app within the given `dist` directory', async () => { - expect( - await fs.exists(join(__dirname, `/../dist/${BUILD_MANIFEST}`)) - ).toBeTruthy() - }) - it('should not build the app within the default `.next` directory', async () => { - expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy() - }) - }) + it('should build the app within the given `dist` directory', async () => { + expect( + await fs.exists(join(__dirname, `/../dist/${BUILD_MANIFEST}`)) + ).toBeTruthy() + }) + it('should not build the app within the default `.next` directory', async () => { + expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy() + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/document-head-warnings/test/index.test.js b/test/integration/document-head-warnings/test/index.test.js index f94017e2944cd..a005425dcfc13 100644 --- a/test/integration/document-head-warnings/test/index.test.js +++ b/test/integration/document-head-warnings/test/index.test.js @@ -19,24 +19,26 @@ describe('Custom Document Head Warnings', () => { await renderViaHTTP(appPort, '/') await killApp(app) }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('warns when using a in document/head', () => { + expect(output).toMatch( + /.*Warning: <title> should not be used in _document.js's <Head>\..*/ + ) + }) - describe('development mode', () => { - it('warns when using a <title> in document/head', () => { - expect(output).toMatch( - /.*Warning: <title> should not be used in _document.js's <Head>\..*/ - ) - }) - - it('warns when using viewport meta tags in document/head', () => { - expect(output).toMatch( - /.*Warning: viewport meta tags should not be used in _document.js's <Head>\..*/ - ) - }) + it('warns when using viewport meta tags in document/head', () => { + expect(output).toMatch( + /.*Warning: viewport meta tags should not be used in _document.js's <Head>\..*/ + ) + }) - it('warns when using a crossOrigin attribute on document/head', () => { - expect(output).toMatch( - /.*Warning: `Head` attribute `crossOrigin` is deprecated\..*/ - ) - }) - }) + it('warns when using a crossOrigin attribute on document/head', () => { + expect(output).toMatch( + /.*Warning: `Head` attribute `crossOrigin` is deprecated\..*/ + ) + }) + } + ) }) diff --git a/test/integration/draft-mode/test/index.test.ts b/test/integration/draft-mode/test/index.test.ts index 52aaaef2615a7..20d365e75c811 100644 --- a/test/integration/draft-mode/test/index.test.ts +++ b/test/integration/draft-mode/test/index.test.ts @@ -32,91 +32,94 @@ function getData(html: string) { } describe('Test Draft Mode', () => { - describe('Development Mode', () => { - let appPort, app, browser, cookieString - it('should start development application', async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - - it('should enable draft mode', async () => { - const res = await fetchViaHTTP(appPort, '/api/enable') - expect(res.status).toBe(200) - - const cookies = res.headers - .get('set-cookie') - .split(',') - .map((c) => cookie.parse(c)) - - expect(cookies[0]).toBeTruthy() - expect(cookies[0].__prerender_bypass).toBeTruthy() - cookieString = cookie.serialize( - '__prerender_bypass', - cookies[0].__prerender_bypass - ) - }) - - it('should return cookies to be expired after dev server reboot', async () => { - await killApp(app) - appPort = await findPort() - app = await launchApp(appDir, appPort) - - const res = await fetchViaHTTP( - appPort, - '/', - {}, - { headers: { Cookie: cookieString } } - ) - expect(res.status).toBe(200) - - const body = await res.text() - // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('"err"') - expect(body).not.toContain('TypeError') - expect(body).not.toContain('previewModeId') - - const cookies = res.headers - .get('set-cookie') - .replace(/(=(?!Lax)\w{3}),/g, '$1') - .split(',') - .map((c) => cookie.parse(c)) - - expect(cookies[0]).toBeTruthy() - }) - - it('should start the client-side browser', async () => { - browser = await webdriver(appPort, '/api/enable') - }) - - it('should fetch draft data on SSR', async () => { - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#draft') - expect(await browser.elementById('draft').text()).toBe('true') - }) - - it('should fetch draft data on CST', async () => { - await browser.get(`http://localhost:${appPort}/to-index`) - await browser.waitForElementByCss('#to-index') - await browser.eval('window.itdidnotrefresh = "yep"') - await browser.elementById('to-index').click() - await browser.waitForElementByCss('#draft') - expect(await browser.eval('window.itdidnotrefresh')).toBe('yep') - expect(await browser.elementById('draft').text()).toBe('true') - }) - - it('should disable draft mode', async () => { - await browser.get(`http://localhost:${appPort}/api/disable`) - - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#draft') - expect(await browser.elementById('draft').text()).toBe('false') - }) - - afterAll(async () => { - await browser.close() - await killApp(app) - }) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let appPort, app, browser, cookieString + it('should start development application', async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + + it('should enable draft mode', async () => { + const res = await fetchViaHTTP(appPort, '/api/enable') + expect(res.status).toBe(200) + + const cookies = res.headers + .get('set-cookie') + .split(',') + .map((c) => cookie.parse(c)) + + expect(cookies[0]).toBeTruthy() + expect(cookies[0].__prerender_bypass).toBeTruthy() + cookieString = cookie.serialize( + '__prerender_bypass', + cookies[0].__prerender_bypass + ) + }) + + it('should return cookies to be expired after dev server reboot', async () => { + await killApp(app) + appPort = await findPort() + app = await launchApp(appDir, appPort) + + const res = await fetchViaHTTP( + appPort, + '/', + {}, + { headers: { Cookie: cookieString } } + ) + expect(res.status).toBe(200) + + const body = await res.text() + // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" + expect(body).not.toContain('"err"') + expect(body).not.toContain('TypeError') + expect(body).not.toContain('previewModeId') + + const cookies = res.headers + .get('set-cookie') + .replace(/(=(?!Lax)\w{3}),/g, '$1') + .split(',') + .map((c) => cookie.parse(c)) + + expect(cookies[0]).toBeTruthy() + }) + + it('should start the client-side browser', async () => { + browser = await webdriver(appPort, '/api/enable') + }) + + it('should fetch draft data on SSR', async () => { + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#draft') + expect(await browser.elementById('draft').text()).toBe('true') + }) + + it('should fetch draft data on CST', async () => { + await browser.get(`http://localhost:${appPort}/to-index`) + await browser.waitForElementByCss('#to-index') + await browser.eval('window.itdidnotrefresh = "yep"') + await browser.elementById('to-index').click() + await browser.waitForElementByCss('#draft') + expect(await browser.eval('window.itdidnotrefresh')).toBe('yep') + expect(await browser.elementById('draft').text()).toBe('true') + }) + + it('should disable draft mode', async () => { + await browser.get(`http://localhost:${appPort}/api/disable`) + + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#draft') + expect(await browser.elementById('draft').text()).toBe('false') + }) + + afterAll(async () => { + await browser.close() + await killApp(app) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -153,6 +156,7 @@ describe('Test Draft Mode', () => { expect(rand).toBe(initialRand) }) + // eslint-disable-next-line jest/no-identical-title it('should enable draft mode', async () => { const res = await fetchViaHTTP(appPort, '/api/enable') expect(res.status).toBe(200) diff --git a/test/integration/dynamic-optional-routing-root-fallback/test/index.test.js b/test/integration/dynamic-optional-routing-root-fallback/test/index.test.js index 7b021693008ba..19a174f6ee77f 100644 --- a/test/integration/dynamic-optional-routing-root-fallback/test/index.test.js +++ b/test/integration/dynamic-optional-routing-root-fallback/test/index.test.js @@ -51,17 +51,20 @@ function runTests() { const nextConfig = join(appDir, 'next.config.js') describe('Dynamic Optional Routing Root Fallback', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/dynamic-optional-routing-root-static-paths/test/index.test.js b/test/integration/dynamic-optional-routing-root-static-paths/test/index.test.js index 1bc8a7c647455..9b3fe1de5e723 100644 --- a/test/integration/dynamic-optional-routing-root-static-paths/test/index.test.js +++ b/test/integration/dynamic-optional-routing-root-static-paths/test/index.test.js @@ -39,15 +39,18 @@ function runTests() { const nextConfig = join(appDir, 'next.config.js') describe('Dynamic Optional Routing', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/dynamic-optional-routing/test/index.test.js b/test/integration/dynamic-optional-routing/test/index.test.js index 031d1318dba12..fd93a7c1bb062 100644 --- a/test/integration/dynamic-optional-routing/test/index.test.js +++ b/test/integration/dynamic-optional-routing/test/index.test.js @@ -237,24 +237,27 @@ function runInvalidPagesTests(buildFn) { } describe('Dynamic Optional Routing', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - - runInvalidPagesTests(async (appDir) => { - stderr = '' - await launchApp(appDir, await findPort(), { - onStderr: (msg) => { - stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) }) - }) - }) + afterAll(() => killApp(app)) + + runTests() + + runInvalidPagesTests(async (appDir) => { + stderr = '' + await launchApp(appDir, await findPort(), { + onStderr: (msg) => { + stderr += msg + }, + }) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/dynamic-routing/test/index.test.js b/test/integration/dynamic-routing/test/index.test.js index 4b0882053b13f..f2d460d1026ce 100644 --- a/test/integration/dynamic-routing/test/index.test.js +++ b/test/integration/dynamic-routing/test/index.test.js @@ -1579,18 +1579,21 @@ describe('Dynamic Routing', () => { afterAll(() => fs.remove(middlewarePath)) } - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(nextConfig) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(nextConfig) - appPort = await findPort() - app = await launchApp(appDir, appPort) - buildId = 'development' - }) - afterAll(() => killApp(app)) + appPort = await findPort() + app = await launchApp(appDir, appPort) + buildId = 'development' + }) + afterAll(() => killApp(app)) - runTests({ dev: true }) - }) + runTests({ dev: true }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/edge-runtime-dynamic-code/test/index.test.js b/test/integration/edge-runtime-dynamic-code/test/index.test.js index 98581f9d3ee36..a93b4b59999da 100644 --- a/test/integration/edge-runtime-dynamic-code/test/index.test.js +++ b/test/integration/edge-runtime-dynamic-code/test/index.test.js @@ -74,90 +74,93 @@ describe.each([ ])( '$title usage of dynamic code evaluation', ({ extractValue, computeRoute }) => { - describe('development mode', () => { - let output = '' - - beforeAll(async () => { - context.appPort = await findPort() - context.app = await launchApp(context.appDir, context.appPort, { - env: { __NEXT_TEST_WITH_DEVTOOL: 1 }, - onStdout(msg) { - output += msg - }, - onStderr(msg) { - output += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let output = '' + + beforeAll(async () => { + context.appPort = await findPort() + context.app = await launchApp(context.appDir, context.appPort, { + env: { __NEXT_TEST_WITH_DEVTOOL: 1 }, + onStdout(msg) { + output += msg + }, + onStderr(msg) { + output += msg + }, + }) }) - }) - - beforeEach(() => (output = '')) - afterAll(() => killApp(context.app)) - - it('shows a warning when running code with eval', async () => { - const res = await fetchViaHTTP( - context.appPort, - computeRoute('using-eval') - ) - expect(await extractValue(res)).toEqual(100) - await waitFor(500) - expect(output).toContain(EVAL_ERROR) - // TODO check why that has a backslash on windows - expect(output).toMatch(/lib[\\/]utils\.js/) - expect(output).toContain('usingEval') - expect(stripAnsi(output)).toContain("value: eval('100')") - }) - - it('does not show warning when no code uses eval', async () => { - const res = await fetchViaHTTP( - context.appPort, - computeRoute('not-using-eval') - ) - expect(await extractValue(res)).toEqual(100) - await waitFor(500) - expect(output).not.toContain('Dynamic Code Evaluation') - }) - - it('shows a warning when running WebAssembly.compile', async () => { - const res = await fetchViaHTTP( - context.appPort, - computeRoute('using-webassembly-compile') - ) - expect(await extractValue(res)).toEqual(81) - await waitFor(500) - expect(output).toContain(WASM_COMPILE_ERROR) - expect(output).toMatch(/lib[\\/]wasm\.js/) - expect(output).toContain('usingWebAssemblyCompile') - expect(stripAnsi(output)).toContain( - 'await WebAssembly.compile(SQUARE_WASM_BUFFER)' - ) - }) - - it('shows a warning when running WebAssembly.instantiate with a buffer parameter', async () => { - const res = await fetchViaHTTP( - context.appPort, - computeRoute('using-webassembly-instantiate-with-buffer') - ) - expect(await extractValue(res)).toEqual(81) - await waitFor(500) - expect(output).toContain(WASM_INSTANTIATE_ERROR) - expect(output).toMatch(/lib[\\/]wasm\.js/) - expect(output).toContain('usingWebAssemblyInstantiateWithBuffer') - expect(stripAnsi(output)).toContain( - 'await WebAssembly.instantiate(SQUARE_WASM_BUFFER, {})' - ) - }) - - it('does not show a warning when running WebAssembly.instantiate with a module parameter', async () => { - const res = await fetchViaHTTP( - context.appPort, - computeRoute('using-webassembly-instantiate') - ) - expect(await extractValue(res)).toEqual(81) - await waitFor(500) - expect(output).not.toContain(WASM_INSTANTIATE_ERROR) - expect(output).not.toContain('DynamicWasmCodeGenerationWarning') - }) - }) + + beforeEach(() => (output = '')) + afterAll(() => killApp(context.app)) + + it('shows a warning when running code with eval', async () => { + const res = await fetchViaHTTP( + context.appPort, + computeRoute('using-eval') + ) + expect(await extractValue(res)).toEqual(100) + await waitFor(500) + expect(output).toContain(EVAL_ERROR) + // TODO check why that has a backslash on windows + expect(output).toMatch(/lib[\\/]utils\.js/) + expect(output).toContain('usingEval') + expect(stripAnsi(output)).toContain("value: eval('100')") + }) + + it('does not show warning when no code uses eval', async () => { + const res = await fetchViaHTTP( + context.appPort, + computeRoute('not-using-eval') + ) + expect(await extractValue(res)).toEqual(100) + await waitFor(500) + expect(output).not.toContain('Dynamic Code Evaluation') + }) + + it('shows a warning when running WebAssembly.compile', async () => { + const res = await fetchViaHTTP( + context.appPort, + computeRoute('using-webassembly-compile') + ) + expect(await extractValue(res)).toEqual(81) + await waitFor(500) + expect(output).toContain(WASM_COMPILE_ERROR) + expect(output).toMatch(/lib[\\/]wasm\.js/) + expect(output).toContain('usingWebAssemblyCompile') + expect(stripAnsi(output)).toContain( + 'await WebAssembly.compile(SQUARE_WASM_BUFFER)' + ) + }) + + it('shows a warning when running WebAssembly.instantiate with a buffer parameter', async () => { + const res = await fetchViaHTTP( + context.appPort, + computeRoute('using-webassembly-instantiate-with-buffer') + ) + expect(await extractValue(res)).toEqual(81) + await waitFor(500) + expect(output).toContain(WASM_INSTANTIATE_ERROR) + expect(output).toMatch(/lib[\\/]wasm\.js/) + expect(output).toContain('usingWebAssemblyInstantiateWithBuffer') + expect(stripAnsi(output)).toContain( + 'await WebAssembly.instantiate(SQUARE_WASM_BUFFER, {})' + ) + }) + + it('does not show a warning when running WebAssembly.instantiate with a module parameter', async () => { + const res = await fetchViaHTTP( + context.appPort, + computeRoute('using-webassembly-instantiate') + ) + expect(await extractValue(res)).toEqual(81) + await waitFor(500) + expect(output).not.toContain(WASM_INSTANTIATE_ERROR) + expect(output).not.toContain('DynamicWasmCodeGenerationWarning') + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/edge-runtime-module-errors/test/index.test.js b/test/integration/edge-runtime-module-errors/test/index.test.js index f8282e8fe142a..eab8dc9e93331 100644 --- a/test/integration/edge-runtime-module-errors/test/index.test.js +++ b/test/integration/edge-runtime-module-errors/test/index.test.js @@ -82,25 +82,27 @@ describe('Edge runtime code with imports', () => { const importStatement = `await import("${moduleName}")` beforeEach(() => init(importStatement)) - - describe('development mode', () => { - it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => { - context.app = await launchApp( - context.appDir, - context.appPort, - appOption - ) - await retry(async () => { - const res = await fetchViaHTTP(context.appPort, url) - expect(res.status).toBe(500) - expectUnsupportedModuleDevError( - moduleName, - importStatement, - await res.text() + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => { + context.app = await launchApp( + context.appDir, + context.appPort, + appOption ) + await retry(async () => { + const res = await fetchViaHTTP(context.appPort, url) + expect(res.status).toBe(500) + expectUnsupportedModuleDevError( + moduleName, + importStatement, + await res.text() + ) + }) }) - }) - }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -167,26 +169,28 @@ describe('Edge runtime code with imports', () => { } `) }) - - describe('development mode', () => { - it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => { - context.app = await launchApp( - context.appDir, - context.appPort, - appOption - ) - const res = await fetchViaHTTP(context.appPort, url) - expect(res.status).toBe(500) - await check(async () => { - expectUnsupportedModuleDevError( - moduleName, - importStatement, - await res.text() + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('throws unsupported module error in dev at runtime and highlights the faulty line', async () => { + context.app = await launchApp( + context.appDir, + context.appPort, + appOption ) - return 'success' - }, 'success') - }) - }) + const res = await fetchViaHTTP(context.appPort, url) + expect(res.status).toBe(500) + await check(async () => { + expectUnsupportedModuleDevError( + moduleName, + importStatement, + await res.text() + ) + return 'success' + }, 'success') + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/edge-runtime-streaming-error/test/index.test.ts b/test/integration/edge-runtime-streaming-error/test/index.test.ts index 0966b44f3b477..92dee4562aa3c 100644 --- a/test/integration/edge-runtime-streaming-error/test/index.test.ts +++ b/test/integration/edge-runtime-streaming-error/test/index.test.ts @@ -50,21 +50,24 @@ function createContext() { return ctx } -describe('development mode', () => { - const context = createContext() +;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + const context = createContext() - beforeAll(async () => { - context.appPort = await findPort() - context.app = await launchApp(appDir, context.appPort, { - ...context.handler, - env: { __NEXT_TEST_WITH_DEVTOOL: '1' }, + beforeAll(async () => { + context.appPort = await findPort() + context.app = await launchApp(appDir, context.appPort, { + ...context.handler, + env: { __NEXT_TEST_WITH_DEVTOOL: '1' }, + }) }) - }) - afterAll(() => killApp(context.app)) + afterAll(() => killApp(context.app)) - it('logs the error correctly', test(context)) -}) + it('logs the error correctly', test(context)) + } +) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -82,6 +85,7 @@ describe('development mode', () => { }) }) afterAll(() => killApp(context.app)) + // eslint-disable-next-line jest/no-identical-title it('logs the error correctly', test(context)) } ) diff --git a/test/integration/edge-runtime-with-node.js-apis/test/index.test.ts b/test/integration/edge-runtime-with-node.js-apis/test/index.test.ts index 62d54fa5a1f16..a0beee8a08743 100644 --- a/test/integration/edge-runtime-with-node.js-apis/test/index.test.ts +++ b/test/integration/edge-runtime-with-node.js-apis/test/index.test.ts @@ -60,56 +60,59 @@ describe.each([ ])('$title using Node.js API', ({ computeRoute }) => { const appDir = join(__dirname, '..') - describe('development mode', () => { - let output = '' - let appPort: number - let app = null + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let output = '' + let appPort: number + let app = null - beforeAll(async () => { - output = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - env: { __NEXT_TEST_WITH_DEVTOOL: '1' }, - onStdout(msg) { - output += msg - }, - onStderr(msg) { - output += msg - }, + beforeAll(async () => { + output = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + env: { __NEXT_TEST_WITH_DEVTOOL: '1' }, + onStdout(msg) { + output += msg + }, + onStderr(msg) { + output += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) + + it.each(undefinedProperties.map((api) => ({ api })))( + 'does not throw on using $api', + async ({ api }) => { + const res = await fetchViaHTTP(appPort, computeRoute(api)) + expect(res.status).toBe(200) + await waitFor(500) + expect(output).not.toInclude(`A Node.js API is used (${api})`) + } + ) - it.each(undefinedProperties.map((api) => ({ api })))( - 'does not throw on using $api', - async ({ api }) => { + it.each([ + ...unsupportedFunctions.map((api) => ({ + api, + errorHighlight: `${api}(`, + })), + ...unsupportedClasses.map((api) => ({ + api, + errorHighlight: `new ${api}(`, + })), + ])(`throws error when using $api`, async ({ api, errorHighlight }) => { const res = await fetchViaHTTP(appPort, computeRoute(api)) - expect(res.status).toBe(200) + expect(res.status).toBe(500) await waitFor(500) - expect(output).not.toInclude(`A Node.js API is used (${api})`) - } - ) - - it.each([ - ...unsupportedFunctions.map((api) => ({ - api, - errorHighlight: `${api}(`, - })), - ...unsupportedClasses.map((api) => ({ - api, - errorHighlight: `new ${api}(`, - })), - ])(`throws error when using $api`, async ({ api, errorHighlight }) => { - const res = await fetchViaHTTP(appPort, computeRoute(api)) - expect(res.status).toBe(500) - await waitFor(500) - expect(output) - .toInclude(`A Node.js API is used (${api}) which is not supported in the Edge Runtime. + expect(output) + .toInclude(`A Node.js API is used (${api}) which is not supported in the Edge Runtime. Learn more: https://nextjs.org/docs/api-reference/edge-runtime`) - expect(stripAnsi(output)).toInclude(errorHighlight) - }) - }) + expect(stripAnsi(output)).toInclude(errorHighlight) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/env-config/test/index.test.js b/test/integration/env-config/test/index.test.js index 82da0e6c50d96..40c26cd0904df 100644 --- a/test/integration/env-config/test/index.test.js +++ b/test/integration/env-config/test/index.test.js @@ -132,216 +132,221 @@ const runTests = (mode = 'dev', didReload = false) => { } describe('Env Config', () => { - describe('development mode', () => { - beforeAll(async () => { - output = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - env: { - PROCESS_ENV_KEY: 'processenvironment', - ENV_FILE_PROCESS_ENV: 'env-cli', - }, - onStdout(msg) { - output += msg || '' - }, - onStderr(msg) { - output += msg || '' - }, - }) - - await renderViaHTTP(appPort, '/another-global') - }) - afterAll(() => killApp(app)) - - runTests('dev') - - describe('with hot reload', () => { - const originalContents = [] + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { beforeAll(async () => { - const outputIndex = output.length - const envFiles = (await fs.readdir(appDir)).filter((file) => - file.startsWith('.env') - ) - const envToUpdate = [ - { - toAdd: 'NEW_ENV_KEY=true', - file: '.env', + output = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + env: { + PROCESS_ENV_KEY: 'processenvironment', + ENV_FILE_PROCESS_ENV: 'env-cli', }, - { - toAdd: 'NEW_ENV_LOCAL_KEY=hello', - file: '.env.local', + onStdout(msg) { + output += msg || '' }, - { - toAdd: 'NEW_ENV_DEV_KEY=from-dev\nNEXT_PUBLIC_HELLO_WORLD=again', - file: '.env.development', + onStderr(msg) { + output += msg || '' }, - ] - - for (const file of envFiles) { - const filePath = join(appDir, file) - const content = await fs.readFile(filePath, 'utf8') - originalContents.push({ file, content }) + }) - const toUpdate = envToUpdate.find((item) => item.file === file) - if (toUpdate) { - await fs.writeFile(filePath, content + `\n${toUpdate.toAdd}`) - } - } - await check(() => { - return output.substring(outputIndex) - }, /Reload env:/) - }) - afterAll(async () => { - for (const { file, content } of originalContents) { - await fs.writeFile(join(appDir, file), content) - } + await renderViaHTTP(appPort, '/another-global') }) + afterAll(() => killApp(app)) + + runTests('dev') - runTests('dev', true) - - it('should have updated runtime values after change', async () => { - let html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) - let renderedEnv = JSON.parse(cheerio.load(html)('p').text()) - - expect(renderedEnv['ENV_FILE_KEY']).toBe('env') - expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe('localenv') - let outputIdx = output.length - - const envFile = join(appDir, '.env') - const envLocalFile = join(appDir, '.env.local') - const envContent = originalContents.find( - (item) => item.file === '.env' - ).content - const envLocalContent = originalContents.find( - (item) => item.file === '.env.local' - ).content - - try { - await fs.writeFile( - envFile, - envContent.replace(`ENV_FILE_KEY=env`, `ENV_FILE_KEY=env-updated`) + describe('with hot reload', () => { + const originalContents = [] + beforeAll(async () => { + const outputIndex = output.length + const envFiles = (await fs.readdir(appDir)).filter((file) => + file.startsWith('.env') ) + const envToUpdate = [ + { + toAdd: 'NEW_ENV_KEY=true', + file: '.env', + }, + { + toAdd: 'NEW_ENV_LOCAL_KEY=hello', + file: '.env.local', + }, + { + toAdd: 'NEW_ENV_DEV_KEY=from-dev\nNEXT_PUBLIC_HELLO_WORLD=again', + file: '.env.development', + }, + ] + + for (const file of envFiles) { + const filePath = join(appDir, file) + const content = await fs.readFile(filePath, 'utf8') + originalContents.push({ file, content }) + + const toUpdate = envToUpdate.find((item) => item.file === file) + if (toUpdate) { + await fs.writeFile(filePath, content + `\n${toUpdate.toAdd}`) + } + } + await check(() => { + return output.substring(outputIndex) + }, /Reload env:/) + }) + afterAll(async () => { + for (const { file, content } of originalContents) { + await fs.writeFile(join(appDir, file), content) + } + }) + + runTests('dev', true) + + it('should have updated runtime values after change', async () => { + let html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) + let renderedEnv = JSON.parse(cheerio.load(html)('p').text()) + + expect(renderedEnv['ENV_FILE_KEY']).toBe('env') + expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe('localenv') + let outputIdx = output.length - // we should only log we loaded new env from .env - await check(() => output.substring(outputIdx), /Reload env:/) - expect( - [...output.substring(outputIdx).matchAll(/Reload env:/g)].length - ).toBe(1) - expect(output.substring(outputIdx)).not.toContain('.env.local') - - await check(async () => { - html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) - renderedEnv = JSON.parse(cheerio.load(html)('p').text()) - expect(renderedEnv['ENV_FILE_KEY']).toBe('env-updated') - expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe('localenv') - return 'success' - }, 'success') - - outputIdx = output.length - - await fs.writeFile( - envLocalFile, - envLocalContent.replace( - `ENV_FILE_LOCAL_OVERRIDE_TEST=localenv`, - `ENV_FILE_LOCAL_OVERRIDE_TEST=localenv-updated` + const envFile = join(appDir, '.env') + const envLocalFile = join(appDir, '.env.local') + const envContent = originalContents.find( + (item) => item.file === '.env' + ).content + const envLocalContent = originalContents.find( + (item) => item.file === '.env.local' + ).content + + try { + await fs.writeFile( + envFile, + envContent.replace(`ENV_FILE_KEY=env`, `ENV_FILE_KEY=env-updated`) ) - ) - // we should only log we loaded new env from .env - await check(() => output.substring(outputIdx), /Reload env:/) - expect( - [...output.substring(outputIdx).matchAll(/Reload env:/g)].length - ).toBe(1) - expect(output.substring(outputIdx)).toContain('.env.local') - - await check(async () => { - html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) - renderedEnv = JSON.parse(cheerio.load(html)('p').text()) - expect(renderedEnv['ENV_FILE_KEY']).toBe('env-updated') - expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe( - 'localenv-updated' + // we should only log we loaded new env from .env + await check(() => output.substring(outputIdx), /Reload env:/) + expect( + [...output.substring(outputIdx).matchAll(/Reload env:/g)].length + ).toBe(1) + expect(output.substring(outputIdx)).not.toContain('.env.local') + + await check(async () => { + html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) + renderedEnv = JSON.parse(cheerio.load(html)('p').text()) + expect(renderedEnv['ENV_FILE_KEY']).toBe('env-updated') + expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe( + 'localenv' + ) + return 'success' + }, 'success') + + outputIdx = output.length + + await fs.writeFile( + envLocalFile, + envLocalContent.replace( + `ENV_FILE_LOCAL_OVERRIDE_TEST=localenv`, + `ENV_FILE_LOCAL_OVERRIDE_TEST=localenv-updated` + ) ) - return 'success' - }, 'success') - } finally { - await fs.writeFile(envFile, envContent) - await fs.writeFile(envLocalFile, envLocalContent) - } - }) - it('should trigger HMR correctly when NEXT_PUBLIC_ env is changed', async () => { - const envFile = join(appDir, '.env') - const envLocalFile = join(appDir, '.env.local') - const envContent = originalContents.find( - (item) => item.file === '.env' - ).content - const envLocalContent = originalContents.find( - (item) => item.file === '.env.local' - ).content - - try { - const browser = await webdriver(appPort, '/global') - expect( - await browser.waitForElementByCss('#global-value').text() - ).toBe('another') + // we should only log we loaded new env from .env + await check(() => output.substring(outputIdx), /Reload env:/) + expect( + [...output.substring(outputIdx).matchAll(/Reload env:/g)].length + ).toBe(1) + expect(output.substring(outputIdx)).toContain('.env.local') + + await check(async () => { + html = await fetchViaHTTP(appPort, '/').then((res) => res.text()) + renderedEnv = JSON.parse(cheerio.load(html)('p').text()) + expect(renderedEnv['ENV_FILE_KEY']).toBe('env-updated') + expect(renderedEnv['ENV_FILE_LOCAL_OVERRIDE_TEST']).toBe( + 'localenv-updated' + ) + return 'success' + }, 'success') + } finally { + await fs.writeFile(envFile, envContent) + await fs.writeFile(envLocalFile, envLocalContent) + } + }) - let outputIdx = output.length + it('should trigger HMR correctly when NEXT_PUBLIC_ env is changed', async () => { + const envFile = join(appDir, '.env') + const envLocalFile = join(appDir, '.env.local') + const envContent = originalContents.find( + (item) => item.file === '.env' + ).content + const envLocalContent = originalContents.find( + (item) => item.file === '.env.local' + ).content + + try { + const browser = await webdriver(appPort, '/global') + expect( + await browser.waitForElementByCss('#global-value').text() + ).toBe('another') + + let outputIdx = output.length + + await fs.writeFile( + envFile, + envContent.replace( + `NEXT_PUBLIC_TEST_DEST=another`, + `NEXT_PUBLIC_TEST_DEST=replaced` + ) + ) + // we should only log we loaded new env from .env + await check(() => output.substring(outputIdx), /Reload env:/) + expect( + [...output.substring(outputIdx).matchAll(/Reload env:/g)].length + ).toBe(1) + expect(output.substring(outputIdx)).not.toContain('.env.local') + + await check( + () => browser.waitForElementByCss('#global-value').text(), + 'replaced' + ) + + outputIdx = output.length - await fs.writeFile( - envFile, - envContent.replace( - `NEXT_PUBLIC_TEST_DEST=another`, - `NEXT_PUBLIC_TEST_DEST=replaced` + await fs.writeFile( + envLocalFile, + envLocalContent + `\nNEXT_PUBLIC_TEST_DEST=overridden` + ) + // we should only log we loaded new env from .env + await check(() => output.substring(outputIdx), /Reload env:/) + expect( + [...output.substring(outputIdx).matchAll(/Reload env:/g)].length + ).toBe(1) + expect(output.substring(outputIdx)).toContain('.env.local') + + await check( + () => browser.waitForElementByCss('#global-value').text(), + 'overridden' ) - ) - // we should only log we loaded new env from .env - await check(() => output.substring(outputIdx), /Reload env:/) - expect( - [...output.substring(outputIdx).matchAll(/Reload env:/g)].length - ).toBe(1) - expect(output.substring(outputIdx)).not.toContain('.env.local') - - await check( - () => browser.waitForElementByCss('#global-value').text(), - 'replaced' - ) - outputIdx = output.length + outputIdx = output.length - await fs.writeFile( - envLocalFile, - envLocalContent + `\nNEXT_PUBLIC_TEST_DEST=overridden` - ) - // we should only log we loaded new env from .env - await check(() => output.substring(outputIdx), /Reload env:/) - expect( - [...output.substring(outputIdx).matchAll(/Reload env:/g)].length - ).toBe(1) - expect(output.substring(outputIdx)).toContain('.env.local') - - await check( - () => browser.waitForElementByCss('#global-value').text(), - 'overridden' - ) + await fs.writeFile(envLocalFile, envLocalContent) + // we should only log we loaded new env from .env + await check(() => output.substring(outputIdx), /Reload env:/) + expect( + [...output.substring(outputIdx).matchAll(/Reload env:/g)].length + ).toBe(1) + expect(output.substring(outputIdx)).toContain('.env.local') - outputIdx = output.length - - await fs.writeFile(envLocalFile, envLocalContent) - // we should only log we loaded new env from .env - await check(() => output.substring(outputIdx), /Reload env:/) - expect( - [...output.substring(outputIdx).matchAll(/Reload env:/g)].length - ).toBe(1) - expect(output.substring(outputIdx)).toContain('.env.local') - - await check(() => browser.elementByCss('p').text(), 'replaced') - } finally { - await fs.writeFile(envFile, envContent) - await fs.writeFile(envLocalFile, envLocalContent) - } + await check(() => browser.elementByCss('p').text(), 'replaced') + } finally { + await fs.writeFile(envFile, envContent) + await fs.writeFile(envLocalFile, envLocalContent) + } + }) }) - }) - }) + } + ) describe('test environment', () => { beforeAll(async () => { diff --git a/test/integration/fallback-false-rewrite/test/index.test.js b/test/integration/fallback-false-rewrite/test/index.test.js index 99ee7c6f8eaa1..f4cb7eadf1942 100644 --- a/test/integration/fallback-false-rewrite/test/index.test.js +++ b/test/integration/fallback-false-rewrite/test/index.test.js @@ -107,16 +107,19 @@ const runTests = () => { } describe('fallback: false rewrite', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/fallback-route-params/test/index.test.js b/test/integration/fallback-route-params/test/index.test.js index 4a4a6b6b04d2c..7a1b35a8b6035 100644 --- a/test/integration/fallback-route-params/test/index.test.js +++ b/test/integration/fallback-route-params/test/index.test.js @@ -40,16 +40,19 @@ const runTests = () => { } describe('Fallback Dynamic Route Params', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/fetch-polyfill-ky-universal/test/index.test.js b/test/integration/fetch-polyfill-ky-universal/test/index.test.js index 5f3356bbd97f3..423512ba139c1 100644 --- a/test/integration/fetch-polyfill-ky-universal/test/index.test.js +++ b/test/integration/fetch-polyfill-ky-universal/test/index.test.js @@ -51,23 +51,26 @@ function runTests() { } describe('Fetch polyfill with ky-universal', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - await startApiServer() - app = await launchApp(appDir, appPort, { - env: { - NEXT_PUBLIC_API_PORT: apiServerPort, - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + await startApiServer() + app = await launchApp(appDir, appPort, { + env: { + NEXT_PUBLIC_API_PORT: apiServerPort, + }, + }) + }) + afterAll(async () => { + await killApp(app) + await killApp(apiServer) }) - }) - afterAll(async () => { - await killApp(app) - await killApp(apiServer) - }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/fetch-polyfill/test/index.test.js b/test/integration/fetch-polyfill/test/index.test.js index 41e667f037ac3..8404d74a60da7 100644 --- a/test/integration/fetch-polyfill/test/index.test.js +++ b/test/integration/fetch-polyfill/test/index.test.js @@ -70,23 +70,26 @@ function runTests() { } describe('Fetch polyfill', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - await startApiServer() - app = await launchApp(appDir, appPort, { - env: { - NEXT_PUBLIC_API_PORT: apiServerPort, - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + await startApiServer() + app = await launchApp(appDir, appPort, { + env: { + NEXT_PUBLIC_API_PORT: apiServerPort, + }, + }) + }) + afterAll(async () => { + await killApp(app) + await killApp(apiServer) }) - }) - afterAll(async () => { - await killApp(app) - await killApp(apiServer) - }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/file-serving/test/index.test.js b/test/integration/file-serving/test/index.test.js index 8d6b5bd0b711d..d64827f6f9a93 100644 --- a/test/integration/file-serving/test/index.test.js +++ b/test/integration/file-serving/test/index.test.js @@ -4465,23 +4465,26 @@ const copyTestFileToDist = () => fs.copy(join(appDir, 'test-file.txt'), join(appDir, '.next', 'test-file.txt')) describe('File Serving', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - // don't log stdout and stderr as we're going to generate - // a lot of output from resolve mismatches - stdout: false, - stderr: false, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + // don't log stdout and stderr as we're going to generate + // a lot of output from resolve mismatches + stdout: false, + stderr: false, + }) + await copyTestFileToDist() + }) + afterAll(async () => { + await killApp(app) }) - await copyTestFileToDist() - }) - afterAll(async () => { - await killApp(app) - }) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/getinitialprops/test/index.test.js b/test/integration/getinitialprops/test/index.test.js index 454ffac1917eb..d3d4c155ee334 100644 --- a/test/integration/getinitialprops/test/index.test.js +++ b/test/integration/getinitialprops/test/index.test.js @@ -40,15 +40,18 @@ const runTests = () => { } describe('getInitialProps', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/getserversideprops-preview/test/index.test.js b/test/integration/getserversideprops-preview/test/index.test.js index 1f0ebc3775bb8..81c2b936d9fe4 100644 --- a/test/integration/getserversideprops-preview/test/index.test.js +++ b/test/integration/getserversideprops-preview/test/index.test.js @@ -174,101 +174,115 @@ function runTests(startServer = nextStart) { } describe('ServerSide Props Preview Mode', () => { - describe('Development Mode', () => { - let appPort, app - it('should start development application', async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - - let previewCookieString - it('should enable preview mode', async () => { - const res = await fetchViaHTTP(appPort, '/api/preview', { lets: 'goooo' }) - expect(res.status).toBe(200) - - const cookies = res.headers.get('set-cookie').split(',').map(cookie.parse) - - expect(cookies.length).toBe(2) - previewCookieString = - cookie.serialize('__prerender_bypass', cookies[0].__prerender_bypass) + - '; ' + - cookie.serialize('__next_preview_data', cookies[1].__next_preview_data) - }) - - it('should return cookies to be expired after dev server reboot', async () => { - await killApp(app) - appPort = await findPort() - app = await launchApp(appDir, appPort) - - const res = await fetchViaHTTP( - appPort, - '/', - {}, - { headers: { Cookie: previewCookieString } } - ) - expect(res.status).toBe(200) - - const body = await res.text() - // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('"err"') - expect(body).not.toContain('TypeError') - expect(body).not.toContain('previewModeId') - - const cookies = res.headers - .get('set-cookie') - .replace(/(=(?!Lax)\w{3}),/g, '$1') - .split(',') - .map(cookie.parse) - - expect(cookies.length).toBe(2) - }) - - /** @type {import('next-webdriver').Chain} */ - let browser - it('should start the client-side browser', async () => { - browser = await webdriver( - appPort, - '/api/preview?' + qs.stringify({ client: 'mode' }) - ) - }) - - it('should fetch preview data on SSR', async () => { - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#props-pre') - // expect(await browser.elementById('props-pre').text()).toBe('Has No Props') - // await new Promise(resolve => setTimeout(resolve, 2000)) - expect(await browser.elementById('props-pre').text()).toBe( - 'true and {"client":"mode"}' - ) - }) - - it('should fetch preview data on CST', async () => { - await browser.get(`http://localhost:${appPort}/to-index`) - await browser.waitForElementByCss('#to-index') - await browser.eval('window.itdidnotrefresh = "hello"') - await browser.elementById('to-index').click() - await browser.waitForElementByCss('#props-pre') - expect(await browser.eval('window.itdidnotrefresh')).toBe('hello') - expect(await browser.elementById('props-pre').text()).toBe( - 'true and {"client":"mode"}' - ) - }) - - it('should fetch prerendered data', async () => { - await browser.get(`http://localhost:${appPort}/api/reset`) - - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#props-pre') - expect(await browser.elementById('props-pre').text()).toBe( - 'false and null' - ) - }) - - afterAll(async () => { - await browser.close() - await killApp(app) - }) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let appPort, app + it('should start development application', async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + + let previewCookieString + it('should enable preview mode', async () => { + const res = await fetchViaHTTP(appPort, '/api/preview', { + lets: 'goooo', + }) + expect(res.status).toBe(200) + + const cookies = res.headers + .get('set-cookie') + .split(',') + .map(cookie.parse) + + expect(cookies.length).toBe(2) + previewCookieString = + cookie.serialize( + '__prerender_bypass', + cookies[0].__prerender_bypass + ) + + '; ' + + cookie.serialize( + '__next_preview_data', + cookies[1].__next_preview_data + ) + }) + + it('should return cookies to be expired after dev server reboot', async () => { + await killApp(app) + appPort = await findPort() + app = await launchApp(appDir, appPort) + + const res = await fetchViaHTTP( + appPort, + '/', + {}, + { headers: { Cookie: previewCookieString } } + ) + expect(res.status).toBe(200) + + const body = await res.text() + // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" + expect(body).not.toContain('"err"') + expect(body).not.toContain('TypeError') + expect(body).not.toContain('previewModeId') + + const cookies = res.headers + .get('set-cookie') + .replace(/(=(?!Lax)\w{3}),/g, '$1') + .split(',') + .map(cookie.parse) + + expect(cookies.length).toBe(2) + }) + + /** @type {import('next-webdriver').Chain} */ + let browser + it('should start the client-side browser', async () => { + browser = await webdriver( + appPort, + '/api/preview?' + qs.stringify({ client: 'mode' }) + ) + }) + + it('should fetch preview data on SSR', async () => { + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#props-pre') + // expect(await browser.elementById('props-pre').text()).toBe('Has No Props') + // await new Promise(resolve => setTimeout(resolve, 2000)) + expect(await browser.elementById('props-pre').text()).toBe( + 'true and {"client":"mode"}' + ) + }) + + it('should fetch preview data on CST', async () => { + await browser.get(`http://localhost:${appPort}/to-index`) + await browser.waitForElementByCss('#to-index') + await browser.eval('window.itdidnotrefresh = "hello"') + await browser.elementById('to-index').click() + await browser.waitForElementByCss('#props-pre') + expect(await browser.eval('window.itdidnotrefresh')).toBe('hello') + expect(await browser.elementById('props-pre').text()).toBe( + 'true and {"client":"mode"}' + ) + }) + + it('should fetch prerendered data', async () => { + await browser.get(`http://localhost:${appPort}/api/reset`) + + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#props-pre') + expect(await browser.elementById('props-pre').text()).toBe( + 'false and null' + ) + }) + + afterAll(async () => { + await browser.close() + await killApp(app) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/gip-identifier/test/index.test.js b/test/integration/gip-identifier/test/index.test.js index 50a4eea54eeb6..b1ac25d78ab5f 100644 --- a/test/integration/gip-identifier/test/index.test.js +++ b/test/integration/gip-identifier/test/index.test.js @@ -87,9 +87,12 @@ const runTests = (isDev) => { } describe('gip identifiers', () => { - describe('development mode', () => { - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/gssp-pageProps-merge/test/index.test.js b/test/integration/gssp-pageProps-merge/test/index.test.js index 5bace1b567c5c..38560ac847ac7 100644 --- a/test/integration/gssp-pageProps-merge/test/index.test.js +++ b/test/integration/gssp-pageProps-merge/test/index.test.js @@ -31,15 +31,18 @@ const runTests = () => { } describe('pageProps GSSP conflict', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/gssp-redirect-base-path/test/index.test.js b/test/integration/gssp-redirect-base-path/test/index.test.js index b8e0c6c0d0bdc..9501d9b1a2f5d 100644 --- a/test/integration/gssp-redirect-base-path/test/index.test.js +++ b/test/integration/gssp-redirect-base-path/test/index.test.js @@ -480,15 +480,18 @@ const runTests = (isDev) => { } describe('GS(S)P Redirect Support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/gssp-redirect/test/index.test.js b/test/integration/gssp-redirect/test/index.test.js index a96c04a9bdc66..248f3a0076073 100644 --- a/test/integration/gssp-redirect/test/index.test.js +++ b/test/integration/gssp-redirect/test/index.test.js @@ -505,15 +505,18 @@ const runTests = (isDev) => { } describe('GS(S)P Redirect Support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/hashbang/test/index.test.js b/test/integration/hashbang/test/index.test.js index fa52b9c68ae76..090aed1a2c634 100644 --- a/test/integration/hashbang/test/index.test.js +++ b/test/integration/hashbang/test/index.test.js @@ -37,15 +37,18 @@ function runTests() { const nextConfig = join(appDir, 'next.config.js') describe('Hashbang', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/hydration/test/index.test.js b/test/integration/hydration/test/index.test.js index b3dac1711f8e8..8101d6dea4099 100644 --- a/test/integration/hydration/test/index.test.js +++ b/test/integration/hydration/test/index.test.js @@ -40,16 +40,19 @@ const runTests = () => { } describe('Hydration', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(path.join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(path.join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-base-path/test/index.test.js b/test/integration/i18n-support-base-path/test/index.test.js index 3b2617a8bf2f2..7e50ad59b25dd 100644 --- a/test/integration/i18n-support-base-path/test/index.test.js +++ b/test/integration/i18n-support-base-path/test/index.test.js @@ -40,25 +40,27 @@ describe('i18n Support basePath', () => { }) ) }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + const curCtx = { + ...ctx, + isDev: true, + } + beforeAll(async () => { + nextConfig.replace(/__EXTERNAL_PORT__/g, ctx.externalPort) + await fs.remove(join(appDir, '.next')) + curCtx.appPort = await findPort() + curCtx.app = await launchApp(appDir, curCtx.appPort) + }) + afterAll(async () => { + nextConfig.restore() + await killApp(curCtx.app) + }) - describe('development mode', () => { - const curCtx = { - ...ctx, - isDev: true, + runTests(curCtx) } - beforeAll(async () => { - nextConfig.replace(/__EXTERNAL_PORT__/g, ctx.externalPort) - await fs.remove(join(appDir, '.next')) - curCtx.appPort = await findPort() - curCtx.app = await launchApp(appDir, curCtx.appPort) - }) - afterAll(async () => { - nextConfig.restore() - await killApp(curCtx.app) - }) - - runTests(curCtx) - }) + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-catchall/test/index.test.js b/test/integration/i18n-support-catchall/test/index.test.js index c5aecd10a7565..b97989de60ad5 100644 --- a/test/integration/i18n-support-catchall/test/index.test.js +++ b/test/integration/i18n-support-catchall/test/index.test.js @@ -221,16 +221,19 @@ function runTests(isDev) { } describe('i18n Support Root Catch-all', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-custom-error/test/index.test.js b/test/integration/i18n-support-custom-error/test/index.test.js index 18db060b6ef3b..6738a6b867776 100644 --- a/test/integration/i18n-support-custom-error/test/index.test.js +++ b/test/integration/i18n-support-custom-error/test/index.test.js @@ -108,14 +108,17 @@ const runTests = () => { } describe('Custom routes i18n custom error', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-fallback-rewrite-legacy/test/index.test.js b/test/integration/i18n-support-fallback-rewrite-legacy/test/index.test.js index da7c730941050..62e34f75dbbf2 100644 --- a/test/integration/i18n-support-fallback-rewrite-legacy/test/index.test.js +++ b/test/integration/i18n-support-fallback-rewrite-legacy/test/index.test.js @@ -85,19 +85,22 @@ function runTests() { } describe('i18n Support', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - nextConfig.restore() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + nextConfig.restore() + }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-fallback-rewrite/test/index.test.js b/test/integration/i18n-support-fallback-rewrite/test/index.test.js index da7c730941050..62e34f75dbbf2 100644 --- a/test/integration/i18n-support-fallback-rewrite/test/index.test.js +++ b/test/integration/i18n-support-fallback-rewrite/test/index.test.js @@ -85,19 +85,22 @@ function runTests() { } describe('i18n Support', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - nextConfig.restore() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + nextConfig.restore() + }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-index-rewrite/test/index.test.js b/test/integration/i18n-support-index-rewrite/test/index.test.js index 55c9b31acee03..273f37e37a115 100644 --- a/test/integration/i18n-support-index-rewrite/test/index.test.js +++ b/test/integration/i18n-support-index-rewrite/test/index.test.js @@ -76,14 +76,17 @@ const runTests = () => { } describe('Custom routes i18n support index rewrite', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support-same-page-hash-change/test/index.test.js b/test/integration/i18n-support-same-page-hash-change/test/index.test.js index a62decef9f08d..b52047e76d6cf 100644 --- a/test/integration/i18n-support-same-page-hash-change/test/index.test.js +++ b/test/integration/i18n-support-same-page-hash-change/test/index.test.js @@ -71,14 +71,17 @@ const runTests = () => { } describe('Hash changes i18n', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/i18n-support/test/index.test.js b/test/integration/i18n-support/test/index.test.js index 51e2115fa6c3b..0654238585589 100644 --- a/test/integration/i18n-support/test/index.test.js +++ b/test/integration/i18n-support/test/index.test.js @@ -38,26 +38,28 @@ describe('i18n Support', () => { }) }) afterAll(() => ctx.externalApp.close()) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + const curCtx = { + ...ctx, + isDev: true, + } + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + nextConfig.replace(/__EXTERNAL_PORT__/g, ctx.externalPort) + curCtx.appPort = await findPort() + curCtx.app = await launchApp(appDir, curCtx.appPort) + curCtx.buildId = 'development' + }) + afterAll(async () => { + await killApp(curCtx.app) + nextConfig.restore() + }) - describe('development mode', () => { - const curCtx = { - ...ctx, - isDev: true, + runTests(curCtx) } - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - nextConfig.replace(/__EXTERNAL_PORT__/g, ctx.externalPort) - curCtx.appPort = await findPort() - curCtx.app = await launchApp(appDir, curCtx.appPort) - curCtx.buildId = 'development' - }) - afterAll(async () => { - await killApp(curCtx.app) - nextConfig.restore() - }) - - runTests(curCtx) - }) + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -421,25 +423,28 @@ describe('i18n Support', () => { }) } - describe('development mode', () => { - const curCtx = { - ...ctx, - isDev: true, - } - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - nextConfig.replace('// trailingSlash', 'trailingSlash') + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + const curCtx = { + ...ctx, + isDev: true, + } + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + nextConfig.replace('// trailingSlash', 'trailingSlash') - curCtx.appPort = await findPort() - curCtx.app = await launchApp(appDir, curCtx.appPort) - }) - afterAll(async () => { - nextConfig.restore() - await killApp(curCtx.app) - }) + curCtx.appPort = await findPort() + curCtx.app = await launchApp(appDir, curCtx.appPort) + }) + afterAll(async () => { + nextConfig.restore() + await killApp(curCtx.app) + }) - runSlashTests(curCtx) - }) + runSlashTests(curCtx) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -488,25 +493,28 @@ describe('i18n Support', () => { }) } - describe('development mode', () => { - const curCtx = { - ...ctx, - isDev: true, - } - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - nextConfig.replace('// trailingSlash: true', 'trailingSlash: false') + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + const curCtx = { + ...ctx, + isDev: true, + } + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + nextConfig.replace('// trailingSlash: true', 'trailingSlash: false') - curCtx.appPort = await findPort() - curCtx.app = await launchApp(appDir, curCtx.appPort) - }) - afterAll(async () => { - nextConfig.restore() - await killApp(curCtx.app) - }) + curCtx.appPort = await findPort() + curCtx.app = await launchApp(appDir, curCtx.appPort) + }) + afterAll(async () => { + nextConfig.restore() + await killApp(curCtx.app) + }) - runSlashTests(curCtx) - }) + runSlashTests(curCtx) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/index-index/test/index.test.js b/test/integration/index-index/test/index.test.js index d335c11a2bc13..efbdcc5f92dd2 100644 --- a/test/integration/index-index/test/index.test.js +++ b/test/integration/index-index/test/index.test.js @@ -182,15 +182,18 @@ function runTests() { const nextConfig = join(appDir, 'next.config.js') describe('nested index.js', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/initial-ref/test/index.test.js b/test/integration/initial-ref/test/index.test.js index 9d42f8e3789c8..037eaf5751721 100644 --- a/test/integration/initial-ref/test/index.test.js +++ b/test/integration/initial-ref/test/index.test.js @@ -35,14 +35,16 @@ describe('Initial Refs', () => { runTest() } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTest() - }) + runTest() + } + ) }) diff --git a/test/integration/invalid-custom-routes/test/index.test.js b/test/integration/invalid-custom-routes/test/index.test.js index b97852fc73823..ceeb285a8d301 100644 --- a/test/integration/invalid-custom-routes/test/index.test.js +++ b/test/integration/invalid-custom-routes/test/index.test.js @@ -578,26 +578,28 @@ const runTests = () => { describe('Errors on invalid custom routes', () => { afterAll(() => fs.remove(nextConfigPath)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let stderr = '' + beforeAll(() => { + getStderr = async () => { + const port = await findPort() + await launchApp(appDir, port, { + onStderr: (msg) => { + stderr += msg + }, + }) + return stderr + } + }) + afterEach(() => { + stderr = '' + }) - describe('development mode', () => { - let stderr = '' - beforeAll(() => { - getStderr = async () => { - const port = await findPort() - await launchApp(appDir, port, { - onStderr: (msg) => { - stderr += msg - }, - }) - return stderr - } - }) - afterEach(() => { - stderr = '' - }) - - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/invalid-href/test/index.test.js b/test/integration/invalid-href/test/index.test.js index 6e663bc09b059..5543ae3ff164e 100644 --- a/test/integration/invalid-href/test/index.test.js +++ b/test/integration/invalid-href/test/index.test.js @@ -147,53 +147,57 @@ describe('Invalid hrefs', () => { }) } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - it('does not show error when mailto: is used as href on Link', async () => { - await noError('/first') - }) - - it('does not show error when https://google.com is used as href on Link', async () => { - await noError('/second') - }) - - it('shows error when dynamic route mismatch is used on Link', async () => { - await showsError( - '/dynamic-route-mismatch', - /The provided `as` value \(\/blog\/post-1\) is incompatible with the `href` value \(\/\[post\]\)/, - true - ) - }) - - it('shows error when internal href is used with external as', async () => { - await showsError( - '/invalid-relative', - /Invalid href: "\/second" and as: "mailto:hello@example\.com", received relative href and external as/, - true - ) - }) - - it('does not throw error when dynamic route mismatch is used on Link and params are manually provided', async () => { - await noError('/dynamic-route-mismatch-manual', true) - }) - - it("doesn't fail on invalid url", async () => { - await noError('/third') - }) - - it('shows warning when dynamic route mismatch is used on Link', async () => { - await showsError( - '/dynamic-route-mismatch', - /Mismatching `as` and `href` failed to manually provide the params: post in the `href`'s `query`/, - true, - true - ) - }) - }) + it('does not show error when mailto: is used as href on Link', async () => { + await noError('/first') + }) + + it('does not show error when https://google.com is used as href on Link', async () => { + await noError('/second') + }) + + // eslint-disable-next-line jest/no-identical-title + it('shows error when dynamic route mismatch is used on Link', async () => { + await showsError( + '/dynamic-route-mismatch', + /The provided `as` value \(\/blog\/post-1\) is incompatible with the `href` value \(\/\[post\]\)/, + true + ) + }) + + it('shows error when internal href is used with external as', async () => { + await showsError( + '/invalid-relative', + /Invalid href: "\/second" and as: "mailto:hello@example\.com", received relative href and external as/, + true + ) + }) + + it('does not throw error when dynamic route mismatch is used on Link and params are manually provided', async () => { + await noError('/dynamic-route-mismatch-manual', true) + }) + + // eslint-disable-next-line jest/no-identical-title + it("doesn't fail on invalid url", async () => { + await noError('/third') + }) + + it('shows warning when dynamic route mismatch is used on Link', async () => { + await showsError( + '/dynamic-route-mismatch', + /Mismatching `as` and `href` failed to manually provide the params: post in the `href`'s `query`/, + true, + true + ) + }) + } + ) }) diff --git a/test/integration/invalid-middleware-matchers/test/index.test.js b/test/integration/invalid-middleware-matchers/test/index.test.js index 004c8772c4b2b..016018de382ab 100644 --- a/test/integration/invalid-middleware-matchers/test/index.test.js +++ b/test/integration/invalid-middleware-matchers/test/index.test.js @@ -135,24 +135,26 @@ const runTests = () => { describe('Errors on invalid custom middleware matchers', () => { afterAll(() => fs.remove(middlewarePath)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(() => { + getStderr = async () => { + let stderr = '' + const port = await findPort() + await launchApp(appDir, port, { + onStderr(msg) { + stderr += msg + }, + }) + await fetchViaHTTP(port, '/').catch(() => {}) + return stderr + } + }) - describe('development mode', () => { - beforeAll(() => { - getStderr = async () => { - let stderr = '' - const port = await findPort() - await launchApp(appDir, port, { - onStderr(msg) { - stderr += msg - }, - }) - await fetchViaHTTP(port, '/').catch(() => {}) - return stderr - } - }) - - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/invalid-multi-match/test/index.test.js b/test/integration/invalid-multi-match/test/index.test.js index 56d0aa76660f5..658ff92213c3b 100644 --- a/test/integration/invalid-multi-match/test/index.test.js +++ b/test/integration/invalid-multi-match/test/index.test.js @@ -28,18 +28,21 @@ const runTests = () => { } describe('Custom routes invalid multi-match', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr: (msg) => { - stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr: (msg) => { + stderr += msg + }, + }) }) - }) - afterAll(() => killApp(app)) - runTests(true) - }) + afterAll(() => killApp(app)) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/link-ref/test/index.test.js b/test/integration/link-ref/test/index.test.js index e593a6fb46531..387e08ae5303a 100644 --- a/test/integration/link-ref/test/index.test.js +++ b/test/integration/link-ref/test/index.test.js @@ -58,31 +58,34 @@ function runCommonTests() { } describe('Invalid hrefs', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runCommonTests() - - it('should not show error for function component with forwardRef', async () => { - await noError('/function') - }) - - it('should not show error for class component as child of next/link', async () => { - await noError('/class') - }) - - it('should handle child ref with React.createRef', async () => { - await noError('/child-ref') - }) - - it('should handle child ref that is a function', async () => { - await noError('/child-ref-func') - }) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runCommonTests() + + it('should not show error for function component with forwardRef', async () => { + await noError('/function') + }) + + it('should not show error for class component as child of next/link', async () => { + await noError('/class') + }) + + it('should handle child ref with React.createRef', async () => { + await noError('/child-ref') + }) + + it('should handle child ref that is a function', async () => { + await noError('/child-ref-func') + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/link-without-router/test/index.test.js b/test/integration/link-without-router/test/index.test.js index c53f87a9d98e2..ff3f757221e7b 100644 --- a/test/integration/link-without-router/test/index.test.js +++ b/test/integration/link-without-router/test/index.test.js @@ -21,25 +21,28 @@ describe('Link without a router', () => { container.remove() container = null }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('should not throw when rendered', () => { + jest.useFakeTimers() - describe('development mode', () => { - it('should not throw when rendered', () => { - jest.useFakeTimers() + act(() => { + render(<Hello />, container) + }) - act(() => { - render(<Hello />, container) - }) + act(() => { + jest.runAllTimers() + }) - act(() => { - jest.runAllTimers() + expect(container.textContent).toBe('Click me') }) - - expect(container.textContent).toBe('Click me') - }) - }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { + // eslint-disable-next-line jest/no-identical-title it('should not throw when rendered', () => { jest.useFakeTimers() diff --git a/test/integration/middleware-basic/test/index.test.js b/test/integration/middleware-basic/test/index.test.js index ff3591469ff5a..b604bfed844cd 100644 --- a/test/integration/middleware-basic/test/index.test.js +++ b/test/integration/middleware-basic/test/index.test.js @@ -23,15 +23,18 @@ function runTest() { }) } -describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) +;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTest() -}) + runTest() + } +) // TODO enable that once turbopack supports middleware in development mode ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( diff --git a/test/integration/middleware-overrides-node.js-api/test/index.test.ts b/test/integration/middleware-overrides-node.js-api/test/index.test.ts index 24908010e4c23..f4e0b6f6dda28 100644 --- a/test/integration/middleware-overrides-node.js-api/test/index.test.ts +++ b/test/integration/middleware-overrides-node.js-api/test/index.test.ts @@ -14,32 +14,35 @@ const context = { appDir: join(__dirname, '../'), appPort: NaN, app: null } jest.setTimeout(1000 * 60 * 2) describe('Middleware overriding a Node.js API', () => { - describe('development mode', () => { - let output = '' + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let output = '' - beforeAll(async () => { - output = '' - context.appPort = await findPort() - context.app = await launchApp(context.appDir, context.appPort, { - onStdout(msg) { - output += msg - }, - onStderr(msg) { - output += msg - }, + beforeAll(async () => { + output = '' + context.appPort = await findPort() + context.app = await launchApp(context.appDir, context.appPort, { + onStdout(msg) { + output += msg + }, + onStderr(msg) { + output += msg + }, + }) }) - }) - afterAll(() => killApp(context.app)) + afterAll(() => killApp(context.app)) - it('does not show a warning and allows overriding', async () => { - const res = await fetchViaHTTP(context.appPort, '/') - await waitFor(500) - expect(res.status).toBe(200) - expect(output).toContain('fixed-value') - expect(output).not.toContain('TypeError') - expect(output).not.toContain('A Node.js API is used (process.env') - expect(output).not.toContain('A Node.js API is used (process.cwd') - }) - }) + it('does not show a warning and allows overriding', async () => { + const res = await fetchViaHTTP(context.appPort, '/') + await waitFor(500) + expect(res.status).toBe(200) + expect(output).toContain('fixed-value') + expect(output).not.toContain('TypeError') + expect(output).not.toContain('A Node.js API is used (process.env') + expect(output).not.toContain('A Node.js API is used (process.cwd') + }) + } + ) }) diff --git a/test/integration/middleware-src/test/index.test.js b/test/integration/middleware-src/test/index.test.js index 0dff359005dd0..5adb39f82494c 100644 --- a/test/integration/middleware-src/test/index.test.js +++ b/test/integration/middleware-src/test/index.test.js @@ -89,16 +89,18 @@ describe.each([ ])('$title', ({ setup, teardown, runTest }) => { beforeAll(() => setup()) afterAll(() => teardown()) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTest() - }) + runTest() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-dynamic-css/test/index.test.js b/test/integration/next-dynamic-css/test/index.test.js index cb60b37a28ca6..77a4ed94019cd 100644 --- a/test/integration/next-dynamic-css/test/index.test.js +++ b/test/integration/next-dynamic-css/test/index.test.js @@ -31,15 +31,18 @@ function runTests() { } describe('next/dynamic', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-dynamic-lazy-compilation/test/index.test.js b/test/integration/next-dynamic-lazy-compilation/test/index.test.js index 24c664adc3df6..f349b502a0df4 100644 --- a/test/integration/next-dynamic-lazy-compilation/test/index.test.js +++ b/test/integration/next-dynamic-lazy-compilation/test/index.test.js @@ -50,15 +50,18 @@ function runTests() { ;(process.env.TURBOPACK ? describe.skip : describe)( 'next/dynamic lazy compilation', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-dynamic/test/index.test.js b/test/integration/next-dynamic/test/index.test.js index c13c705484b95..38d9ead4a9562 100644 --- a/test/integration/next-dynamic/test/index.test.js +++ b/test/integration/next-dynamic/test/index.test.js @@ -43,15 +43,18 @@ function runTests() { } describe('next/dynamic', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/asset-prefix/test/index.test.ts b/test/integration/next-image-legacy/asset-prefix/test/index.test.ts index 0b88f4d9ba321..08537b94d586f 100644 --- a/test/integration/next-image-legacy/asset-prefix/test/index.test.ts +++ b/test/integration/next-image-legacy/asset-prefix/test/index.test.ts @@ -16,35 +16,38 @@ let appPort let app describe('Image Component assetPrefix Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - it('should include assetPrefix when placeholder=blur during next dev', async () => { - let browser - try { - browser = await webdriver(appPort, '/') - const id = 'test1' - const bgImage = await browser.eval( - `document.getElementById('${id}').style['background-image']` - ) - if (process.env.TURBOPACK) { - expect(bgImage).toContain('data:image/jpeg;') - } else { - expect(bgImage).toMatch( - /\/_next\/image\?url=https%3A%2F%2Fexample.com%2Fpre%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=8&q=70/ + it('should include assetPrefix when placeholder=blur during next dev', async () => { + let browser + try { + browser = await webdriver(appPort, '/') + const id = 'test1' + const bgImage = await browser.eval( + `document.getElementById('${id}').style['background-image']` ) + if (process.env.TURBOPACK) { + expect(bgImage).toContain('data:image/jpeg;') + } else { + expect(bgImage).toMatch( + /\/_next\/image\?url=https%3A%2F%2Fexample.com%2Fpre%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=8&q=70/ + ) + } + } finally { + if (browser) { + await browser.close() + } } - } finally { - if (browser) { - await browser.close() - } - } - }) - }) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/base-path/test/index.test.ts b/test/integration/next-image-legacy/base-path/test/index.test.ts index 567d4908c46af..d4832a9e58cdd 100644 --- a/test/integration/next-image-legacy/base-path/test/index.test.ts +++ b/test/integration/next-image-legacy/base-path/test/index.test.ts @@ -465,15 +465,18 @@ function runTests(mode) { } describe('Image Component basePath Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/base-path/test/static.test.ts b/test/integration/next-image-legacy/base-path/test/static.test.ts index d02b734ec4ae8..12b1e666ce4c6 100644 --- a/test/integration/next-image-legacy/base-path/test/static.test.ts +++ b/test/integration/next-image-legacy/base-path/test/static.test.ts @@ -139,17 +139,19 @@ describe('Static Image Component Tests for basePath', () => { runTests() } ) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - html = await renderViaHTTP(appPort, '/docs/static-img') - browser = await webdriver(appPort, '/docs/static-img') - }) - afterAll(() => { - killApp(app) - }) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + html = await renderViaHTTP(appPort, '/docs/static-img') + browser = await webdriver(appPort, '/docs/static-img') + }) + afterAll(() => { + killApp(app) + }) + runTests(true) + } + ) }) diff --git a/test/integration/next-image-legacy/default/test/index.test.ts b/test/integration/next-image-legacy/default/test/index.test.ts index 794d1288c1636..c5164a68e9bc7 100644 --- a/test/integration/next-image-legacy/default/test/index.test.ts +++ b/test/integration/next-image-legacy/default/test/index.test.ts @@ -1469,17 +1469,20 @@ function runTests(mode) { } describe('Image Component Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/svgo-webpack/test/index.test.ts b/test/integration/next-image-legacy/svgo-webpack/test/index.test.ts index 1d99789c3f54d..512dbbe3e02dd 100644 --- a/test/integration/next-image-legacy/svgo-webpack/test/index.test.ts +++ b/test/integration/next-image-legacy/svgo-webpack/test/index.test.ts @@ -31,26 +31,28 @@ let devOutput }) } ) - - describe('development mode', () => { - beforeAll(async () => { - devOutput = { stdout: '', stderr: '' } - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout: (msg) => { - devOutput.stdout += msg - }, - onStderr: (msg) => { - devOutput.stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + devOutput = { stdout: '', stderr: '' } + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout: (msg) => { + devOutput.stdout += msg + }, + onStderr: (msg) => { + devOutput.stderr += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should print error when invalid Image usage', async () => { - await renderViaHTTP(appPort, '/', {}) - expect(devOutput.stderr).toBeFalsy() - }) - }) + it('should print error when invalid Image usage', async () => { + await renderViaHTTP(appPort, '/', {}) + expect(devOutput.stderr).toBeFalsy() + }) + } + ) } ) diff --git a/test/integration/next-image-legacy/trailing-slash/test/index.test.ts b/test/integration/next-image-legacy/trailing-slash/test/index.test.ts index a732d8b8c30ad..f3e4346ffc3f9 100644 --- a/test/integration/next-image-legacy/trailing-slash/test/index.test.ts +++ b/test/integration/next-image-legacy/trailing-slash/test/index.test.ts @@ -17,33 +17,36 @@ let appPort let app describe('Image Component Trailing Slash Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - it('should include trailing slash when trailingSlash is set on config file during next dev', async () => { - expect.assertions(1) - let browser + it('should include trailing slash when trailingSlash is set on config file during next dev', async () => { + expect.assertions(1) + let browser - try { - browser = await webdriver(appPort, '/') - const id = 'test1' - const srcImage = await browser.eval( - `document.getElementById('${id}').src` - ) - expect(srcImage).toMatch( - /\/_next\/image\/\?url=%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=828&q=75/ - ) - } finally { - if (browser) { - await browser.close() + try { + browser = await webdriver(appPort, '/') + const id = 'test1' + const srcImage = await browser.eval( + `document.getElementById('${id}').src` + ) + expect(srcImage).toMatch( + /\/_next\/image\/\?url=%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=828&q=75/ + ) + } finally { + if (browser) { + await browser.close() + } } - } - }) - }) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/typescript/test/index.test.ts b/test/integration/next-image-legacy/typescript/test/index.test.ts index 77b8f732d80c0..c9dba8f87a66a 100644 --- a/test/integration/next-image-legacy/typescript/test/index.test.ts +++ b/test/integration/next-image-legacy/typescript/test/index.test.ts @@ -55,34 +55,39 @@ describe('TypeScript Image Component', () => { }) } ) - - describe('development mode', () => { - beforeAll(async () => { - output = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout: handleOutput, - onStderr: handleOutput, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + output = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout: handleOutput, + onStderr: handleOutput, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should have image types when enabled', async () => { - const envTypes = await fs.readFile(join(appDir, 'next-env.d.ts'), 'utf8') - expect(envTypes).toContain('image-types/global') - }) + it('should have image types when enabled', async () => { + const envTypes = await fs.readFile( + join(appDir, 'next-env.d.ts'), + 'utf8' + ) + expect(envTypes).toContain('image-types/global') + }) - it('should render the valid Image usage and not print error', async () => { - const html = await renderViaHTTP(appPort, '/valid', {}) - expect(html).toMatch(/This is valid usage of the Image component/) - expect(output).not.toMatch(/Error: Image/) - }) + it('should render the valid Image usage and not print error', async () => { + const html = await renderViaHTTP(appPort, '/valid', {}) + expect(html).toMatch(/This is valid usage of the Image component/) + expect(output).not.toMatch(/Error: Image/) + }) - it('should print error when invalid Image usage', async () => { - await renderViaHTTP(appPort, '/invalid', {}) - expect(output).toMatch(/Error: Image/) - }) - }) + it('should print error when invalid Image usage', async () => { + await renderViaHTTP(appPort, '/invalid', {}) + expect(output).toMatch(/Error: Image/) + }) + } + ) describe('development mode 2', () => { it('should remove global image types when disabled (dev)', async () => { diff --git a/test/integration/next-image-legacy/unicode/test/index.test.ts b/test/integration/next-image-legacy/unicode/test/index.test.ts index ea47777a4373c..2e7060b7c2c82 100644 --- a/test/integration/next-image-legacy/unicode/test/index.test.ts +++ b/test/integration/next-image-legacy/unicode/test/index.test.ts @@ -68,20 +68,23 @@ function runTests() { } describe('Image Component Unicode Image URL', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - browser = await webdriver(appPort, '/') - }) - afterAll(() => { - killApp(app) - if (browser) { - browser.close() - } - }) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + browser = await webdriver(appPort, '/') + }) + afterAll(() => { + killApp(app) + if (browser) { + browser.close() + } + }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-legacy/unoptimized/test/index.test.ts b/test/integration/next-image-legacy/unoptimized/test/index.test.ts index 7a72c5b135ad3..ded6e2bb215f3 100644 --- a/test/integration/next-image-legacy/unoptimized/test/index.test.ts +++ b/test/integration/next-image-legacy/unoptimized/test/index.test.ts @@ -98,17 +98,20 @@ function runTests() { } describe('Unoptimized Image Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/app-dir/test/index.test.ts b/test/integration/next-image-new/app-dir/test/index.test.ts index 61355d8a4e82d..a9cb5c1e42ed4 100644 --- a/test/integration/next-image-new/app-dir/test/index.test.ts +++ b/test/integration/next-image-new/app-dir/test/index.test.ts @@ -1515,17 +1515,20 @@ function runTests(mode) { } describe('Image Component Default Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/app-dir/test/static.test.ts b/test/integration/next-image-new/app-dir/test/static.test.ts index 5d06b9fc73770..a5365f143a738 100644 --- a/test/integration/next-image-new/app-dir/test/static.test.ts +++ b/test/integration/next-image-new/app-dir/test/static.test.ts @@ -263,18 +263,20 @@ describe('Static Image Component Tests', () => { runTests(false) } ) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - html = await renderViaHTTP(appPort, '/static-img') - $ = cheerio.load(html) - browser = await webdriver(appPort, '/static-img') - }) - afterAll(() => { - killApp(app) - }) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + html = await renderViaHTTP(appPort, '/static-img') + $ = cheerio.load(html) + browser = await webdriver(appPort, '/static-img') + }) + afterAll(() => { + killApp(app) + }) + runTests(true) + } + ) }) diff --git a/test/integration/next-image-new/asset-prefix/test/index.test.js b/test/integration/next-image-new/asset-prefix/test/index.test.js index cd3b93fa88738..c6b425098e541 100644 --- a/test/integration/next-image-new/asset-prefix/test/index.test.js +++ b/test/integration/next-image-new/asset-prefix/test/index.test.js @@ -16,46 +16,49 @@ let appPort let app describe('Image Component assetPrefix Tests', () => { - describe('development mode', () => { - let stdout = '' - let stderr = '' - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout(msg) { - stdout += msg - }, - onStderr(msg) { - stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let stdout = '' + let stderr = '' + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout(msg) { + stdout += msg + }, + onStderr(msg) { + stderr += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should include assetPrefix when placeholder=blur during next dev', async () => { - const browser = await webdriver(appPort, '/') - const id = 'test1' - const bgImage = await browser.eval( - `document.getElementById('${id}').style['background-image']` - ) - if (process.env.TURBOPACK) { - expect(bgImage).toContain('data:image/svg+xml;') - } else { - expect(bgImage).toMatch( - /\/_next\/image\?url=https%3A%2F%2Fexample\.vercel\.sh%2Fpre%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=8&q=70/ + it('should include assetPrefix when placeholder=blur during next dev', async () => { + const browser = await webdriver(appPort, '/') + const id = 'test1' + const bgImage = await browser.eval( + `document.getElementById('${id}').style['background-image']` ) - } - }) + if (process.env.TURBOPACK) { + expect(bgImage).toContain('data:image/svg+xml;') + } else { + expect(bgImage).toMatch( + /\/_next\/image\?url=https%3A%2F%2Fexample\.vercel\.sh%2Fpre%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=8&q=70/ + ) + } + }) - it('should not log a deprecation warning about using `images.domains`', async () => { - await webdriver(appPort, '/') - const warningMessage = - 'The "images.domains" configuration is deprecated. Please use "images.remotePatterns" configuration instead.' + it('should not log a deprecation warning about using `images.domains`', async () => { + await webdriver(appPort, '/') + const warningMessage = + 'The "images.domains" configuration is deprecated. Please use "images.remotePatterns" configuration instead.' - expect(stderr).not.toContain(warningMessage) - expect(stdout).not.toContain(warningMessage) - }) - }) + expect(stderr).not.toContain(warningMessage) + expect(stdout).not.toContain(warningMessage) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { @@ -84,6 +87,7 @@ describe('Image Component assetPrefix Tests', () => { expect(bgImage).toMatch('data:image/jpeg;base64') }) + // eslint-disable-next-line jest/no-identical-title it('should not log a deprecation warning about using `images.domains`', async () => { await webdriver(appPort, '/') const warningMessage = diff --git a/test/integration/next-image-new/base-path/test/index.test.js b/test/integration/next-image-new/base-path/test/index.test.js index 9aad9cff077cc..dc9bdb4b77549 100644 --- a/test/integration/next-image-new/base-path/test/index.test.js +++ b/test/integration/next-image-new/base-path/test/index.test.js @@ -195,17 +195,20 @@ function runTests(mode) { } describe('Image Component basePath Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/base-path/test/static.test.js b/test/integration/next-image-new/base-path/test/static.test.js index 351a0bca33286..58006097f3f89 100644 --- a/test/integration/next-image-new/base-path/test/static.test.js +++ b/test/integration/next-image-new/base-path/test/static.test.js @@ -209,18 +209,20 @@ describe('Static Image Component Tests for basePath', () => { runTests(false) } ) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - html = await renderViaHTTP(appPort, '/docs/static-img') - $ = cheerio.load(html) - browser = await webdriver(appPort, '/docs/static-img') - }) - afterAll(() => { - killApp(app) - }) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + html = await renderViaHTTP(appPort, '/docs/static-img') + $ = cheerio.load(html) + browser = await webdriver(appPort, '/docs/static-img') + }) + afterAll(() => { + killApp(app) + }) + runTests(true) + } + ) }) diff --git a/test/integration/next-image-new/both-basepath-trailingslash/test/index.test.ts b/test/integration/next-image-new/both-basepath-trailingslash/test/index.test.ts index 1bde61913531f..5c19e86b964e1 100644 --- a/test/integration/next-image-new/both-basepath-trailingslash/test/index.test.ts +++ b/test/integration/next-image-new/both-basepath-trailingslash/test/index.test.ts @@ -42,15 +42,18 @@ const runTests = () => { } describe('Image Component basePath + trailingSlash Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/default/test/index.test.ts b/test/integration/next-image-new/default/test/index.test.ts index 3b839ef907ba3..163ac71478287 100644 --- a/test/integration/next-image-new/default/test/index.test.ts +++ b/test/integration/next-image-new/default/test/index.test.ts @@ -1523,17 +1523,20 @@ function runTests(mode) { } describe('Image Component Default Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/default/test/static.test.ts b/test/integration/next-image-new/default/test/static.test.ts index e2599efbc498c..4377bda5c2c0b 100644 --- a/test/integration/next-image-new/default/test/static.test.ts +++ b/test/integration/next-image-new/default/test/static.test.ts @@ -275,18 +275,20 @@ describe('Static Image Component Tests', () => { runTests(false) } ) - - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - html = await renderViaHTTP(appPort, '/static-img') - $ = cheerio.load(html) - browser = await webdriver(appPort, '/static-img') - }) - afterAll(() => { - killApp(app) - }) - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + html = await renderViaHTTP(appPort, '/static-img') + $ = cheerio.load(html) + browser = await webdriver(appPort, '/static-img') + }) + afterAll(() => { + killApp(app) + }) + runTests(true) + } + ) }) diff --git a/test/integration/next-image-new/export-config/test/index.test.ts b/test/integration/next-image-new/export-config/test/index.test.ts index 029158e0f2855..2b7a067a92e2d 100644 --- a/test/integration/next-image-new/export-config/test/index.test.ts +++ b/test/integration/next-image-new/export-config/test/index.test.ts @@ -16,26 +16,29 @@ let app let stderr = '' describe('next/image with output export config', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg || '' - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg || '' + }, + }) }) - }) - afterAll(async () => { - await killApp(app) - stderr = '' - }) - it('should error', async () => { - const browser = await webdriver(appPort, '/') - const msg = - "Image Optimization using the default loader is not compatible with `{ output: 'export' }`." - expect(await hasRedbox(browser)).toBe(true) - expect(await getRedboxHeader(browser)).toContain(msg) - expect(stderr).toContain(msg) - }) - }) + afterAll(async () => { + await killApp(app) + stderr = '' + }) + it('should error', async () => { + const browser = await webdriver(appPort, '/') + const msg = + "Image Optimization using the default loader is not compatible with `{ output: 'export' }`." + expect(await hasRedbox(browser)).toBe(true) + expect(await getRedboxHeader(browser)).toContain(msg) + expect(stderr).toContain(msg) + }) + } + ) }) diff --git a/test/integration/next-image-new/invalid-image-import/test/index.test.ts b/test/integration/next-image-new/invalid-image-import/test/index.test.ts index cea23ffd31f05..ed2a33f98f5a7 100644 --- a/test/integration/next-image-new/invalid-image-import/test/index.test.ts +++ b/test/integration/next-image-new/invalid-image-import/test/index.test.ts @@ -49,24 +49,27 @@ function runTests({ isDev }) { } describe('Missing Import Image Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - stderr = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStderr(msg) { - stderr += msg || '' - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + stderr = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStderr(msg) { + stderr += msg || '' + }, + }) + }) + afterAll(async () => { + if (app) { + await killApp(app) + } }) - }) - afterAll(async () => { - if (app) { - await killApp(app) - } - }) - runTests({ isDev: true }) - }) + runTests({ isDev: true }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/loader-config-edge-runtime/test/index.test.ts b/test/integration/next-image-new/loader-config-edge-runtime/test/index.test.ts index 539d54f179679..142b8ef324265 100644 --- a/test/integration/next-image-new/loader-config-edge-runtime/test/index.test.ts +++ b/test/integration/next-image-new/loader-config-edge-runtime/test/index.test.ts @@ -43,20 +43,23 @@ function runTests() { } describe('Image Loader Config with Edge Runtime', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - browser = await webdriver(appPort, '/') - }) - afterAll(() => { - killApp(app) - if (browser) { - browser.close() - } - }) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + browser = await webdriver(appPort, '/') + }) + afterAll(() => { + killApp(app) + if (browser) { + browser.close() + } + }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/middleware/test/index.test.ts b/test/integration/next-image-new/middleware/test/index.test.ts index 294a6afa933f5..f3897e94d752d 100644 --- a/test/integration/next-image-new/middleware/test/index.test.ts +++ b/test/integration/next-image-new/middleware/test/index.test.ts @@ -10,30 +10,35 @@ let app: Awaited<ReturnType<typeof launchApp>> let output = '' describe('Image with middleware in edge func', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout: (s) => { - output += s - }, - onStderr: (s) => { - output += s - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout: (s) => { + output += s + }, + onStderr: (s) => { + output += s + }, + }) + }) + afterAll(async () => { + await killApp(app) }) - }) - afterAll(async () => { - await killApp(app) - }) - it('should not error', async () => { - /** + it('should not error', async () => { + /** ⚠️ ../../../../packages/next/dist/esm/client/image-component.js Attempted import error: 'preload' is not exported from 'react-dom' (imported as 'preload'). */ - await webdriver(appPort, '/') - await check(() => output, /compiled \//i) - expect(output).not.toContain(`'preload' is not exported from 'react-dom'`) - }) - }) + await webdriver(appPort, '/') + await check(() => output, /compiled \//i) + expect(output).not.toContain( + `'preload' is not exported from 'react-dom'` + ) + }) + } + ) }) diff --git a/test/integration/next-image-new/svgo-webpack/test/index.test.ts b/test/integration/next-image-new/svgo-webpack/test/index.test.ts index 179c5d66e66a7..0a3a7cb17fde7 100644 --- a/test/integration/next-image-new/svgo-webpack/test/index.test.ts +++ b/test/integration/next-image-new/svgo-webpack/test/index.test.ts @@ -31,29 +31,31 @@ let devOutput }) } ) - - describe('development mode', () => { - beforeAll(async () => { - devOutput = { stdout: '', stderr: '' } - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout: (msg) => { - devOutput.stdout += msg - }, - onStderr: (msg) => { - devOutput.stderr += msg - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + devOutput = { stdout: '', stderr: '' } + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout: (msg) => { + devOutput.stdout += msg + }, + onStderr: (msg) => { + devOutput.stderr += msg + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should print error when invalid Image usage', async () => { - await renderViaHTTP(appPort, '/', {}) - const errors = devOutput.stderr - .split('\n') - .filter((line) => line && !line.trim().startsWith('⚠️')) - expect(errors).toEqual([]) - }) - }) + it('should print error when invalid Image usage', async () => { + await renderViaHTTP(appPort, '/', {}) + const errors = devOutput.stderr + .split('\n') + .filter((line) => line && !line.trim().startsWith('⚠️')) + expect(errors).toEqual([]) + }) + } + ) } ) diff --git a/test/integration/next-image-new/trailing-slash/test/index.test.ts b/test/integration/next-image-new/trailing-slash/test/index.test.ts index a732d8b8c30ad..f3e4346ffc3f9 100644 --- a/test/integration/next-image-new/trailing-slash/test/index.test.ts +++ b/test/integration/next-image-new/trailing-slash/test/index.test.ts @@ -17,33 +17,36 @@ let appPort let app describe('Image Component Trailing Slash Tests', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - it('should include trailing slash when trailingSlash is set on config file during next dev', async () => { - expect.assertions(1) - let browser + it('should include trailing slash when trailingSlash is set on config file during next dev', async () => { + expect.assertions(1) + let browser - try { - browser = await webdriver(appPort, '/') - const id = 'test1' - const srcImage = await browser.eval( - `document.getElementById('${id}').src` - ) - expect(srcImage).toMatch( - /\/_next\/image\/\?url=%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=828&q=75/ - ) - } finally { - if (browser) { - await browser.close() + try { + browser = await webdriver(appPort, '/') + const id = 'test1' + const srcImage = await browser.eval( + `document.getElementById('${id}').src` + ) + expect(srcImage).toMatch( + /\/_next\/image\/\?url=%2F_next%2Fstatic%2Fmedia%2Ftest(.+).jpg&w=828&q=75/ + ) + } finally { + if (browser) { + await browser.close() + } } - } - }) - }) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/next-image-new/typescript/test/index.test.ts b/test/integration/next-image-new/typescript/test/index.test.ts index db65eb7553bc4..57929d8f5fec4 100644 --- a/test/integration/next-image-new/typescript/test/index.test.ts +++ b/test/integration/next-image-new/typescript/test/index.test.ts @@ -55,34 +55,39 @@ describe('TypeScript Image Component', () => { }) } ) - - describe('development mode', () => { - beforeAll(async () => { - output = '' - appPort = await findPort() - app = await launchApp(appDir, appPort, { - onStdout: handleOutput, - onStderr: handleOutput, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + output = '' + appPort = await findPort() + app = await launchApp(appDir, appPort, { + onStdout: handleOutput, + onStderr: handleOutput, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - it('should have image types when enabled', async () => { - const envTypes = await fs.readFile(join(appDir, 'next-env.d.ts'), 'utf8') - expect(envTypes).toContain('image-types/global') - }) + it('should have image types when enabled', async () => { + const envTypes = await fs.readFile( + join(appDir, 'next-env.d.ts'), + 'utf8' + ) + expect(envTypes).toContain('image-types/global') + }) - it('should render the valid Image usage and not print error', async () => { - const html = await renderViaHTTP(appPort, '/valid', {}) - expect(html).toMatch(/This is valid usage of the Image component/) - expect(output).not.toMatch(/Error: Image/) - }) + it('should render the valid Image usage and not print error', async () => { + const html = await renderViaHTTP(appPort, '/valid', {}) + expect(html).toMatch(/This is valid usage of the Image component/) + expect(output).not.toMatch(/Error: Image/) + }) - it('should print error when invalid Image usage', async () => { - await renderViaHTTP(appPort, '/invalid', {}) - expect(output).toMatch(/Error: Image/) - }) - }) + it('should print error when invalid Image usage', async () => { + await renderViaHTTP(appPort, '/invalid', {}) + expect(output).toMatch(/Error: Image/) + }) + } + ) it('should remove global image types when disabled (dev)', async () => { const content = await fs.readFile(nextConfig, 'utf8') diff --git a/test/integration/next-image-new/unicode/test/index.test.ts b/test/integration/next-image-new/unicode/test/index.test.ts index ea47777a4373c..2e7060b7c2c82 100644 --- a/test/integration/next-image-new/unicode/test/index.test.ts +++ b/test/integration/next-image-new/unicode/test/index.test.ts @@ -68,20 +68,23 @@ function runTests() { } describe('Image Component Unicode Image URL', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - browser = await webdriver(appPort, '/') - }) - afterAll(() => { - killApp(app) - if (browser) { - browser.close() - } - }) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + browser = await webdriver(appPort, '/') + }) + afterAll(() => { + killApp(app) + if (browser) { + browser.close() + } + }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/no-page-props/test/index.test.js b/test/integration/no-page-props/test/index.test.js index 66e39e62d624e..02740082b0f61 100644 --- a/test/integration/no-page-props/test/index.test.js +++ b/test/integration/no-page-props/test/index.test.js @@ -80,15 +80,18 @@ const runTests = () => { } describe('Error no pageProps', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/nullish-config/test/index.test.js b/test/integration/nullish-config/test/index.test.js index ecb609bec9509..93076a458bd1c 100644 --- a/test/integration/nullish-config/test/index.test.js +++ b/test/integration/nullish-config/test/index.test.js @@ -62,23 +62,25 @@ const runTests = (type) => { describe('Nullish configs in next.config.js', () => { afterAll(() => fs.remove(nextConfig)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(() => { + getStdout = async () => { + let stdout = '' + const app = await launchApp(appDir, await findPort(), { + onStdout: (msg) => { + stdout += msg + }, + }) + await killApp(app) + return stdout + } + }) - describe('development mode', () => { - beforeAll(() => { - getStdout = async () => { - let stdout = '' - const app = await launchApp(appDir, await findPort(), { - onStdout: (msg) => { - stdout += msg - }, - }) - await killApp(app) - return stdout - } - }) - - runTests('dev') - }) + runTests('dev') + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/optional-chaining-nullish-coalescing/test/index.test.js b/test/integration/optional-chaining-nullish-coalescing/test/index.test.js index 3702f7fc5bfcd..b323322ceb5a5 100644 --- a/test/integration/optional-chaining-nullish-coalescing/test/index.test.js +++ b/test/integration/optional-chaining-nullish-coalescing/test/index.test.js @@ -29,15 +29,18 @@ const runTests = () => { } describe('Optional chaining and nullish coalescing support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/port-env-var/test/index.test.js b/test/integration/port-env-var/test/index.test.js index 3e60017d1c3e3..d11f6af098e14 100644 --- a/test/integration/port-env-var/test/index.test.js +++ b/test/integration/port-env-var/test/index.test.js @@ -22,19 +22,22 @@ const runTests = () => { } describe('PORT environment variable', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await runNextCommandDev([appDir], undefined, { - env: { - PORT: appPort, - }, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await runNextCommandDev([appDir], undefined, { + env: { + PORT: appPort, + }, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/prerender-fallback-encoding/test/index.test.js b/test/integration/prerender-fallback-encoding/test/index.test.js index 94e5900e5f3a3..e9472fc966a92 100644 --- a/test/integration/prerender-fallback-encoding/test/index.test.js +++ b/test/integration/prerender-fallback-encoding/test/index.test.js @@ -325,17 +325,20 @@ function runTests(isDev) { } describe('Fallback path encoding', () => { - describe('development mode', () => { - beforeAll(async () => { - await fs.remove(join(appDir, '.next')) - appPort = await findPort() - app = await launchApp(appDir, appPort) - buildId = 'development' - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + await fs.remove(join(appDir, '.next')) + appPort = await findPort() + app = await launchApp(appDir, appPort) + buildId = 'development' + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/prerender-preview/test/index.test.js b/test/integration/prerender-preview/test/index.test.js index fb9ee09335407..57c1a109edb2c 100644 --- a/test/integration/prerender-preview/test/index.test.js +++ b/test/integration/prerender-preview/test/index.test.js @@ -267,119 +267,133 @@ function runTests(startServer = nextStart) { } describe('Prerender Preview Mode', () => { - describe('Development Mode', () => { - let appPort, app - it('should start development application', async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - - let previewCookieString - it('should enable preview mode', async () => { - const res = await fetchViaHTTP(appPort, '/api/preview', { lets: 'goooo' }) - expect(res.status).toBe(200) - - const cookies = res.headers.get('set-cookie').split(',').map(cookie.parse) - - expect(cookies.length).toBe(2) - previewCookieString = - cookie.serialize('__prerender_bypass', cookies[0].__prerender_bypass) + - '; ' + - cookie.serialize('__next_preview_data', cookies[1].__next_preview_data) - }) - - it('should return cookies to be expired after dev server reboot', async () => { - await killApp(app) - appPort = await findPort() - app = await launchApp(appDir, appPort) - - const res = await fetchViaHTTP( - appPort, - '/', - {}, - { headers: { Cookie: previewCookieString } } - ) - expect(res.status).toBe(200) - - const body = await res.text() - // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('"err"') - expect(body).not.toContain('TypeError') - expect(body).not.toContain('previewModeId') - - const cookies = res.headers - .get('set-cookie') - .replace(/(=(?!Lax)\w{3}),/g, '$1') - .split(',') - .map(cookie.parse) - - expect(cookies.length).toBe(2) - }) - - /** @type {import('next-webdriver').Chain} */ - let browser - it('should start the client-side browser', async () => { - browser = await webdriver( - appPort, - '/api/preview?' + qs.stringify({ client: 'mode' }) - ) - }) - - it('should fetch preview data on SSR', async () => { - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#props-pre') - // expect(await browser.elementById('props-pre').text()).toBe('Has No Props') - // await new Promise(resolve => setTimeout(resolve, 2000)) - expect(await browser.elementById('props-pre').text()).toBe( - 'true and {"client":"mode"}' - ) - }) - - it('should fetch preview data on CST', async () => { - await browser.get(`http://localhost:${appPort}/to-index`) - await browser.waitForElementByCss('#to-index') - await browser.eval('window.itdidnotrefresh = "hello"') - await browser.elementById('to-index').click() - await browser.waitForElementByCss('#props-pre') - expect(await browser.eval('window.itdidnotrefresh')).toBe('hello') - expect(await browser.elementById('props-pre').text()).toBe( - 'true and {"client":"mode"}' - ) - }) - - it('should fetch prerendered data', async () => { - await browser.get(`http://localhost:${appPort}/api/reset`) - - await browser.get(`http://localhost:${appPort}/`) - await browser.waitForElementByCss('#props-pre') - expect(await browser.elementById('props-pre').text()).toBe( - 'false and null' - ) - }) - - it('should fetch live static props with preview active', async () => { - await browser.get(`http://localhost:${appPort}/`) - - await browser.waitForElementByCss('#ssg-random') - const initialRandom = await browser.elementById('ssg-random').text() - - // reload static props with router.replace - await browser.elementById('reload-props').click() - - // wait for route change to complete and set updated state - await browser.waitForElementByCss('#ssg-reloaded') - - // assert that the random number from static props has changed (thus, was re-evaluated) - expect(await browser.elementById('ssg-random').text()).not.toBe( - initialRandom - ) - }) - - afterAll(async () => { - await browser.close() - await killApp(app) - }) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + let appPort, app + it('should start development application', async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + + let previewCookieString + it('should enable preview mode', async () => { + const res = await fetchViaHTTP(appPort, '/api/preview', { + lets: 'goooo', + }) + expect(res.status).toBe(200) + + const cookies = res.headers + .get('set-cookie') + .split(',') + .map(cookie.parse) + + expect(cookies.length).toBe(2) + previewCookieString = + cookie.serialize( + '__prerender_bypass', + cookies[0].__prerender_bypass + ) + + '; ' + + cookie.serialize( + '__next_preview_data', + cookies[1].__next_preview_data + ) + }) + + it('should return cookies to be expired after dev server reboot', async () => { + await killApp(app) + appPort = await findPort() + app = await launchApp(appDir, appPort) + + const res = await fetchViaHTTP( + appPort, + '/', + {}, + { headers: { Cookie: previewCookieString } } + ) + expect(res.status).toBe(200) + + const body = await res.text() + // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" + expect(body).not.toContain('"err"') + expect(body).not.toContain('TypeError') + expect(body).not.toContain('previewModeId') + + const cookies = res.headers + .get('set-cookie') + .replace(/(=(?!Lax)\w{3}),/g, '$1') + .split(',') + .map(cookie.parse) + + expect(cookies.length).toBe(2) + }) + + /** @type {import('next-webdriver').Chain} */ + let browser + it('should start the client-side browser', async () => { + browser = await webdriver( + appPort, + '/api/preview?' + qs.stringify({ client: 'mode' }) + ) + }) + + it('should fetch preview data on SSR', async () => { + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#props-pre') + // expect(await browser.elementById('props-pre').text()).toBe('Has No Props') + // await new Promise(resolve => setTimeout(resolve, 2000)) + expect(await browser.elementById('props-pre').text()).toBe( + 'true and {"client":"mode"}' + ) + }) + + it('should fetch preview data on CST', async () => { + await browser.get(`http://localhost:${appPort}/to-index`) + await browser.waitForElementByCss('#to-index') + await browser.eval('window.itdidnotrefresh = "hello"') + await browser.elementById('to-index').click() + await browser.waitForElementByCss('#props-pre') + expect(await browser.eval('window.itdidnotrefresh')).toBe('hello') + expect(await browser.elementById('props-pre').text()).toBe( + 'true and {"client":"mode"}' + ) + }) + + it('should fetch prerendered data', async () => { + await browser.get(`http://localhost:${appPort}/api/reset`) + + await browser.get(`http://localhost:${appPort}/`) + await browser.waitForElementByCss('#props-pre') + expect(await browser.elementById('props-pre').text()).toBe( + 'false and null' + ) + }) + + it('should fetch live static props with preview active', async () => { + await browser.get(`http://localhost:${appPort}/`) + + await browser.waitForElementByCss('#ssg-random') + const initialRandom = await browser.elementById('ssg-random').text() + + // reload static props with router.replace + await browser.elementById('reload-props').click() + + // wait for route change to complete and set updated state + await browser.waitForElementByCss('#ssg-reloaded') + + // assert that the random number from static props has changed (thus, was re-evaluated) + expect(await browser.elementById('ssg-random').text()).not.toBe( + initialRandom + ) + }) + + afterAll(async () => { + await browser.close() + await killApp(app) + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/preview-fallback/test/index.test.js b/test/integration/preview-fallback/test/index.test.js index aee7d5456e289..f3318321eec79 100644 --- a/test/integration/preview-fallback/test/index.test.js +++ b/test/integration/preview-fallback/test/index.test.js @@ -267,15 +267,18 @@ function runTests(isDev) { } describe('Preview mode with fallback pages', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/relay-graphql-swc-multi-project/test/index.test.js b/test/integration/relay-graphql-swc-multi-project/test/index.test.js index 072ffdce14ea8..852eb99a561af 100644 --- a/test/integration/relay-graphql-swc-multi-project/test/index.test.js +++ b/test/integration/relay-graphql-swc-multi-project/test/index.test.js @@ -39,37 +39,40 @@ const runRelayCompiler = () => { beforeAll(() => { runRelayCompiler() }) - - describe('development mode', () => { - describe('project-a', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(projectAAppDir, appPort, { - cwd: projectAAppDir, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + describe('project-a', () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(projectAAppDir, appPort, { + cwd: projectAAppDir, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - runTests('Project A') - }) + runTests('Project A') + }) - describe('project-b', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(projectBAppDir, appPort, { - cwd: projectBAppDir, + describe('project-b', () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(projectBAppDir, appPort, { + cwd: projectBAppDir, + }) }) - }) - afterAll(() => killApp(app)) + afterAll(() => killApp(app)) - runTests('Project B') - }) - }) + runTests('Project B') + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { + // eslint-disable-next-line jest/no-identical-title describe('project-a', () => { beforeAll(async () => { await nextBuild(projectAAppDir, [], { cwd: projectAAppDir }) @@ -82,6 +85,7 @@ const runRelayCompiler = () => { runTests('Project A') }) + // eslint-disable-next-line jest/no-identical-title describe('project-b', () => { beforeAll(async () => { await nextBuild(projectBAppDir, [], { cwd: projectBAppDir }) diff --git a/test/integration/relay-graphql-swc-single-project/test/index.test.js b/test/integration/relay-graphql-swc-single-project/test/index.test.js index 5347752a98a64..9ae4748dd3f6f 100644 --- a/test/integration/relay-graphql-swc-single-project/test/index.test.js +++ b/test/integration/relay-graphql-swc-single-project/test/index.test.js @@ -31,16 +31,19 @@ const runRelayCompiler = () => { } describe('Relay Compiler Transform - Single Project Config', () => { - describe('development mode', () => { - beforeAll(async () => { - runRelayCompiler() - appPort = await findPort() - app = await launchApp(appDir, appPort, { cwd: appDir }) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + runRelayCompiler() + appPort = await findPort() + app = await launchApp(appDir, appPort, { cwd: appDir }) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/rewrite-with-browser-history/test/index.test.js b/test/integration/rewrite-with-browser-history/test/index.test.js index 8ac0c77e6cfb8..b9436f14ca251 100644 --- a/test/integration/rewrite-with-browser-history/test/index.test.js +++ b/test/integration/rewrite-with-browser-history/test/index.test.js @@ -39,15 +39,18 @@ const runTests = () => { } describe('rewrites persist with browser history actions', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/rewrites-client-resolving/test/index.test.js b/test/integration/rewrites-client-resolving/test/index.test.js index 3ea604169dc90..4c48c1a848b76 100644 --- a/test/integration/rewrites-client-resolving/test/index.test.js +++ b/test/integration/rewrites-client-resolving/test/index.test.js @@ -61,15 +61,18 @@ const runTests = () => { } describe('Client-side rewrites resolving', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/rewrites-destination-query-array/test/index.test.js b/test/integration/rewrites-destination-query-array/test/index.test.js index fdef43574d613..5a8650fb72113 100644 --- a/test/integration/rewrites-destination-query-array/test/index.test.js +++ b/test/integration/rewrites-destination-query-array/test/index.test.js @@ -23,15 +23,18 @@ const runTests = () => { } describe('rewrites destination query', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/rewrites-has-condition/test/index.test.js b/test/integration/rewrites-has-condition/test/index.test.js index a47e8566f7a86..28f9167581652 100644 --- a/test/integration/rewrites-has-condition/test/index.test.js +++ b/test/integration/rewrites-has-condition/test/index.test.js @@ -46,15 +46,18 @@ const runTests = () => { } describe('rewrites has condition', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/rewrites-manual-href-as/test/index.test.js b/test/integration/rewrites-manual-href-as/test/index.test.js index 7514a64fc20cb..576edf01b7c1b 100644 --- a/test/integration/rewrites-manual-href-as/test/index.test.js +++ b/test/integration/rewrites-manual-href-as/test/index.test.js @@ -160,15 +160,18 @@ const runTests = () => { } describe('rewrites manual href/as', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/route-index/test/index.test.js b/test/integration/route-index/test/index.test.js index d4c91fb1ec903..fd2b240cf18d8 100644 --- a/test/integration/route-index/test/index.test.js +++ b/test/integration/route-index/test/index.test.js @@ -48,15 +48,18 @@ const runTests = () => { } describe('Route index handling', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/route-indexes/test/index.test.js b/test/integration/route-indexes/test/index.test.js index 9532341ee53c3..763d19d61a657 100644 --- a/test/integration/route-indexes/test/index.test.js +++ b/test/integration/route-indexes/test/index.test.js @@ -113,15 +113,18 @@ const runTests = () => { } describe('Route indexes handling', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/route-load-cancel/test/index.test.js b/test/integration/route-load-cancel/test/index.test.js index 5fe339677248d..aa6a87ef218d3 100644 --- a/test/integration/route-load-cancel/test/index.test.js +++ b/test/integration/route-load-cancel/test/index.test.js @@ -35,15 +35,18 @@ function runTests() { } describe('next/dynamic', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/router-hash-navigation/test/index.test.js b/test/integration/router-hash-navigation/test/index.test.js index 6d6e7ffa6fbe7..96883c229c94f 100644 --- a/test/integration/router-hash-navigation/test/index.test.js +++ b/test/integration/router-hash-navigation/test/index.test.js @@ -25,17 +25,20 @@ function runTests() { } describe('router.isReady', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/router-is-ready-app-gip/test/index.test.js b/test/integration/router-is-ready-app-gip/test/index.test.js index 8386b0ffd3dde..6ce48535bde16 100644 --- a/test/integration/router-is-ready-app-gip/test/index.test.js +++ b/test/integration/router-is-ready-app-gip/test/index.test.js @@ -49,18 +49,21 @@ function runTests() { } describe('router.isReady with appGip', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - invalidPage.restore() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + invalidPage.restore() + }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/router-is-ready/test/index.test.js b/test/integration/router-is-ready/test/index.test.js index 9fe2838c6322a..8b4ba72f2f356 100644 --- a/test/integration/router-is-ready/test/index.test.js +++ b/test/integration/router-is-ready/test/index.test.js @@ -79,18 +79,21 @@ function runTests() { } describe('router.isReady', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - await killApp(app) - invalidPage.restore() - }) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + await killApp(app) + invalidPage.restore() + }) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/router-prefetch/test/index.test.js b/test/integration/router-prefetch/test/index.test.js index 715518f589b54..25a51f5b96bbb 100644 --- a/test/integration/router-prefetch/test/index.test.js +++ b/test/integration/router-prefetch/test/index.test.js @@ -26,28 +26,31 @@ const didResolveAfterPrefetch = async () => { } describe('Router prefetch', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - it('should not prefetch', async () => { - const browser = await webdriver(appPort, '/') - const links = await browser - .elementByCss('#prefetch-button') - .click() - .elementsByCss('link[rel=prefetch]') + it('should not prefetch', async () => { + const browser = await webdriver(appPort, '/') + const links = await browser + .elementByCss('#prefetch-button') + .click() + .elementsByCss('link[rel=prefetch]') - expect(links.length).toBe(0) - await browser.close() - }) + expect(links.length).toBe(0) + await browser.close() + }) - it('should resolve prefetch promise', async () => { - await didResolveAfterPrefetch() - }) - }) + it('should resolve prefetch promise', async () => { + await didResolveAfterPrefetch() + }) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/router-rerender/test/index.test.js b/test/integration/router-rerender/test/index.test.js index 5bb4b5a5669ac..c04d0f29b6c0f 100644 --- a/test/integration/router-rerender/test/index.test.js +++ b/test/integration/router-rerender/test/index.test.js @@ -33,15 +33,18 @@ const runTests = () => { } describe('router rerender', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/scroll-back-restoration/test/index.test.js b/test/integration/scroll-back-restoration/test/index.test.js index 8927043400122..d96a60ae2a3a1 100644 --- a/test/integration/scroll-back-restoration/test/index.test.js +++ b/test/integration/scroll-back-restoration/test/index.test.js @@ -64,15 +64,18 @@ const runTests = () => { } describe('Scroll Back Restoration Support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/scroll-forward-restoration/test/index.test.js b/test/integration/scroll-forward-restoration/test/index.test.js index 406502ab41471..0bee863996848 100644 --- a/test/integration/scroll-forward-restoration/test/index.test.js +++ b/test/integration/scroll-forward-restoration/test/index.test.js @@ -72,15 +72,18 @@ const runTests = () => { } describe('Scroll Forward Restoration Support', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/server-asset-modules/test/index.test.js b/test/integration/server-asset-modules/test/index.test.js index 56d5cb7e267b3..7d827e97d8149 100644 --- a/test/integration/server-asset-modules/test/index.test.js +++ b/test/integration/server-asset-modules/test/index.test.js @@ -26,15 +26,18 @@ function runTests() { } describe('serverside asset modules', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/src-dir-support-double-dir/test/index.test.js b/test/integration/src-dir-support-double-dir/test/index.test.js index 6eda291e34d3c..1d57619a3be5a 100644 --- a/test/integration/src-dir-support-double-dir/test/index.test.js +++ b/test/integration/src-dir-support-double-dir/test/index.test.js @@ -27,15 +27,18 @@ function runTests(dev) { } describe('Dynamic Routing', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests(true) - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/src-dir-support/test/index.test.js b/test/integration/src-dir-support/test/index.test.js index 6e2b1d7eb94cd..6052e7c287686 100644 --- a/test/integration/src-dir-support/test/index.test.js +++ b/test/integration/src-dir-support/test/index.test.js @@ -76,15 +76,18 @@ function runTests() { } describe('Dynamic Routing', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/ssg-data-404/test/index.test.js b/test/integration/ssg-data-404/test/index.test.js index 3096cc37b0644..302a622ed505d 100644 --- a/test/integration/ssg-data-404/test/index.test.js +++ b/test/integration/ssg-data-404/test/index.test.js @@ -52,35 +52,38 @@ describe('SSG data 404', () => { return } - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) - const proxy = httpProxy.createProxyServer({ - target: `http://localhost:${appPort}`, - }) - proxyPort = await findPort() - - proxyServer = http.createServer((req, res) => { - if (should404Data && req.url.match(/\/_next\/data/)) { - res.statusCode = 404 - return res.end('not found') - } - proxy.web(req, res) - }) + const proxy = httpProxy.createProxyServer({ + target: `http://localhost:${appPort}`, + }) + proxyPort = await findPort() + + proxyServer = http.createServer((req, res) => { + if (should404Data && req.url.match(/\/_next\/data/)) { + res.statusCode = 404 + return res.end('not found') + } + proxy.web(req, res) + }) - await new Promise((resolve) => { - proxyServer.listen(proxyPort, () => resolve()) + await new Promise((resolve) => { + proxyServer.listen(proxyPort, () => resolve()) + }) + }) + afterAll(async () => { + await killApp(app) + proxyServer.close() }) - }) - afterAll(async () => { - await killApp(app) - proxyServer.close() - }) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/ssg-dynamic-routes-404-page/test/index.test.js b/test/integration/ssg-dynamic-routes-404-page/test/index.test.js index 0dbd6414a08d7..bea7e4acb34fc 100644 --- a/test/integration/ssg-dynamic-routes-404-page/test/index.test.js +++ b/test/integration/ssg-dynamic-routes-404-page/test/index.test.js @@ -45,14 +45,16 @@ describe('Custom 404 Page for static site generation with dynamic routes', () => runTests('server') } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests('dev') - }) + runTests('dev') + } + ) }) diff --git a/test/integration/static-page-name/test/index.test.js b/test/integration/static-page-name/test/index.test.js index 03ddf9b686896..84b32de1ce361 100644 --- a/test/integration/static-page-name/test/index.test.js +++ b/test/integration/static-page-name/test/index.test.js @@ -31,14 +31,17 @@ const runTests = () => { } describe('Static Page Name', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTests() - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/trailing-slash-dist/test/index.test.js b/test/integration/trailing-slash-dist/test/index.test.js index f596557d9c6d7..7826069c964f9 100644 --- a/test/integration/trailing-slash-dist/test/index.test.js +++ b/test/integration/trailing-slash-dist/test/index.test.js @@ -27,12 +27,15 @@ const runTest = (mode = 'server') => { } describe('Trailing slash in distDir', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - runTest('dev') - }) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) + runTest('dev') + } + ) }) diff --git a/test/integration/trailing-slashes-href-resolving/test/index.test.js b/test/integration/trailing-slashes-href-resolving/test/index.test.js index ea6d1171af2ef..3c3e625eed55c 100644 --- a/test/integration/trailing-slashes-href-resolving/test/index.test.js +++ b/test/integration/trailing-slashes-href-resolving/test/index.test.js @@ -93,15 +93,18 @@ const runTests = (dev) => { } describe('href resolving trailing-slash', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests(true) - }) + runTests(true) + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => { diff --git a/test/integration/trailing-slashes-rewrite/test/index.test.js b/test/integration/trailing-slashes-rewrite/test/index.test.js index 851c2f433a40c..14cbc467ad5ea 100644 --- a/test/integration/trailing-slashes-rewrite/test/index.test.js +++ b/test/integration/trailing-slashes-rewrite/test/index.test.js @@ -75,30 +75,32 @@ describe('Trailing Slash Rewrite Proxying', () => { runTests() } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + proxyPort = await findPort() + proxyServer = await initNextServerScript( + join(appDir, 'server.js'), + /ready on/i, + { + ...process.env, + PORT: proxyPort, + } + ) - describe('development mode', () => { - beforeAll(async () => { - proxyPort = await findPort() - proxyServer = await initNextServerScript( - join(appDir, 'server.js'), - /ready on/i, - { - ...process.env, - PORT: proxyPort, - } - ) - - nextConfig.replace('__EXTERNAL_PORT__', proxyPort) + nextConfig.replace('__EXTERNAL_PORT__', proxyPort) - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(async () => { - nextConfig.restore() - await killApp(app) - await killApp(proxyServer) - }) + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(async () => { + nextConfig.restore() + await killApp(app) + await killApp(proxyServer) + }) - runTests() - }) + runTests() + } + ) }) diff --git a/test/integration/typescript-only-remove-type-imports/test/index.test.js b/test/integration/typescript-only-remove-type-imports/test/index.test.js index c303607fcf47e..e2c8025145696 100644 --- a/test/integration/typescript-only-remove-type-imports/test/index.test.js +++ b/test/integration/typescript-only-remove-type-imports/test/index.test.js @@ -45,15 +45,17 @@ const runTests = () => { runTests() } ) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) - - runTests() - }) + runTests() + } + ) } ) diff --git a/test/integration/webpack-require-hook/test/index.test.js b/test/integration/webpack-require-hook/test/index.test.js index f35a3641e37f9..d695d6c00591c 100644 --- a/test/integration/webpack-require-hook/test/index.test.js +++ b/test/integration/webpack-require-hook/test/index.test.js @@ -29,22 +29,24 @@ const appDir = path.join(__dirname, '..') expect(stdout).toMatch(/Initialized config/) }) }) - - describe('development mode', () => { - it('Applies and does not error during development', async () => { - let output - const handleOutput = (msg) => { - output += msg - } - const appPort = await findPort() - const app = await launchApp(appDir, appPort, { - onStdout: handleOutput, - onStderr: handleOutput, + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + it('Applies and does not error during development', async () => { + let output + const handleOutput = (msg) => { + output += msg + } + const appPort = await findPort() + const app = await launchApp(appDir, appPort, { + onStdout: handleOutput, + onStderr: handleOutput, + }) + await renderViaHTTP(appPort, '/') + await killApp(app) + expect(output).toMatch(/Initialized config/) }) - await renderViaHTTP(appPort, '/') - await killApp(app) - expect(output).toMatch(/Initialized config/) - }) - }) + } + ) } ) diff --git a/test/integration/worker-webpack5/test/index.test.js b/test/integration/worker-webpack5/test/index.test.js index 77a1c437fc4bb..75f68e96d2546 100644 --- a/test/integration/worker-webpack5/test/index.test.js +++ b/test/integration/worker-webpack5/test/index.test.js @@ -35,15 +35,18 @@ const runTests = () => { ;(process.env.TURBOPACK ? describe.skip : describe)( 'Web Workers with webpack 5', () => { - describe('development mode', () => { - beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) - }) - afterAll(() => killApp(app)) + ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( + 'development mode', + () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(appDir, appPort) + }) + afterAll(() => killApp(app)) - runTests() - }) + runTests() + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'production mode', () => {