-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
development-logs.js
40 lines (38 loc) · 1.13 KB
/
development-logs.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
31
32
33
34
35
36
37
38
39
40
/* eslint-env jest */
import webdriver from 'next-webdriver'
export default (context) => {
async function getLogs$(path) {
let foundLog = false
let browser
try {
browser = await webdriver(context.appPort, path)
const browserLogs = await browser.log('browser')
browserLogs.forEach((log) => {
if (log.message.includes('Next.js auto-prefetches automatically')) {
foundLog = true
}
})
} finally {
if (browser) {
await browser.close()
}
}
return foundLog
}
describe('Development Logs', () => {
it('should warn when prefetch is true', async () => {
const foundLog = await getLogs$('/development-logs')
expect(foundLog).toBe(true)
})
it('should not warn when prefetch is false', async () => {
const foundLog = await getLogs$(
'/development-logs/link-with-prefetch-false'
)
expect(foundLog).toBe(false)
})
it('should not warn when prefetch is not specified', async () => {
const foundLog = await getLogs$('/development-logs/link-with-no-prefetch')
expect(foundLog).toBe(false)
})
})
}