Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1f11a4

Browse files
committed
Fix production tests.
1 parent 03209d8 commit a1f11a4

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default () => (
2+
<div className='about-page'>About Page</div>
3+
)
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import Link from 'next/link'
2+
13
export default () => (
2-
<div>Hello World</div>
4+
<div>
5+
<Link href='/about'><a>About Page</a></Link>
6+
<p>Hello World</p>
7+
</div>
38
)
Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global jasmine, describe, it, expect, beforeAll, afterAll */
22

3-
import fetch from 'node-fetch'
43
import { join } from 'path'
54
import {
65
nextServer,
@@ -9,6 +8,7 @@ import {
98
stopApp,
109
renderViaHTTP
1110
} from 'next-test-utils'
11+
import webdriver from 'next-webdriver'
1212

1313
const appDir = join(__dirname, '../')
1414
let appPort
@@ -37,32 +37,16 @@ describe('Production Usage', () => {
3737
})
3838
})
3939

40-
describe('JSON pages', () => {
41-
describe('when asked for a normal page', () => {
42-
it('should serve the normal page', async () => {
43-
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
44-
const res = await fetch(url, { compress: false })
45-
expect(res.headers.get('Content-Encoding')).toBeNull()
40+
describe('With navigation', () => {
41+
it('should navigate via client side', async () => {
42+
const browser = await webdriver(appPort, '/')
43+
const text = await browser
44+
.elementByCss('a').click()
45+
.waitForElementByCss('.about-page')
46+
.elementByCss('div').text()
4647

47-
const page = await res.json()
48-
expect(page.component).toBeDefined()
49-
})
50-
})
51-
52-
describe('when asked for a page with an unknown encoding', () => {
53-
it('should serve the normal page', async () => {
54-
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
55-
const res = await fetch(url, {
56-
compress: false,
57-
headers: {
58-
'Accept-Encoding': 'br'
59-
}
60-
})
61-
expect(res.headers.get('Content-Encoding')).toBeNull()
62-
63-
const page = await res.json()
64-
expect(page.component).toBeDefined()
65-
})
48+
expect(text).toBe('About Page')
49+
browser.close()
6650
})
6751
})
6852
})

0 commit comments

Comments
 (0)