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