Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flakey dev context tests #43951

Merged
merged 1 commit into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

27 changes: 23 additions & 4 deletions test/development/acceptance-app/server-components.test.ts
Expand Up @@ -3,6 +3,7 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { check } from 'next-test-utils'

describe('Error Overlay for server components', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
Expand Down Expand Up @@ -51,7 +52,12 @@ describe('Error Overlay for server components', () => {
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource(true)).toMatchSnapshot()
await check(async () => {
expect(await session.getRedboxSource(true)).toContain(
`TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component`
)
return 'success'
}, 'success')
expect(next.cliOutput).toContain(
'createContext only works in Client Components'
)
Expand Down Expand Up @@ -100,7 +106,14 @@ describe('Error Overlay for server components', () => {
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource(true)).toMatchSnapshot()

await check(async () => {
expect(await session.getRedboxSource(true)).toContain(
`TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component`
)
return 'success'
}, 'success')

expect(next.cliOutput).toContain(
'createContext only works in Client Components'
)
Expand Down Expand Up @@ -149,11 +162,17 @@ describe('Error Overlay for server components', () => {
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource(true)).toMatchSnapshot()

await check(async () => {
expect(await session.getRedboxSource(true)).toContain(
`TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component`
)
return 'success'
}, 'success')

expect(next.cliOutput).toContain(
'createContext only works in Client Components'
)

await cleanup()
})
})
Expand Down