Unverified Commit 8f7b0fb7 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack build: Fix edge-runtime-configurable-guards tests (#70088)

This test was checking for an unsupported feature, skipped and
documented.

<!-- 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 30ce5d4b
......@@ -72,6 +72,7 @@ These features are currently not supported:
- We are currently not planning to support `experimental.urlImports` in Next.js with Turbopack.
- [`:import` and `:export` ICSS rules](https://github.com/css-modules/icss)
- We are currently not planning to support `:import` and `:export` ICSS rules in Next.js with Turbopack as [Lightning CSS](https://lightningcss.dev/css-modules.html) the CSS parser Turbopack uses does not support these rules.
- `unstable_allowDynamic` configuration in edge runtime
## Generating Trace Files
......
......@@ -109,7 +109,7 @@ describe('Edge runtime configurable guards', () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
env: process.env.TURBOPACK ? {} : { NEXT_TELEMETRY_DEBUG: 1 },
})
expect(output.code).toBe(1)
......@@ -314,27 +314,38 @@ describe('Edge runtime configurable guards', () => {
;(process.env.TURBOPACK_DEV ? 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.appPort = await findPort()
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`
)
})
// This checks the unstable_allowDynamic configuration which is not supported in Turbopack.
;(process.env.TURBOPACK ? it.skip : it)(
'build and does not warn at runtime',
async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: process.env.TURBOPACK ? {} : { NEXT_TELEMETRY_DEBUG: 1 },
})
// eslint-disable-next-line jest/no-standalone-expect
expect(output.stderr).not.toContain(`Build failed`)
if (!process.env.TURBOPACK) {
// eslint-disable-next-line jest/no-standalone-expect
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
}
context.appPort = await findPort()
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
// eslint-disable-next-line jest/no-standalone-expect
expect(res.status).toBe(200)
// eslint-disable-next-line jest/no-standalone-expect
expect(context.logs.output).not.toContain(`warn`)
// eslint-disable-next-line jest/no-standalone-expect
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
}
)
}
)
})
......@@ -403,13 +414,14 @@ describe('Edge runtime configurable guards', () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
env: process.env.TURBOPACK ? {} : { 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)
if (!process.env.TURBOPACK) {
expect(output.stderr).toContain(TELEMETRY_EVENT_NAME)
}
})
}
)
......@@ -457,26 +469,34 @@ describe('Edge runtime configurable guards', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
// This checks the unstable_allowDynamic configuration which is not supported in Turbopack.
// 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.appPort = await findPort()
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 ? it.skip : it)(
'build and does not warn at runtime',
async () => {
const output = await nextBuild(context.appDir, undefined, {
stdout: true,
stderr: true,
})
// eslint-disable-next-line jest/no-standalone-expect
expect(output.stderr).not.toContain(`Build failed`)
context.appPort = await findPort()
context.app = await nextStart(
context.appDir,
context.appPort,
appOption
)
const res = await fetchViaHTTP(context.appPort, url)
// eslint-disable-next-line jest/no-standalone-expect
expect(res.status).toBe(200)
// eslint-disable-next-line jest/no-standalone-expect
expect(context.logs.output).not.toContain(`warn`)
// eslint-disable-next-line jest/no-standalone-expect
expect(context.logs.output).not.toContain(
`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime`
)
}
)
}
)
})
......
......@@ -8968,25 +8968,25 @@
"Edge runtime configurable guards Edge API using lib with unallowed, used dynamic code warns in dev at runtime",
"Edge runtime configurable guards Edge API with allowed, used dynamic code still warns in dev at runtime",
"Edge runtime configurable guards Edge API with use of Function as a type does not warn in dev at runtime",
"Edge runtime configurable guards Edge API with use of Function as a type production mode build and does not warn at runtime",
"Edge runtime configurable guards Middleware using lib with allowed, used dynamic code still warns in dev at runtime",
"Edge runtime configurable guards Middleware using lib with unallowed, used dynamic code warns in dev at runtime",
"Edge runtime configurable guards Middleware with allowed, used dynamic code still warns in dev at runtime",
"Edge runtime configurable guards Middleware with use of Function as a type does not warn in dev at runtime",
"Edge runtime configurable guards Middleware with use of Function as a type production mode build and does not warn at runtime",
"Edge runtime configurable guards Multiple functions with different configurations warns in dev for allowed code",
"Edge runtime configurable guards Multiple functions with different configurations warns in dev for unallowed code",
"Edge runtime configurable guards Multiple functions with different configurations production mode fails to build because of unallowed code"
],
"failed": [
"Edge runtime configurable guards Edge API using lib with allowed, unused dynamic code production mode build and does not warn at runtime",
"Edge runtime configurable guards Multiple functions with different configurations production mode fails to build because of unallowed code",
"Edge runtime configurable guards Edge API using lib with unallowed, used dynamic code production mode fails to build because of dynamic code evaluation",
"Edge runtime configurable guards Middleware using lib with unallowed, used dynamic code production mode fails to build because of dynamic code evaluation"
],
"failed": [],
"pending": [
"Edge runtime configurable guards Edge API with use of Function as a type production mode build and does not warn at runtime",
"Edge runtime configurable guards Middleware with use of Function as a type production mode build and does not warn at runtime",
"Edge runtime configurable guards Edge API with allowed, unused dynamic code production mode build and does not warn at runtime",
"Edge runtime configurable guards Middleware using lib with allowed, unused dynamic code production mode build and does not warn at runtime",
"Edge runtime configurable guards Middleware using lib with unallowed, used dynamic code production mode fails to build because of dynamic code evaluation",
"Edge runtime configurable guards Middleware with allowed, unused dynamic code production mode build and does not warn at runtime"
"Edge runtime configurable guards Middleware with allowed, unused dynamic code production mode build and does not warn at runtime",
"Edge runtime configurable guards Edge API using lib with allowed, unused dynamic code production mode build and does not warn at runtime",
"Edge runtime configurable guards Middleware using lib with allowed, unused dynamic code production mode build and does not warn at runtime"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
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