-
Notifications
You must be signed in to change notification settings - Fork 26k
/
basics.js
30 lines (24 loc) · 1.06 KB
/
basics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* eslint-env jest */
import webdriver from 'next-webdriver'
import cheerio from 'cheerio'
import { renderViaHTTP } from 'next-test-utils'
export default (context) => {
it('no warnings for image related link props', async () => {
await renderViaHTTP(context.appPort, '/')
expect(context.stderr).not.toContain('Warning: Invalid DOM property')
expect(context.stderr).not.toContain('Warning: React does not recognize')
})
it('hydrates correctly for normal page', async () => {
const browser = await webdriver(context.appPort, '/')
expect(await browser.eval('window.didHydrate')).toBe(true)
expect(await browser.elementById('react-dom-version').text()).toMatch(/18/)
})
it('useId() values should match on hydration', async () => {
const html = await renderViaHTTP(context.appPort, '/use-id')
const $ = cheerio.load(html)
const ssrId = $('#id').text()
const browser = await webdriver(context.appPort, '/use-id')
const csrId = await browser.eval('document.getElementById("id").innerText')
expect(ssrId).toEqual(csrId)
})
}