Skip to content

Commit

Permalink
Update flakey dev context tests (#43951)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Dec 12, 2022
1 parent 5cf7408 commit 6ba53d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 46 deletions.

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

0 comments on commit 6ba53d8

Please sign in to comment.