Skip to content

Commit

Permalink
Rename process.env.TURBOPACK -> process.env.TURBOPACK_DEV in test ski…
Browse files Browse the repository at this point in the history
…ps (#63665)

## What?

Follow-up to #63653.

<!-- 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 #

-->


Closes NEXT-2911
  • Loading branch information
timneutkens authored Mar 25, 2024
1 parent f9d73cc commit 1e710ab
Show file tree
Hide file tree
Showing 305 changed files with 13,791 additions and 12,661 deletions.
2 changes: 1 addition & 1 deletion test/e2e/app-dir/actions/app-action-export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ createNextDescribe(
},
({ next, isNextStart }) => {
if (!isNextStart) {
it('skip test for dev mode', () => {})
it('skip test for development mode', () => {})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ createNextDescribe(
},
({ next, isNextStart, isNextDeploy }) => {
if (!isNextStart) {
it('skip test for dev mode', () => {})
it('skip test for development mode', () => {})
return
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app-client-cache/client-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ createNextDescribe(
},
({ next, isNextDev }) => {
if (isNextDev) {
// since the router behavior is different in dev mode (no viewport prefetching + liberal revalidation)
// since the router behavior is different in development mode (no viewport prefetching + liberal revalidation)
// we only check the production behavior
it('should skip dev', () => {})
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ createNextDescribe(
},
({ next, isNextDev }) => {
if (isNextDev) {
it.skip('should skip test in dev mode', () => {})
it.skip('should skip test in development mode', () => {})
} else {
it('should avoid double-fetching when optimistic navigation fails', async () => {
const browser = await next.browser('/foo')
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3056,7 +3056,7 @@ createNextDescribe(
})
}
})
// Don't run these tests in dev mode since they won't be statically generated
// Don't run these tests in development mode since they won't be statically generated
if (!isDev) {
describe('server response', () => {
it('should bailout to client rendering - with suspense boundary', async () => {
Expand Down Expand Up @@ -3215,7 +3215,7 @@ createNextDescribe(
})
}
if (!process.env.CUSTOM_CACHE_HANDLER && isDev) {
it('should not cache request if response data size is greater than 2MB and FetchCache is possible in Dev mode', async () => {
it('should not cache request if response data size is greater than 2MB and FetchCache is possible in development mode', async () => {
const cliOutputStart = next.cliOutput.length
const resp1 = await next.fetch('/force-cache/large-data')
const resp1Text = await resp1.text()
Expand Down Expand Up @@ -3243,7 +3243,7 @@ createNextDescribe(
})
}
if (process.env.CUSTOM_CACHE_HANDLER && isDev) {
it('should cache request if response data size is greater than 2MB in Dev mode', async () => {
it('should cache request if response data size is greater than 2MB in development mode', async () => {
const cliOutputStart = next.cliOutput.length
const resp1 = await next.fetch('/force-cache/large-data')
const resp1Text = await resp1.text()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/logging/fetch-logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ createNextDescribe(
withFullUrlFetches?: boolean
}) {
if (withFetchesLogging) {
it('should only log requests in dev mode', async () => {
it('should only log requests in development mode', async () => {
const outputIndex = next.cliOutput.length
await next.fetch('/default-cache')

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/metadata-warnings/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ createNextDescribe(
},
({ next, isNextDev }) => {
// If it's start mode, we get the whole logs since they're from build process.
// If it's dev mode, we get the logs after request
// If it's development mode, we get the logs after request
function getCliOutput(logStartPosition: number) {
return isNextDev ? next.cliOutput.slice(logStartPosition) : next.cliOutput
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ createNextDescribe(
},
({ next, isNextDev }) => {
if (isNextDev) {
it.skip('skip test for dev mode', () => {})
it.skip('skip test for development mode', () => {})
return
}

Expand Down
73 changes: 38 additions & 35 deletions test/e2e/app-dir/ppr-errors/ppr-errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
import { nextBuild } from 'next-test-utils'

describe('ppr build errors', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let stderr: string
let stdout: string
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
let stderr: string
let stdout: string

beforeAll(async () => {
const output = await nextBuild(__dirname, [], {
stderr: true,
stdout: true,
beforeAll(async () => {
const output = await nextBuild(__dirname, [], {
stderr: true,
stdout: true,
})
stderr = output.stderr
stdout = output.stdout
})
stderr = output.stderr
stdout = output.stdout
})

describe('within a suspense boundary', () => {
it('should fail the build for uncaught prerender errors', async () => {
expect(stderr).toContain(
'Error occurred prerendering page "/regular-error-suspense-boundary".'
)
expect(stderr).toContain(
'Error occurred prerendering page "/re-throwing-error".'
)
describe('within a suspense boundary', () => {
it('should fail the build for uncaught prerender errors', async () => {
expect(stderr).toContain(
'Error occurred prerendering page "/regular-error-suspense-boundary".'
)
expect(stderr).toContain(
'Error occurred prerendering page "/re-throwing-error".'
)
})
})
})

describe('outside of a suspense boundary', () => {
it('should fail the build for uncaught errors', async () => {
expect(stderr).toContain(
'Error occurred prerendering page "/regular-error".'
)
expect(stderr).toContain(
'Error occurred prerendering page "/no-suspense-boundary-re-throwing-error".'
)
describe('outside of a suspense boundary', () => {
it('should fail the build for uncaught errors', async () => {
expect(stderr).toContain(
'Error occurred prerendering page "/regular-error".'
)
expect(stderr).toContain(
'Error occurred prerendering page "/no-suspense-boundary-re-throwing-error".'
)
})
})
})

describe('when a postpone call is caught and logged it should', () => {
it('should include a message telling why', async () => {
expect(stdout).toContain(
'User land logged error: Route /logging-error needs to bail out of prerendering at this point because it used cookies.'
)
describe('when a postpone call is caught and logged it should', () => {
it('should include a message telling why', async () => {
expect(stdout).toContain(
'User land logged error: Route /logging-error needs to bail out of prerendering at this point because it used cookies.'
)
})
})
})
})
}
)
})
2 changes: 1 addition & 1 deletion test/e2e/edge-configurable-runtime/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const apiPath = 'pages/api/edge.js'
const api = new File(join(appDir, apiPath))

if ((global as any).isNextDev) {
describe('In dev mode', () => {
describe('In development mode', () => {
beforeAll(async () => {
next = await createNext({
files: new FileRef(appDir),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/prerender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ describe('Prerender', () => {
expect(JSON.parse($2('#__NEXT_DATA__').text()).isFallback).toBe(false)
})

it('should log error in console and browser in dev mode', async () => {
it('should log error in console and browser in development mode', async () => {
const indexPage = 'pages/index.js'
const origContent = await next.readFile(indexPage)

Expand Down
67 changes: 35 additions & 32 deletions test/integration/404-page-app/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,48 @@ let appPort
let app

describe('404 Page Support with _app', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
const { code, stderr, stdout } = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})
it('should build successfully', async () => {
const { code, stderr, stdout } = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})

expect(code).toBe(0)
expect(stderr).not.toMatch(gip404Err)
expect(stdout).not.toMatch(gip404Err)
expect(code).toBe(0)
expect(stderr).not.toMatch(gip404Err)
expect(stdout).not.toMatch(gip404Err)

appPort = await findPort()
app = await nextStart(appDir, appPort)
})
appPort = await findPort()
app = await nextStart(appDir, appPort)
})

it('should not output static 404 if _app has getInitialProps', async () => {
const browser = await webdriver(appPort, '/404')
const isAutoExported = await browser.eval('__NEXT_DATA__.autoExport')
expect(isAutoExported).toBeFalsy()
})
it('should not output static 404 if _app has getInitialProps', async () => {
const browser = await webdriver(appPort, '/404')
const isAutoExported = await browser.eval('__NEXT_DATA__.autoExport')
expect(isAutoExported).toBeFalsy()
})

it('specify to use the 404 page still in the routes-manifest', async () => {
const manifest = await fs.readJSON(
join(appDir, '.next/routes-manifest.json')
)
expect(manifest.pages404).toBe(true)
})
it('specify to use the 404 page still in the routes-manifest', async () => {
const manifest = await fs.readJSON(
join(appDir, '.next/routes-manifest.json')
)
expect(manifest.pages404).toBe(true)
})

it('should still use 404 page', async () => {
const res = await fetchViaHTTP(appPort, '/abc')
expect(res.status).toBe(404)
const $ = cheerio.load(await res.text())
expect($('#404-title').text()).toBe('Hi There')
})
})
it('should still use 404 page', async () => {
const res = await fetchViaHTTP(appPort, '/abc')
expect(res.status).toBe(404)
const $ = cheerio.load(await res.text())
expect($('#404-title').text()).toBe('Hi There')
})
}
)

describe('dev mode', () => {
describe('development mode', () => {
let stderr = ''
let stdout = ''

Expand Down
31 changes: 17 additions & 14 deletions test/integration/404-page-custom-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,29 @@ const runTests = (mode) => {
}

describe('Default 404 Page with custom _error', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
const { code } = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})
it('should build successfully', async () => {
const { code } = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})

expect(code).toBe(0)
expect(code).toBe(0)

appPort = await findPort()
appPort = await findPort()

app = await nextStart(appDir, appPort)
})
app = await nextStart(appDir, appPort)
})

runTests('server')
})
runTests('server')
}
)

describe('dev mode', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
Expand Down
69 changes: 36 additions & 33 deletions test/integration/404-page-ssg/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,45 @@ const runTests = (isDev) => {
}

describe('404 Page Support SSG', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
const {
code,
stderr: buildStderr,
stdout: buildStdout,
} = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
const {
code,
stderr: buildStderr,
stdout: buildStdout,
} = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})

expect(code).toBe(0)
expect(buildStderr).not.toMatch(gip404Err)
expect(buildStdout).not.toMatch(gip404Err)

appPort = await findPort()
stderr = ''
stdout = ''

app = await nextStart(appDir, appPort, {
onStdout(msg) {
stdout += msg
},
onStderr(msg) {
stderr += msg
},
})
buildId = await fs.readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
})

expect(code).toBe(0)
expect(buildStderr).not.toMatch(gip404Err)
expect(buildStdout).not.toMatch(gip404Err)

appPort = await findPort()
stderr = ''
stdout = ''

app = await nextStart(appDir, appPort, {
onStdout(msg) {
stdout += msg
},
onStderr(msg) {
stderr += msg
},
})
buildId = await fs.readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
})

runTests()
})
runTests()
}
)

describe('dev mode', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
stderr = ''
Expand Down
Loading

0 comments on commit 1e710ab

Please sign in to comment.