Skip to content

Commit 8662ba0

Browse files
authored
Turbopack build: Skip irrelevant telemetry tests (#69671)
Similar to #68969, skips a few more tests that are checking features that we don't have to report on. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
1 parent 668558a commit 8662ba0

File tree

3 files changed

+269
-229
lines changed

3 files changed

+269
-229
lines changed

test/integration/telemetry/test/config.test.js

Lines changed: 200 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -264,95 +264,105 @@ describe('config telemetry', () => {
264264
expect(event1).toMatch(/"@next\/next\/.+?": "(off|warn|error)"/)
265265
})
266266

267-
it('emits telemery for usage of image, script & dynamic', async () => {
268-
const { stderr } = await nextBuild(appDir, [], {
269-
stderr: true,
270-
env: { NEXT_TELEMETRY_DEBUG: 1 },
271-
lint: true,
272-
})
273-
const featureUsageEvents = findAllTelemetryEvents(
274-
stderr,
275-
'NEXT_BUILD_FEATURE_USAGE'
276-
)
277-
278-
expect(featureUsageEvents).toEqual(
279-
expect.arrayContaining([
280-
{
281-
featureName: 'next/image',
282-
invocationCount: 2,
283-
},
284-
{
285-
featureName: 'next/script',
286-
invocationCount: 1,
287-
},
288-
{
289-
featureName: 'next/dynamic',
290-
invocationCount: 1,
291-
},
292-
])
293-
)
294-
})
267+
// Turbopack intentionally does not support these events
268+
;(process.env.TURBOPACK ? it.skip : it)(
269+
'emits telemery for usage of image, script & dynamic',
270+
async () => {
271+
const { stderr } = await nextBuild(appDir, [], {
272+
stderr: true,
273+
env: { NEXT_TELEMETRY_DEBUG: 1 },
274+
lint: true,
275+
})
276+
const featureUsageEvents = findAllTelemetryEvents(
277+
stderr,
278+
'NEXT_BUILD_FEATURE_USAGE'
279+
)
295280

296-
it('emits telemetry for usage of swc', async () => {
297-
await fs.remove(path.join(appDir, 'next.config.js'))
298-
await fs.remove(path.join(appDir, 'jsconfig.json'))
299-
await fs.rename(
300-
path.join(appDir, 'next.config.swc'),
301-
path.join(appDir, 'next.config.js')
302-
)
303-
await fs.rename(
304-
path.join(appDir, 'jsconfig.swc'),
305-
path.join(appDir, 'jsconfig.json')
306-
)
307-
const { stderr } = await nextBuild(appDir, [], {
308-
stderr: true,
309-
env: { NEXT_TELEMETRY_DEBUG: 1 },
310-
})
311-
await fs.rename(
312-
path.join(appDir, 'next.config.js'),
313-
path.join(appDir, 'next.config.swc')
314-
)
315-
await fs.rename(
316-
path.join(appDir, 'jsconfig.json'),
317-
path.join(appDir, 'jsconfig.swc')
318-
)
319-
const featureUsageEvents = findAllTelemetryEvents(
320-
stderr,
321-
'NEXT_BUILD_FEATURE_USAGE'
322-
)
323-
expect(featureUsageEvents).toEqual(
324-
expect.arrayContaining([
325-
{
326-
featureName: 'swcLoader',
327-
invocationCount: 1,
328-
},
329-
{
330-
featureName: 'swcRelay',
331-
invocationCount: 1,
332-
},
333-
{
334-
featureName: 'swcStyledComponents',
335-
invocationCount: 1,
336-
},
337-
{
338-
featureName: 'swcReactRemoveProperties',
339-
invocationCount: 1,
340-
},
341-
{
342-
featureName: 'swcExperimentalDecorators',
343-
invocationCount: 1,
344-
},
345-
{
346-
featureName: 'swcRemoveConsole',
347-
invocationCount: 1,
348-
},
349-
{
350-
featureName: 'swcImportSource',
351-
invocationCount: 0,
352-
},
353-
])
354-
)
355-
})
281+
// eslint-disable-next-line jest/no-standalone-expect
282+
expect(featureUsageEvents).toEqual(
283+
expect.arrayContaining([
284+
{
285+
featureName: 'next/image',
286+
invocationCount: 2,
287+
},
288+
{
289+
featureName: 'next/script',
290+
invocationCount: 1,
291+
},
292+
{
293+
featureName: 'next/dynamic',
294+
invocationCount: 1,
295+
},
296+
])
297+
)
298+
}
299+
)
300+
301+
// Turbopack intentionally does not support these events
302+
;(process.env.TURBOPACK ? it.skip : it)(
303+
'emits telemetry for usage of swc',
304+
async () => {
305+
await fs.remove(path.join(appDir, 'next.config.js'))
306+
await fs.remove(path.join(appDir, 'jsconfig.json'))
307+
await fs.rename(
308+
path.join(appDir, 'next.config.swc'),
309+
path.join(appDir, 'next.config.js')
310+
)
311+
await fs.rename(
312+
path.join(appDir, 'jsconfig.swc'),
313+
path.join(appDir, 'jsconfig.json')
314+
)
315+
const { stderr } = await nextBuild(appDir, [], {
316+
stderr: true,
317+
env: { NEXT_TELEMETRY_DEBUG: 1 },
318+
})
319+
await fs.rename(
320+
path.join(appDir, 'next.config.js'),
321+
path.join(appDir, 'next.config.swc')
322+
)
323+
await fs.rename(
324+
path.join(appDir, 'jsconfig.json'),
325+
path.join(appDir, 'jsconfig.swc')
326+
)
327+
const featureUsageEvents = findAllTelemetryEvents(
328+
stderr,
329+
'NEXT_BUILD_FEATURE_USAGE'
330+
)
331+
// eslint-disable-next-line jest/no-standalone-expect
332+
expect(featureUsageEvents).toEqual(
333+
expect.arrayContaining([
334+
{
335+
featureName: 'swcLoader',
336+
invocationCount: 1,
337+
},
338+
{
339+
featureName: 'swcRelay',
340+
invocationCount: 1,
341+
},
342+
{
343+
featureName: 'swcStyledComponents',
344+
invocationCount: 1,
345+
},
346+
{
347+
featureName: 'swcReactRemoveProperties',
348+
invocationCount: 1,
349+
},
350+
{
351+
featureName: 'swcExperimentalDecorators',
352+
invocationCount: 1,
353+
},
354+
{
355+
featureName: 'swcRemoveConsole',
356+
invocationCount: 1,
357+
},
358+
{
359+
featureName: 'swcImportSource',
360+
invocationCount: 0,
361+
},
362+
])
363+
)
364+
}
365+
)
356366

357367
it('emits telemetry for usage of `optimizeCss`', async () => {
358368
await fs.rename(
@@ -478,95 +488,117 @@ describe('config telemetry', () => {
478488
])
479489
})
480490

481-
it('emits telemetry for usage of next/legacy/image', async () => {
482-
const { stderr } = await nextBuild(appDir, [], {
483-
stderr: true,
484-
env: { NEXT_TELEMETRY_DEBUG: 1 },
485-
})
486-
const featureUsageEvents = findAllTelemetryEvents(
487-
stderr,
488-
'NEXT_BUILD_FEATURE_USAGE'
489-
)
490-
expect(featureUsageEvents).toContainEqual({
491-
featureName: 'next/legacy/image',
492-
invocationCount: 2,
493-
})
494-
expect(featureUsageEvents).toContainEqual({
495-
featureName: 'next/image',
496-
invocationCount: 2,
497-
})
498-
})
491+
// Turbopack intentionally does not support these events
492+
;(process.env.TURBOPACK ? it.skip : it)(
493+
'emits telemetry for usage of next/legacy/image',
494+
async () => {
495+
const { stderr } = await nextBuild(appDir, [], {
496+
stderr: true,
497+
env: { NEXT_TELEMETRY_DEBUG: 1 },
498+
})
499+
const featureUsageEvents = findAllTelemetryEvents(
500+
stderr,
501+
'NEXT_BUILD_FEATURE_USAGE'
502+
)
503+
// eslint-disable-next-line jest/no-standalone-expect
504+
expect(featureUsageEvents).toContainEqual({
505+
featureName: 'next/legacy/image',
506+
invocationCount: 2,
507+
})
508+
// eslint-disable-next-line jest/no-standalone-expect
509+
expect(featureUsageEvents).toContainEqual({
510+
featureName: 'next/image',
511+
invocationCount: 2,
512+
})
513+
}
514+
)
499515

500-
it('emits telemetry for usage of @vercel/og', async () => {
501-
const { stderr } = await nextBuild(appDir, [], {
502-
stderr: true,
503-
env: { NEXT_TELEMETRY_DEBUG: 1 },
504-
})
505-
const featureUsageEvents = findAllTelemetryEvents(
506-
stderr,
507-
'NEXT_BUILD_FEATURE_USAGE'
508-
)
509-
expect(featureUsageEvents).toContainEqual({
510-
featureName: 'vercelImageGeneration',
511-
invocationCount: 1,
512-
})
513-
})
516+
// Turbopack intentionally does not support these events
517+
;(process.env.TURBOPACK ? it.skip : it)(
518+
'emits telemetry for usage of @vercel/og',
519+
async () => {
520+
const { stderr } = await nextBuild(appDir, [], {
521+
stderr: true,
522+
env: { NEXT_TELEMETRY_DEBUG: 1 },
523+
})
524+
const featureUsageEvents = findAllTelemetryEvents(
525+
stderr,
526+
'NEXT_BUILD_FEATURE_USAGE'
527+
)
528+
// eslint-disable-next-line jest/no-standalone-expect
529+
expect(featureUsageEvents).toContainEqual({
530+
featureName: 'vercelImageGeneration',
531+
invocationCount: 1,
532+
})
533+
}
534+
)
514535

515-
it('emits telemetry for transpilePackages', async () => {
516-
await fs.rename(
517-
path.join(appDir, 'next.config.transpile-packages'),
518-
path.join(appDir, 'next.config.js')
519-
)
536+
// Turbopack intentionally does not support these events
537+
;(process.env.TURBOPACK ? it.skip : it)(
538+
'emits telemetry for transpilePackages',
539+
async () => {
540+
await fs.rename(
541+
path.join(appDir, 'next.config.transpile-packages'),
542+
path.join(appDir, 'next.config.js')
543+
)
520544

521-
const { stderr } = await nextBuild(appDir, [], {
522-
stderr: true,
523-
env: { NEXT_TELEMETRY_DEBUG: 1 },
524-
})
545+
const { stderr } = await nextBuild(appDir, [], {
546+
stderr: true,
547+
env: { NEXT_TELEMETRY_DEBUG: 1 },
548+
})
525549

526-
await fs.rename(
527-
path.join(appDir, 'next.config.js'),
528-
path.join(appDir, 'next.config.transpile-packages')
529-
)
550+
await fs.rename(
551+
path.join(appDir, 'next.config.js'),
552+
path.join(appDir, 'next.config.transpile-packages')
553+
)
530554

531-
const featureUsageEvents = findAllTelemetryEvents(
532-
stderr,
533-
'NEXT_BUILD_FEATURE_USAGE'
534-
)
535-
expect(featureUsageEvents).toContainEqual({
536-
featureName: 'transpilePackages',
537-
invocationCount: 1,
538-
})
539-
})
555+
const featureUsageEvents = findAllTelemetryEvents(
556+
stderr,
557+
'NEXT_BUILD_FEATURE_USAGE'
558+
)
559+
// eslint-disable-next-line jest/no-standalone-expect
560+
expect(featureUsageEvents).toContainEqual({
561+
featureName: 'transpilePackages',
562+
invocationCount: 1,
563+
})
564+
}
565+
)
540566

541-
it('emits telemetry for middleware related options', async () => {
542-
await fs.rename(
543-
path.join(appDir, 'next.config.middleware-options'),
544-
path.join(appDir, 'next.config.js')
545-
)
567+
// Turbopack intentionally does not support these events
568+
;(process.env.TURBOPACK ? it.skip : it)(
569+
'emits telemetry for middleware related options',
570+
async () => {
571+
await fs.rename(
572+
path.join(appDir, 'next.config.middleware-options'),
573+
path.join(appDir, 'next.config.js')
574+
)
546575

547-
const { stderr } = await nextBuild(appDir, [], {
548-
stderr: true,
549-
env: { NEXT_TELEMETRY_DEBUG: 1 },
550-
})
576+
const { stderr } = await nextBuild(appDir, [], {
577+
stderr: true,
578+
env: { NEXT_TELEMETRY_DEBUG: 1 },
579+
})
551580

552-
await fs.rename(
553-
path.join(appDir, 'next.config.js'),
554-
path.join(appDir, 'next.config.middleware-options')
555-
)
581+
await fs.rename(
582+
path.join(appDir, 'next.config.js'),
583+
path.join(appDir, 'next.config.middleware-options')
584+
)
556585

557-
const featureUsageEvents = findAllTelemetryEvents(
558-
stderr,
559-
'NEXT_BUILD_FEATURE_USAGE'
560-
)
561-
expect(featureUsageEvents).toContainEqual({
562-
featureName: 'skipMiddlewareUrlNormalize',
563-
invocationCount: 1,
564-
})
565-
expect(featureUsageEvents).toContainEqual({
566-
featureName: 'skipTrailingSlashRedirect',
567-
invocationCount: 1,
568-
})
569-
})
586+
const featureUsageEvents = findAllTelemetryEvents(
587+
stderr,
588+
'NEXT_BUILD_FEATURE_USAGE'
589+
)
590+
// eslint-disable-next-line jest/no-standalone-expect
591+
expect(featureUsageEvents).toContainEqual({
592+
featureName: 'skipMiddlewareUrlNormalize',
593+
invocationCount: 1,
594+
})
595+
// eslint-disable-next-line jest/no-standalone-expect
596+
expect(featureUsageEvents).toContainEqual({
597+
featureName: 'skipTrailingSlashRedirect',
598+
invocationCount: 1,
599+
})
600+
}
601+
)
570602

571603
it('emits telemetry for default React Compiler options', async () => {
572604
const { stderr } = await nextBuild(appDir, [], {

0 commit comments

Comments
 (0)