Skip to content

Commit

Permalink
add test to assert indicator count
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 9, 2025
1 parent 0b15ef4 commit 3aa0cd4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Layout({ children }) {
return <body>{children}</body>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
getRedboxDescription,
getToastErrorCount,
hasErrorToast,
retry,
} from 'next-test-utils'
import { outdent } from 'outdent'

// TODO: merge with test/development/app-dir/missing-required-html-tags/index.test.ts
// once new overlay is stable
describe('app-dir - missing required html tags', () => {
const { next } = nextTestSetup({
files: __dirname,
})

it('should display correct error count in dev indicator', async () => {
const browser = await next.browser('/')

retry(async () => {
expect(await hasErrorToast(browser)).toBe(true)
})
// Dev indicator should show 1 error
expect(await getToastErrorCount(browser)).toBe(1)

await assertHasRedbox(browser)

await retry(async () => {
expect(await getRedboxDescription(browser)).toEqual(outdent`
The following tags are missing in the Root Layout: <html>.
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags
`)
})

await next.patchFile('app/layout.js', (code) =>
code.replace(
'return <body>{children}</body>',
'return <html><body>{children}</body></html>'
)
)

await assertNoRedbox(browser)
expect(await browser.elementByCss('p').text()).toBe('hello world')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @type {import('next').NextConfig}
*/
module.exports = {
experimental: {
newDevOverlay: true,
},
}

0 comments on commit 3aa0cd4

Please # to comment.