-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathErrorPage.test.js
More file actions
42 lines (36 loc) · 1.45 KB
/
ErrorPage.test.js
File metadata and controls
42 lines (36 loc) · 1.45 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
describe('ErrorPage 500', () => {
let response
beforeAll(async () => {
response = await page.goto('http://localhost:6969/error-page?status=500', { waitUntil: 'networkidle0' })
})
test('pages with error have a 500 status', async () => {
const status = response.status()
expect(status).toBe(500)
})
test('pages with error have a status key with the value 500', async () => {
await page.waitForSelector('[data-page-status="500"]')
const element = await page.$('[data-page-status="500"]')
expect(element).toBeTruthy()
})
})
describe('ErrorPage 404', () => {
test('pages with status 404 have a 404 status', async () => {
const response = await page.goto('http://localhost:6969/error-page', { waitUntil: 'networkidle0' })
const status = response.status()
expect(status).toBe(404)
})
test('pages status reflects on the client context', async () => {
await page.waitForSelector('[data-page-status="404"]')
const element = await page.$('[data-page-status="404"]')
expect(element).toBeTruthy()
})
})
describe('ErrorPage offline', () => {
test('the offline template should always have a 200 status', async () => {
await page.goto('http://localhost:6969', { waitUntil: 'networkidle0' })
const link = await page.$eval('a', (element) => element.href)
const response = await page.goto(link, { waitUntil: 'networkidle0' })
const status = response.status()
expect([200, 304]).toContain(status)
})
})