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

Skip production tests for Turbopack (#56089)

Follow-up to #56045. Found there was a group of tests for production
called `server mode` instead of `production mode`, those are skipped too
now.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
parent 3eadfe92
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
createNextDescribe(
'instrumentation-hook-src',
{
files: __dirname,
nextConfig: {
experimental: {
instrumentationHook: true,
;(process.env.TURBOPACK ? describe.skip : describe)(
'instrumentation-hook-rsc',
() => {
createNextDescribe(
'instrumentation',
{
files: __dirname,
nextConfig: {
experimental: {
instrumentationHook: true,
},
},
skipDeployment: true,
},
},
skipDeployment: true,
},
({ next, isNextDev }) => {
it('should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook/)
})
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
it('should run the edge instrumentation compiled version with the edge runtime', async () => {
await next.render('/edge')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./src/instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./src/instrumentation.js',
'./src/instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./src/instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./src/instrumentation.js.bak',
'./src/instrumentation.js'
)
await check(() => next.cliOutput, /The instrumentation file was added/)
await check(() => next.cliOutput, /bread/)
})
}
({ next, isNextDev }) => {
it('should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook/)
})
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
it('should run the edge instrumentation compiled version with the edge runtime', async () => {
await next.render('/edge')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./src/instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./src/instrumentation.js',
'./src/instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./src/instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./src/instrumentation.js.bak',
'./src/instrumentation.js'
)
await check(
() => next.cliOutput,
/The instrumentation file was added/
)
await check(() => next.cliOutput, /bread/)
})
}
}
)
}
)
......@@ -20,117 +20,123 @@ const describeCase = (
callback
)
}
describe('Instrumentation Hook', () => {
// TODO: investigate the failure with esm import
// createNextDescribe(
// 'with-esm-import',
// {
// files: path.join(__dirname, 'with-esm-import'),
// nextConfig: {
// experimental: {
// instrumentationHook: true,
// },
// },
// dependencies: {
// // This test is mostly for compatibility with this package
// '@vercel/otel': 'latest',
// },
// skipDeployment: true,
// },
// ({ next }) => {
// eslint-disable-next-line jest/no-commented-out-tests
// it('with-esm-import should run the instrumentation hook', async () => {
// await next.render('/')
// await check(
// () => next.cliOutput,
// /register in instrumentation\.js is running/
// )
// })
// }
// )
;(process.env.TURBOPACK ? describe.skip : describe)(
'Instrumentation Hook',
() => {
// TODO: investigate the failure with esm import
// createNextDescribe(
// 'with-esm-import',
// {
// files: path.join(__dirname, 'with-esm-import'),
// nextConfig: {
// experimental: {
// instrumentationHook: true,
// },
// },
// dependencies: {
// // This test is mostly for compatibility with this package
// '@vercel/otel': 'latest',
// },
// skipDeployment: true,
// },
// ({ next }) => {
// eslint-disable-next-line jest/no-commented-out-tests
// it('with-esm-import should run the instrumentation hook', async () => {
// await next.render('/')
// await check(
// () => next.cliOutput,
// /register in instrumentation\.js is running/
// )
// })
// }
// )
describeCase('with-middleware', ({ next }) => {
it('with-middleware should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-middleware', ({ next }) => {
it('with-middleware should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})
describeCase('with-edge-api', ({ next }) => {
it('with-edge-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-edge-api', ({ next }) => {
it('with-edge-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})
describeCase('with-edge-page', ({ next }) => {
it('with-edge-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-edge-page', ({ next }) => {
it('with-edge-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})
describeCase('with-node-api', ({ next }) => {
it('with-node-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
describeCase('with-node-api', ({ next }) => {
it('with-node-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
})
})
})
describeCase('with-node-page', ({ next }) => {
it('with-node-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
describeCase('with-node-page', ({ next }) => {
it('with-node-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
})
})
})
describeCase('with-async-node-page', ({ next }) => {
it('with-async-node-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Node - finished: true')
describeCase('with-async-node-page', ({ next }) => {
it('with-async-node-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Node - finished: true')
})
})
})
describeCase('with-async-edge-page', ({ next }) => {
it('with-async-edge-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Edge - finished: true')
describeCase('with-async-edge-page', ({ next }) => {
it('with-async-edge-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Edge - finished: true')
})
})
})
describeCase('general', ({ next, isNextDev }) => {
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./instrumentation.js',
'./instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./instrumentation.js.bak',
'./instrumentation.js'
)
await check(() => next.cliOutput, /The instrumentation file was added/)
await check(() => next.cliOutput, /bread/)
describeCase('general', ({ next, isNextDev }) => {
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
}
})
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./instrumentation.js',
'./instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./instrumentation.js.bak',
'./instrumentation.js'
)
await check(
() => next.cliOutput,
/The instrumentation file was added/
)
await check(() => next.cliOutput, /bread/)
})
}
})
}
)
......@@ -51,7 +51,7 @@ const runTests = (mode) => {
}
describe('Default 404 Page with custom _error', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
it('should build successfully', async () => {
......
......@@ -76,7 +76,7 @@ const runTests = (isDev) => {
}
describe('404 Page Support SSG', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
it('should build successfully', async () => {
......
......@@ -79,8 +79,7 @@ describe('404 Page Support', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -70,8 +70,7 @@ describe('500 Page Support', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
......
......@@ -98,7 +98,7 @@ const runTests = (isDev = false) => {
}
describe('AMP SSG Support', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -30,7 +30,7 @@ const runTests = () => {
}
describe('Auto Export _error bail', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
})
......@@ -22,7 +22,7 @@ const runTests = () => {
}
describe('Auto Export', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
const { stderr: curStderr, code: curCode } = await nextExport(
......
......@@ -42,8 +42,7 @@ describe('bigint API route support', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(nextConfig)
await nextBuild(appDir)
......
......@@ -23,108 +23,112 @@ const existsChunkNamed = (name) => {
}
describe('Chunking', () => {
beforeAll(async () => {
try {
// If a previous build has left chunks behind, delete them
const oldChunks = await readdir(join(appDir, '.next', 'static', 'chunks'))
await Promise.all(
oldChunks.map((chunk) => {
return unlink(join(appDir, '.next', 'static', 'chunks', chunk))
})
)
} catch (e) {
// Error here means old chunks don't exist, so we don't need to do anything
}
await nextBuild(appDir, [])
stats = (await readFile(join(appDir, '.next', 'stats.json'), 'utf8'))
// fixes backslashes in keyNames not being escaped on windows
.replace(/"static\\(.*?":?)/g, (match) => match.replace(/\\/g, '\\\\'))
stats = JSON.parse(stats)
appPort = await findPort()
app = await nextStart(appDir, appPort)
chunks = await readdir(join(appDir, '.next', 'static', 'chunks'))
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
try {
// If a previous build has left chunks behind, delete them
const oldChunks = await readdir(
join(appDir, '.next', 'static', 'chunks')
)
await Promise.all(
oldChunks.map((chunk) => {
return unlink(join(appDir, '.next', 'static', 'chunks', chunk))
})
)
} catch (e) {
// Error here means old chunks don't exist, so we don't need to do anything
}
await nextBuild(appDir, [])
afterAll(() => killApp(app))
stats = (await readFile(join(appDir, '.next', 'stats.json'), 'utf8'))
// fixes backslashes in keyNames not being escaped on windows
.replace(/"static\\(.*?":?)/g, (match) => match.replace(/\\/g, '\\\\'))
it('should use all url friendly names', () => {
expect(chunks).toEqual(chunks.map((name) => encodeURIComponent(name)))
})
stats = JSON.parse(stats)
appPort = await findPort()
app = await nextStart(appDir, appPort)
chunks = await readdir(join(appDir, '.next', 'static', 'chunks'))
})
it('should create a framework chunk', () => {
expect(existsChunkNamed('framework')).toBe(true)
})
afterAll(() => killApp(app))
it('should not create a commons chunk', () => {
// This app has no dependency that is required by ALL pages, and should
// therefore not have a commons chunk
expect(existsChunkNamed('commons')).toBe(false)
})
it('should use all url friendly names', () => {
expect(chunks).toEqual(chunks.map((name) => encodeURIComponent(name)))
})
it('should not create a lib chunk for react or react-dom', () => {
// These large dependencies would become lib chunks, except that they
// are preemptively moved into the framework chunk.
expect(existsChunkNamed('react|react-dom')).toBe(false)
})
it('should create a framework chunk', () => {
expect(existsChunkNamed('framework')).toBe(true)
})
it('should not preload the build manifest', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect(
[].slice
.call($('link[rel="preload"][as="script"]'))
.map((e) => e.attribs.href)
.some((entry) => entry.includes('_buildManifest'))
).toBe(false)
})
it('should not create a commons chunk', () => {
// This app has no dependency that is required by ALL pages, and should
// therefore not have a commons chunk
expect(existsChunkNamed('commons')).toBe(false)
})
it('should execute the build manifest', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect(
Array.from($('script'))
.map((e) => e.attribs.src)
.some((entry) => entry && entry.includes('_buildManifest'))
).toBe(true)
})
it('should not create a lib chunk for react or react-dom', () => {
// These large dependencies would become lib chunks, except that they
// are preemptively moved into the framework chunk.
expect(existsChunkNamed('react|react-dom')).toBe(false)
})
it('should not include more than one instance of react-dom', async () => {
const misplacedReactDom = stats.chunks.some((chunk) => {
if (chunk.names.includes('framework')) {
// disregard react-dom in framework--it's supposed to be there
return false
}
return chunk.modules.some((module) => {
return /react-dom/.test(module.name)
it('should not preload the build manifest', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect(
[].slice
.call($('link[rel="preload"][as="script"]'))
.map((e) => e.attribs.href)
.some((entry) => entry.includes('_buildManifest'))
).toBe(false)
})
it('should execute the build manifest', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect(
Array.from($('script'))
.map((e) => e.attribs.src)
.some((entry) => entry && entry.includes('_buildManifest'))
).toBe(true)
})
it('should not include more than one instance of react-dom', async () => {
const misplacedReactDom = stats.chunks.some((chunk) => {
if (chunk.names.includes('framework')) {
// disregard react-dom in framework--it's supposed to be there
return false
}
return chunk.modules.some((module) => {
return /react-dom/.test(module.name)
})
})
expect(misplacedReactDom).toBe(false)
})
expect(misplacedReactDom).toBe(false)
})
describe('Serving', () => {
it('should hydrate with aggressive chunking', async () => {
const browser = await webdriver(appPort, '/page2')
const text = await browser.elementByCss('#padded-str').text()
describe('Serving', () => {
it('should hydrate with aggressive chunking', async () => {
const browser = await webdriver(appPort, '/page2')
const text = await browser.elementByCss('#padded-str').text()
expect(text).toBe('__rad__')
expect(text).toBe('__rad__')
await browser.close()
})
await browser.close()
})
it('should load chunks when navigating', async () => {
const browser = await webdriver(appPort, '/page3')
const text = await browser
.elementByCss('#page2-link')
.click()
.waitForElementByCss('#padded-str')
.elementByCss('#padded-str')
.text()
it('should load chunks when navigating', async () => {
const browser = await webdriver(appPort, '/page3')
const text = await browser
.elementByCss('#page2-link')
.click()
.waitForElementByCss('#padded-str')
.elementByCss('#padded-str')
.text()
expect(text).toBe('__rad__')
expect(text).toBe('__rad__')
await browser.close()
await browser.close()
})
})
})
})
......@@ -29,7 +29,7 @@ const runTests = () => {
}
describe('Cleaning distDir', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
......
......@@ -2785,8 +2785,7 @@ describe('Custom routes', () => {
)
})
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
const { stdout: buildStdout, stderr: buildStderr } = await nextBuild(
appDir,
......
......@@ -117,8 +117,7 @@ describe('Test Draft Mode', () => {
await killApp(app)
})
})
describe('Server Mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let appPort, app, cookieString, initialRand
const getOpts = () => ({ headers: { Cookie: cookieString } })
......
......@@ -364,8 +364,7 @@ describe('Env Config', () => {
runTests('test')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
const { code } = await nextBuild(appDir, [], {
env: {
......
......@@ -14,36 +14,39 @@ import {
const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export Dyanmic Pages', () => {
let server
let port
beforeAll(async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
;(process.env.TURBOPACK ? describe.skip : describe)(
'Export Dynamic Pages',
() => {
let server
let port
beforeAll(async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
server = await startCleanStaticServer(outdir)
port = server.address().port
})
server = await startCleanStaticServer(outdir)
port = server.address().port
})
afterAll(async () => {
await stopApp(server)
})
afterAll(async () => {
await stopApp(server)
})
it('should of exported with correct asPath', async () => {
const html = await renderViaHTTP(port, '/regression/jeff-is-cool')
const $ = cheerio.load(html)
expect($('#asPath').text()).toBe('/regression/jeff-is-cool')
})
it('should of exported with correct asPath', async () => {
const html = await renderViaHTTP(port, '/regression/jeff-is-cool')
const $ = cheerio.load(html)
expect($('#asPath').text()).toBe('/regression/jeff-is-cool')
})
it('should hydrate with correct asPath', async () => {
expect.assertions(1)
const browser = await webdriver(port, '/regression/jeff-is-cool')
try {
expect(await browser.eval(`window.__AS_PATHS`)).toEqual([
'/regression/jeff-is-cool',
])
} finally {
await browser.close()
}
})
})
it('should hydrate with correct asPath', async () => {
expect.assertions(1)
const browser = await webdriver(port, '/regression/jeff-is-cool')
try {
expect(await browser.eval(`window.__AS_PATHS`)).toEqual([
'/regression/jeff-is-cool',
])
} finally {
await browser.close()
}
})
}
)
......@@ -269,8 +269,7 @@ describe('ServerSide Props Preview Mode', () => {
await killApp(app)
})
})
describe('Server Mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
})
......@@ -41,8 +41,7 @@ describe('Image Component assetPrefix Tests', () => {
}
})
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -511,8 +511,7 @@ describe('Image Component basePath Tests', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -1483,8 +1483,7 @@ describe('Image Component Tests', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -44,8 +44,7 @@ describe('Image Component Trailing Slash Tests', () => {
}
})
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -82,8 +82,7 @@ describe('Image Component Unicode Image URL', () => {
})
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -109,8 +109,7 @@ describe('Unoptimized Image Tests', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -1517,8 +1517,7 @@ describe('Image Component Default Tests', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -34,8 +34,7 @@ describe('Image Component assetPrefix Tests', () => {
)
})
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -206,8 +206,7 @@ describe('Image Component basePath Tests', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -51,8 +51,7 @@ describe('Image Component basePath + trailingSlash Tests', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -1525,8 +1525,7 @@ describe('Image Component Default Tests', () => {
runTests('dev')
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -53,8 +53,7 @@ describe('Missing Import Image Tests', () => {
runTests({ isDev: true })
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
stderr = ''
const result = await nextBuild(appDir, [], { stderr: true })
......
......@@ -55,18 +55,20 @@ describe('Image Loader Config', () => {
})
runTests('/')
})
describe('server mode - component', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - component',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/')
}
)
describe('dev mode - getImgProps', () => {
beforeAll(async () => {
appPort = await findPort()
......@@ -77,16 +79,18 @@ describe('Image Loader Config', () => {
})
runTests('/get-img-props')
})
describe('server mode - getImgProps', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/get-img-props')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - getImgProps',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/get-img-props')
}
)
})
......@@ -57,8 +57,7 @@ describe('Image Loader Config with Edge Runtime', () => {
})
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -48,18 +48,20 @@ describe('Image Loader Config', () => {
})
runTests('/')
})
describe('server mode - component', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - component',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/')
}
)
describe('dev mode - getImgProps', () => {
beforeAll(async () => {
appPort = await findPort()
......@@ -70,16 +72,18 @@ describe('Image Loader Config', () => {
})
runTests('/get-img-props')
})
describe('server mode - getImgProps', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/get-img-props')
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - getImgProps',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
})
runTests('/get-img-props')
}
)
})
......@@ -44,8 +44,7 @@ describe('Image Component Trailing Slash Tests', () => {
}
})
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -82,8 +82,7 @@ describe('Image Component Unicode Image URL', () => {
})
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -103,18 +103,21 @@ describe('Unoptimized Image Tests', () => {
runTests('/')
})
describe('server mode - component', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - component',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
runTests('/')
})
runTests('/')
}
)
describe('dev mode - getImgProps', () => {
beforeAll(async () => {
appPort = await findPort()
......@@ -126,16 +129,19 @@ describe('Unoptimized Image Tests', () => {
runTests('/get-img-props')
})
describe('server mode - getImgProps', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode - getImgProps',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
runTests('/get-img-props')
})
runTests('/get-img-props')
}
)
})
......@@ -38,8 +38,7 @@ describe('Optional chaining and nullish coalescing support', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -35,8 +35,7 @@ describe('PORT environment variable', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -380,8 +380,7 @@ describe('Prerender Preview Mode', () => {
await killApp(app)
})
})
describe('Server Mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
})
......@@ -276,8 +276,7 @@ describe('Preview mode with fallback pages', () => {
runTests(true)
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
......
......@@ -70,7 +70,7 @@ const runTests = () => {
}
describe('Revalidate asPath Normalizing', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
appPort = await findPort()
......
......@@ -73,8 +73,7 @@ describe('Scroll Restoration Support', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -81,8 +81,7 @@ describe('Scroll Restoration Support', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -24,7 +24,7 @@ const runTests = () => {
}
describe('Custom 404 Page for static site generation with dynamic routes', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
it('should build successfully', async () => {
......
......@@ -21,101 +21,104 @@ import webdriver from 'next-webdriver'
jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, '../')
describe(`Handle url imports`, () => {
let staticServer
let staticServerPort
beforeAll(async () => {
await fs.remove(join(appDir, 'next.lock'))
staticServerPort = 12345
staticServer = await startStaticServer(
join(appDir, 'source'),
undefined,
staticServerPort
)
})
afterAll(async () => {
await stopApp(staticServer)
})
for (const dev of [true, false]) {
describe(dev ? 'with next dev' : 'with next build', () => {
let appPort
let app
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
if (dev) {
appPort = await findPort()
app = await launchApp(appDir, appPort)
} else {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
}
})
afterAll(async () => {
await killApp(app)
})
const expectedServer =
/Hello <!-- -->42<!-- -->\+<!-- -->42<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png/
const expectedClient = new RegExp(
expectedServer.source.replace(/<!-- -->/g, '')
;(process.env.TURBOPACK ? describe.skip : describe)(
`Handle url imports`,
() => {
let staticServer
let staticServerPort
beforeAll(async () => {
await fs.remove(join(appDir, 'next.lock'))
staticServerPort = 12345
staticServer = await startStaticServer(
join(appDir, 'source'),
undefined,
staticServerPort
)
})
afterAll(async () => {
await stopApp(staticServer)
})
for (const page of ['/static', '/ssr', '/ssg']) {
it(`should render the ${page} page`, async () => {
const html = await renderViaHTTP(appPort, page)
expect(html).toMatch(expectedServer)
for (const dev of [true, false]) {
describe(dev ? 'with next dev' : 'with next build', () => {
let appPort
let app
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
if (dev) {
appPort = await findPort()
app = await launchApp(appDir, appPort)
} else {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
}
})
afterAll(async () => {
await killApp(app)
})
const expectedServer =
/Hello <!-- -->42<!-- -->\+<!-- -->42<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png/
const expectedClient = new RegExp(
expectedServer.source.replace(/<!-- -->/g, '')
)
it(`should client-render the ${page} page`, async () => {
for (const page of ['/static', '/ssr', '/ssg']) {
it(`should render the ${page} page`, async () => {
const html = await renderViaHTTP(appPort, page)
expect(html).toMatch(expectedServer)
})
it(`should client-render the ${page} page`, async () => {
let browser
try {
browser = await webdriver(appPort, page)
await check(() => getBrowserBodyText(browser), expectedClient)
} finally {
await browser.close()
}
})
}
it(`should render a static url image import`, async () => {
let browser
try {
browser = await webdriver(appPort, page)
await check(() => getBrowserBodyText(browser), expectedClient)
browser = await webdriver(appPort, '/image')
await browser.waitForElementByCss('#static-image')
await check(
() => browser.elementByCss('#static-image').getAttribute('src'),
/^\/_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fvercel\.[0-9a-f]{8}\.png&/
)
} finally {
await browser.close()
}
})
}
it(`should render a static url image import`, async () => {
let browser
try {
browser = await webdriver(appPort, '/image')
await browser.waitForElementByCss('#static-image')
await check(
() => browser.elementByCss('#static-image').getAttribute('src'),
/^\/_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fvercel\.[0-9a-f]{8}\.png&/
)
} finally {
await browser.close()
}
})
it(`should allow url import in css`, async () => {
let browser
try {
browser = await webdriver(appPort, '/css')
await browser.waitForElementByCss('#static-css')
await check(
() =>
browser
.elementByCss('#static-css')
.getComputedCss('background-image'),
/^url\("http:\/\/localhost:\d+\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png"\)$/
)
} finally {
await browser.close()
}
})
it(`should allow url import in css`, async () => {
let browser
try {
browser = await webdriver(appPort, '/css')
await browser.waitForElementByCss('#static-css')
await check(
() =>
browser
.elementByCss('#static-css')
.getComputedCss('background-image'),
/^url\("http:\/\/localhost:\d+\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png"\)$/
it('should respond on value api', async () => {
const data = await fetchViaHTTP(appPort, '/api/value').then(
(res) => res.ok && res.json()
)
} finally {
await browser.close()
}
})
it('should respond on value api', async () => {
const data = await fetchViaHTTP(appPort, '/api/value').then(
(res) => res.ok && res.json()
)
expect(data).toEqual({ value: 42 })
expect(data).toEqual({ value: 42 })
})
})
})
}
}
})
)
......@@ -42,8 +42,7 @@ describe('Web Workers with webpack 5', () => {
runTests()
})
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment