-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
32 lines (25 loc) · 852 Bytes
/
index.test.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
import * as http from 'node:http'
import test from 'ava'
import {withChrome} from '../../test/helpers/index.js'
import {openTab, navigate, findElement} from '../../index.js'
withChrome(test)
test('navigating to different URLs', async (t) => {
const {browser} = global
const tab = await openTab(browser, 'http://example.com')
await navigate(tab, 'https://google.com/ncr')
await findElement(tab, '[name="q"]')
t.pass()
})
test('allowing the navigation timeout to be set', async (t) => {
const {browser} = global
const tab = await openTab(browser, 'http://example.com')
const server = http.createServer(() => {})
server.listen(10_101)
try {
await navigate(tab, 'http://127.0.0.1:10101', {timeout: 1000})
} catch (error) {
t.regex(error.message, /Navigation timeout of 1000 ms/)
} finally {
server.close()
}
})