forked from vercel/next.js
/
disabled.test.js
46 lines (36 loc) · 1.22 KB
/
disabled.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* eslint-env jest */
import { join } from 'path'
import webdriver from 'next-webdriver'
import { killApp, findPort, nextBuild, nextStart } from 'next-test-utils'
const appDir = join(__dirname, '../')
let appPort
let server
jest.setTimeout(1000 * 60 * 2)
describe('Analytics relayer (disabled)', () => {
let stdout
beforeAll(async () => {
appPort = await findPort()
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
server = await nextStart(appDir, appPort)
})
afterAll(() => killApp(server))
it('Does not relay any data', async () => {
const browser = await webdriver(appPort, '/')
await browser.waitForElementByCss('h1')
const h1Text = await browser.elementByCss('h1').text()
const firstContentfulPaint = parseFloat(
await browser.eval('localStorage.getItem("FCP")')
)
expect(h1Text).toMatch(/Foo!/)
expect(firstContentfulPaint).not.toBeNaN()
expect(firstContentfulPaint).toBeGreaterThan(0)
const beacons = (await browser.eval('window.__BEACONS')).map(([, value]) =>
Object.fromEntries(new URLSearchParams(value))
)
expect(beacons.length).toBe(0)
expect(stdout).not.toMatch('Next.js Analytics')
await browser.close()
})
})