Unverified Commit 5f7faac1 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

More Turbopack test fixes (#56248)

Skips additional production tests.

Follow-up to #56089

<!-- 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 cb8b3a21
......@@ -10,7 +10,7 @@ import {
renderViaHTTP,
waitFor,
} from 'next-test-utils'
import { createNext, FileRef } from 'e2e-utils'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { outdent } from 'outdent'
......@@ -21,10 +21,7 @@ describe.each([[''], ['/docs']])(
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(join(__dirname, 'hmr/pages')),
components: new FileRef(join(__dirname, 'hmr/components')),
},
files: join(__dirname, 'hmr'),
nextConfig: {
basePath,
},
......
......@@ -57,7 +57,7 @@ const runTests = () => {
}
describe('Auto Export', () => {
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
......
......@@ -150,7 +150,7 @@ function runTests(dev) {
}
describe('CSS Module client-side navigation', () => {
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
......
......@@ -2817,57 +2817,62 @@ describe('Custom routes', () => {
})
describe('export', () => {
let exportStderr = ''
let exportVercelStderr = ''
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
let exportStderr = ''
let exportVercelStderr = ''
beforeAll(async () => {
const { stdout: buildStdout, stderr: buildStderr } = await nextBuild(
appDir,
['-d'],
{
stdout: true,
stderr: true,
}
)
const exportResult = await nextExport(
appDir,
{ outdir: join(appDir, 'out') },
{ stderr: true }
)
const exportVercelResult = await nextExport(
appDir,
{ outdir: join(appDir, 'out') },
{
stderr: true,
env: {
NOW_BUILDER: '1',
},
}
)
beforeAll(async () => {
const { stdout: buildStdout, stderr: buildStderr } = await nextBuild(
appDir,
['-d'],
{
stdout: true,
stderr: true,
}
)
const exportResult = await nextExport(
appDir,
{ outdir: join(appDir, 'out') },
{ stderr: true }
)
const exportVercelResult = await nextExport(
appDir,
{ outdir: join(appDir, 'out') },
{
stderr: true,
env: {
NOW_BUILDER: '1',
},
}
)
stdout = buildStdout
stderr = buildStderr
exportStderr = exportResult.stderr
exportVercelStderr = exportVercelResult.stderr
})
stdout = buildStdout
stderr = buildStderr
exportStderr = exportResult.stderr
exportVercelStderr = exportVercelResult.stderr
})
it('should not show warning for custom routes when not next export', async () => {
expect(stderr).not.toContain(
`rewrites, redirects, and headers are not applied when exporting your application detected`
)
})
it('should not show warning for custom routes when not next export', async () => {
expect(stderr).not.toContain(
`rewrites, redirects, and headers are not applied when exporting your application detected`
)
})
it('should not show warning for custom routes when next export on Vercel', async () => {
expect(exportVercelStderr).not.toContain(
`rewrites, redirects, and headers are not applied when exporting your application detected`
)
})
it('should not show warning for custom routes when next export on Vercel', async () => {
expect(exportVercelStderr).not.toContain(
`rewrites, redirects, and headers are not applied when exporting your application detected`
)
})
it('should show warning for custom routes with next export', async () => {
expect(exportStderr).toContain(
`rewrites, redirects, and headers are not applied when exporting your application, detected (rewrites, redirects, headers)`
)
})
it('should show warning for custom routes with next export', async () => {
expect(exportStderr).toContain(
`rewrites, redirects, and headers are not applied when exporting your application, detected (rewrites, redirects, headers)`
)
})
}
)
})
describe('should load custom routes when only one type is used', () => {
......
......@@ -13,7 +13,7 @@ import {
const appDir = path.join(__dirname, '..')
describe('Handles Duplicate Pages', () => {
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('Throws an error during build', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toContain('Duplicate page detected')
......
......@@ -97,21 +97,25 @@ describe('Edge runtime configurable guards', () => {
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
it('fails to build because of unallowed code', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).toContain(`Build failed`)
expect(output.stderr).toContain(`./pages/api/route.js`)
expect(output.stderr).toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime`
)
expect(output.stderr).toContain(`Used by default`)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('fails to build because of unallowed code', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).toContain(`Build failed`)
expect(output.stderr).toContain(`./pages/api/route.js`)
expect(output.stderr).toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime`
)
expect(output.stderr).toContain(`Used by default`)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
})
}
)
})
describe.each([
......@@ -297,23 +301,31 @@ describe('Edge runtime configurable guards', () => {
},
])('$title with allowed, unused dynamic code', ({ init, url }) => {
beforeEach(() => init())
it('build and does not warn at runtime', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).not.toContain(`Build failed`)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
context.app = await nextStart(context.appDir, context.appPort, appOption)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(context.logs.output).not.toContain(`warn`)
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('build and does not warn at runtime', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).not.toContain(`Build failed`)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(context.logs.output).not.toContain(`warn`)
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
}
)
})
describe.each([
......@@ -373,19 +385,23 @@ describe('Edge runtime configurable guards', () => {
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
it('fails to build because of dynamic code evaluation', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).toContain(`Build failed`)
expect(output.stderr).toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime`
)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
it('fails to build because of dynamic code evaluation', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.stderr).toContain(`Build failed`)
expect(output.stderr).toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime`
)
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
})
}
)
})
describe.each([
......@@ -427,21 +443,29 @@ describe('Edge runtime configurable guards', () => {
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
// eslint-disable-next-line jest/no-identical-title
it('build and does not warn at runtime', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
})
expect(output.stderr).not.toContain(`Build failed`)
context.app = await nextStart(context.appDir, context.appPort, appOption)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(context.logs.output).not.toContain(`warn`)
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
// eslint-disable-next-line jest/no-identical-title
it('build and does not warn at runtime', async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
})
expect(output.stderr).not.toContain(`Build failed`)
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(200)
expect(context.logs.output).not.toContain(`warn`)
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
})
}
)
})
})
......@@ -11,7 +11,7 @@ import { join } from 'path'
const appDir = join(__dirname, '../app')
describe('Image Generation', () => {
describe('Prod', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let app
let appPort
......
......@@ -10,53 +10,54 @@ const indexPage = join(appDir, 'pages/index.js')
const indexPageBak = `${indexPage}.bak`
describe('Mixed getStaticProps and getServerSideProps error', () => {
it('should error with getStaticProps but no default export', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should error with getStaticProps but no default export', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
export function getStaticProps() {
return {
props: {}
}
}
`
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(stderr).toContain(
'found page without a React Component as default export in'
)
})
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(stderr).toContain(
'found page without a React Component as default export in'
)
})
it('should error when exporting both getStaticProps and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
it('should error when exporting both getStaticProps and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
it('should error when exporting both getStaticPaths and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
it('should error when exporting both getStaticPaths and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
export const getStaticPaths = async () => {
return {
props: { world: 'world' }, fallback: true
......@@ -71,20 +72,20 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
export default ({ world }) => <p>Hello {world}</p>
`
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(code).toBe(1)
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(code).toBe(1)
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
it('should error when exporting getStaticPaths on a non-dynamic page', async () => {
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
it('should error when exporting getStaticPaths on a non-dynamic page', async () => {
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
export const getStaticPaths = async () => {
return {
props: { world: 'world' }, fallback: true
......@@ -93,14 +94,15 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
export default ({ world }) => <p>Hello {world}</p>
`
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(code).toBe(1)
expect(stderr).toContain(
"getStaticPaths is only allowed for dynamic SSG pages and was found on '/'."
)
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(code).toBe(1)
expect(stderr).toContain(
"getStaticPaths is only allowed for dynamic SSG pages and was found on '/'."
)
})
})
})
......@@ -19,7 +19,7 @@ let app
let proxyServer: http.Server
let cancelCount = 0
describe('react-virtualized wrapping next/legacy/image', () => {
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
......
......@@ -19,7 +19,7 @@ let app
let proxyServer: http.Server
let cancelCount = 0
describe('react-virtualized wrapping next/image', () => {
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
......
......@@ -38,8 +38,7 @@ describe('node-fetch-keep-alive', () => {
runTests()
})
describe('production', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
mockServer = createServer((req, res) => {
// we can test request headers by sending them
......
......@@ -38,11 +38,13 @@ function runTests() {
}
describe('Production browser sourcemaps', () => {
describe('Server support', () => {
beforeAll(async () => {
await nextBuild(appDir, [], {})
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Server support', () => {
beforeAll(async () => {
await nextBuild(appDir, [], {})
})
runTests()
runTests()
})
})
})
......@@ -10,22 +10,24 @@ import {
} from 'next-test-utils'
describe('Production Custom Build Directory', () => {
describe('With basic usage', () => {
it('should render the page', async () => {
const result = await runNextCommand(['build', 'build'], {
cwd: join(__dirname, '..'),
stdout: true,
stderr: true,
})
expect(result.stderr).toBe('')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('With basic usage', () => {
it('should render the page', async () => {
const result = await runNextCommand(['build', 'build'], {
cwd: join(__dirname, '..'),
stdout: true,
stderr: true,
})
expect(result.stderr).toBe('')
const appPort = await findPort()
const app = await nextStart(join(__dirname, '../build'), appPort)
const appPort = await findPort()
const app = await nextStart(join(__dirname, '../build'), appPort)
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/Hello World/)
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/Hello World/)
await killApp(app)
await killApp(app)
})
})
})
})
......@@ -16,64 +16,66 @@ let app
let appPort
describe('Production Config Usage', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
describe('with generateBuildId', () => {
it('should add the custom buildid', async () => {
const browser = await webdriver(appPort, '/')
const text = await browser.elementByCss('#mounted').text()
expect(text).toMatch(/ComponentDidMount executed on client\./)
describe('with generateBuildId', () => {
it('should add the custom buildid', async () => {
const browser = await webdriver(appPort, '/')
const text = await browser.elementByCss('#mounted').text()
expect(text).toMatch(/ComponentDidMount executed on client\./)
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch('custom-buildid')
await browser.close()
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch('custom-buildid')
await browser.close()
})
})
})
describe('env', () => {
it('should fail with leading __ in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_FAIL_UNDERSCORE: true },
stdout: true,
stderr: true,
describe('env', () => {
it('should fail with leading __ in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_FAIL_UNDERSCORE: true },
stdout: true,
stderr: true,
})
expect(result.stderr).toMatch(/The key "__NEXT_MY_VAR" under/)
})
expect(result.stderr).toMatch(/The key "__NEXT_MY_VAR" under/)
})
it('should fail with NODE_ in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_FAIL_NODE: true },
stdout: true,
stderr: true,
})
it('should fail with NODE_ in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_FAIL_NODE: true },
stdout: true,
stderr: true,
expect(result.stderr).toMatch(/The key "NODE_ENV" under/)
})
expect(result.stderr).toMatch(/The key "NODE_ENV" under/)
})
it('should fail with NEXT_RUNTIME in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_NEXT_PRESERVED: true },
stdout: true,
stderr: true,
})
it('should fail with NEXT_RUNTIME in env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_NEXT_PRESERVED: true },
stdout: true,
stderr: true,
expect(result.stderr).toMatch(/The key "NEXT_RUNTIME" under/)
})
expect(result.stderr).toMatch(/The key "NEXT_RUNTIME" under/)
})
it('should allow __ within env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_WITH_UNDERSCORES: true },
stdout: true,
stderr: true,
})
it('should allow __ within env key', async () => {
const result = await runNextCommand(['build', appDir], {
env: { ENABLE_ENV_WITH_UNDERSCORES: true },
stdout: true,
stderr: true,
expect(result.stderr).not.toMatch(/The key "SOME__ENV__VAR" under/)
})
expect(result.stderr).not.toMatch(/The key "SOME__ENV__VAR" under/)
})
})
})
......@@ -10,25 +10,27 @@ let appPort
let app
describe('Production Usage', () => {
beforeAll(async () => {
await nextBuild(appDir)
// use compatible port: https://www.browserstack.com/question/664
appPort = await getPort({
port: [8080, 8081, 8888, 8899],
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
// use compatible port: https://www.browserstack.com/question/664
appPort = await getPort({
port: [8080, 8081, 8888, 8899],
})
app = await nextStart(appDir, appPort)
})
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
afterAll(() => killApp(app))
it('should navigate forward and back correctly', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = true')
await browser.elementByCss('#to-another').click()
// waitForElement doesn't seem to work properly in safari 10
await waitFor(2000)
expect(await browser.eval('window.beforeNav')).toBe(true)
await browser.elementByCss('#to-index').click()
await waitFor(2000)
expect(await browser.eval('window.beforeNav')).toBe(true)
it('should navigate forward and back correctly', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = true')
await browser.elementByCss('#to-another').click()
// waitForElement doesn't seem to work properly in safari 10
await waitFor(2000)
expect(await browser.eval('window.beforeNav')).toBe(true)
await browser.elementByCss('#to-index').click()
await waitFor(2000)
expect(await browser.eval('window.beforeNav')).toBe(true)
})
})
})
......@@ -439,39 +439,41 @@ describe('404 handling', () => {
isDev: true,
})
})
describe('production', () => {
beforeAll(async () => {
await nextBuild(appDir, [], nextOpts)
})
describe('next start', () => {
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await nextStart(appDir, appPort, nextOpts)
await nextBuild(appDir, [], nextOpts)
})
afterAll(() => killApp(app))
runTests({
isPages404,
describe('next start', () => {
beforeAll(async () => {
appPort = await findPort()
app = await nextStart(appDir, appPort, nextOpts)
})
afterAll(() => killApp(app))
runTests({
isPages404,
})
})
})
describe('next export', () => {
beforeAll(async () => {
await nextExport(appDir, { outdir }, nextOpts)
app = await startStaticServer(outdir, join(outdir, '404.html'))
appPort = app.address().port
describe('next export', () => {
beforeAll(async () => {
await nextExport(appDir, { outdir }, nextOpts)
app = await startStaticServer(outdir, join(outdir, '404.html'))
appPort = app.address().port
})
afterAll(() => {
stopApp(app)
})
runTests({
isPages404,
isExport: true,
})
})
afterAll(() => {
stopApp(app)
})
runTests({
isPages404,
isExport: true,
})
})
})
}
)
}
describe('custom _error', () => {
......@@ -479,14 +481,17 @@ describe('404 handling', () => {
})
describe('pages/404', () => {
const pagesErr = join(appDir, 'pages/_error.js')
const pages404 = join(appDir, 'pages/404.js')
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const pagesErr = join(appDir, 'pages/_error.js')
const pages404 = join(appDir, 'pages/404.js')
beforeAll(async () => {
await fs.move(pagesErr, pagesErr + '.bak')
await fs.writeFile(
pages404,
`
beforeAll(async () => {
await fs.move(pagesErr, pagesErr + '.bak')
await fs.writeFile(
pages404,
`
if (typeof window !== 'undefined') {
window.errorLoad = true
}
......@@ -494,14 +499,16 @@ describe('404 handling', () => {
return <p id='error'>custom 404</p>
}
`
)
await nextBuild(appDir, [], nextOpts)
})
afterAll(async () => {
await fs.move(pagesErr + '.bak', pagesErr)
await fs.remove(pages404)
})
)
await nextBuild(appDir, [], nextOpts)
})
afterAll(async () => {
await fs.move(pagesErr + '.bak', pagesErr)
await fs.remove(pages404)
})
devStartAndExport(true)
devStartAndExport(true)
}
)
})
})
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