e7a8645cb8
### 🤔 What's in there? We've deprecated config's `analyticsId` in 14.1.1 [almost 3 months ago](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.2). Users can opt in fot `@vercel/speed-insights`, or use `useReportWebVitals` to report to any provider they'd like. This PR: - removes `analyticsId` key from configuration - stops setting `__NEXT_PUBLIC_ANALYTICS_ID` env variable when the key was present - stops injecting `performance-relayer` file, when the variable is set - cleans up related test code.
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { createNext } from 'e2e-utils'
|
|
import { NextInstance } from 'e2e-utils'
|
|
import { check } from 'next-test-utils'
|
|
|
|
describe('useReportWebVitals hook', () => {
|
|
let next: NextInstance
|
|
|
|
beforeAll(async () => {
|
|
next = await createNext({
|
|
files: __dirname,
|
|
skipStart: true,
|
|
env: {},
|
|
})
|
|
|
|
await next.start()
|
|
})
|
|
afterAll(() => next.destroy())
|
|
|
|
// Analytics events are only sent in production
|
|
it('should send web-vitals', async () => {
|
|
await next.fetch('/report-web-vitals')
|
|
|
|
let eventsCount = 0
|
|
const browser = await next.browser('/report-web-vitals', {
|
|
beforePageLoad: (page) => {
|
|
page.route('https://example.vercel.sh/vitals', (route) => {
|
|
eventsCount += 1
|
|
route.fulfill()
|
|
})
|
|
},
|
|
})
|
|
|
|
// Refresh will trigger CLS and LCP. When page loads FCP and TTFB will trigger:
|
|
await browser.refresh()
|
|
|
|
// After interaction LCP and FID will trigger
|
|
await browser.elementById('btn').click()
|
|
|
|
// Make sure all registered events in performance-relayer has fired
|
|
await check(async () => {
|
|
expect(eventsCount).toBeGreaterThanOrEqual(6)
|
|
return 'success'
|
|
}, 'success')
|
|
})
|
|
})
|