forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
43 lines (36 loc) · 1.16 KB
/
index.test.js
File metadata and controls
43 lines (36 loc) · 1.16 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
43
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
createNextDescribe(
'socket-io',
{
files: __dirname,
dependencies: {
'socket.io': '4.7.2',
'socket.io-client': '4.7.2',
'utf-8-validate': '6.0.3',
bufferutil: '4.0.8',
},
},
({ next }) => {
it('should support socket.io without falling back to polling', async () => {
let requestsCount = 0
const browser1 = await next.browser(next.url, '/')
const browser2 = await next.browser(next.url, '/', {
beforePageLoad(page) {
page.on('request', () => {
requestsCount++
})
},
})
const input1 = await browser1.elementByCss('input')
const input2 = await browser2.elementByCss('input')
await input1.fill('hello world')
await check(() => input2.inputValue(), /hello world/)
const currentRequestsCount = requestsCount
await input1.fill('123456')
await check(() => input2.inputValue(), /123456/)
// There should be no new requests (polling) and using the existing WS connection
expect(requestsCount).toBe(currentRequestsCount)
})
}
)