mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## What? Converts existing `createNext()` usage into `nextTestSetup()`. `createNext()` was the setup step we had before `nextTestSetup()` was added. This PR focused on the simple conversion cases. There will be a follow-up to complete the last few. --------- Co-authored-by: Cursor <[email protected]>
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { FileRef, nextTestSetup } from 'e2e-utils'
|
|
import { findAllTelemetryEvents } from 'next-test-utils'
|
|
import { join } from 'path'
|
|
|
|
const mockedGoogleFontResponses = require.resolve(
|
|
'./google-font-mocked-responses.js'
|
|
)
|
|
|
|
// Turbopack intentionally does not support these events
|
|
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
|
|
'next/font used telemetry',
|
|
() => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
pages: new FileRef(join(__dirname, 'telemetry/pages')),
|
|
},
|
|
env: {
|
|
NEXT_FONT_GOOGLE_MOCKED_RESPONSES: mockedGoogleFontResponses,
|
|
NEXT_TELEMETRY_DEBUG: '1',
|
|
},
|
|
})
|
|
|
|
it('should send next/font/google and next/font/local usage event', async () => {
|
|
const events = findAllTelemetryEvents(
|
|
next.cliOutput,
|
|
'NEXT_BUILD_FEATURE_USAGE'
|
|
)
|
|
expect(events).toContainEqual({
|
|
featureName: 'next/font/google',
|
|
invocationCount: 1,
|
|
})
|
|
expect(events).toContainEqual({
|
|
featureName: 'next/font/local',
|
|
invocationCount: 1,
|
|
})
|
|
})
|
|
}
|
|
)
|
|
|
|
// Turbopack intentionally does not support these events
|
|
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
|
|
'next/font unused telemetry',
|
|
() => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
pages: new FileRef(join(__dirname, 'telemetry/pages-unused')),
|
|
},
|
|
env: {
|
|
NEXT_FONT_GOOGLE_MOCKED_RESPONSES: mockedGoogleFontResponses,
|
|
NEXT_TELEMETRY_DEBUG: '1',
|
|
},
|
|
})
|
|
|
|
it('should not send next/font/google and next/font/local usage event', async () => {
|
|
const events = findAllTelemetryEvents(
|
|
next.cliOutput,
|
|
'NEXT_BUILD_FEATURE_USAGE'
|
|
)
|
|
expect(events).toContainEqual({
|
|
featureName: 'next/font/google',
|
|
invocationCount: 0,
|
|
})
|
|
expect(events).toContainEqual({
|
|
featureName: 'next/font/local',
|
|
invocationCount: 0,
|
|
})
|
|
})
|
|
}
|
|
)
|