Update flaky dev tests (#46179)

ref:
[slack](https://vercel.slack.com/archives/C04DUD7EB1B/p1676914009577859)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
This commit is contained in:
Hannes Bornö 2023-02-21 23:28:25 +01:00 committed by GitHub
parent 185a8921c8
commit a5ef594a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -188,6 +188,7 @@ createNextDescribe(
[
'app/comp2.js',
`
import 'server-only-package'
export function Comp2() {
return (
<div>Hello world</div>
@ -198,8 +199,7 @@ createNextDescribe(
],
[
'app/page.js',
`'use client'
import { Comp1 } from './comp1'
`import { Comp1 } from './comp1'
export default function Page() {
return <Comp1 />
@ -209,9 +209,9 @@ createNextDescribe(
])
)
const file = 'app/comp2.js'
const file = 'app/page.js'
const content = await next.readFile(file)
await session.patch(file, 'import "server-only-package"\n' + content)
await session.patch(file, "'use client'\n" + content)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`

View file

@ -46,23 +46,28 @@ createNextDescribe(
const pageFile = 'app/client-with-errors/metadata-export/page.js'
const content = await next.readFile(pageFile)
// Add `metadata` error
let uncomment = content.replace(
'// export const metadata',
'export const metadata'
)
await session.patch(pageFile, uncomment)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toInclude(
'"metadata" is not supported in app/'
)
// Restore file
await session.patch(pageFile, content)
expect(await session.hasRedbox(false)).toBe(false)
// Add `generateMetadata` error
uncomment = content.replace(
'// export async function generateMetadata',
'export async function generateMetadata'
)
await session.patch(pageFile, uncomment)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toInclude(
'"generateMetadata" is not supported in app/'