Skip to content

Commit 1e77052

Browse files
chargomeclaude
andcommitted
test(nextjs): Skip Turbopack-only server-component streaming tests on webpack
The new webpack variant runs the whole nextjs-16-streaming suite under webpack, including two server-component tests that assert Turbopack-internal span names (`build component tree`, `resolve page components`, ...) that webpack never emits. Gate them on the SDK's `turbopack` span attribute (TEST_ENV=production is shared by both prod variants, so env alone cannot distinguish them). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6180813 commit 1e77052

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

dev-packages/e2e-tests/test-applications/nextjs-16-streaming/tests/server-components.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { expect, test } from '@playwright/test';
22
import { waitForStreamedSpan, waitForStreamedSpans, getSpanOp } from '@sentry-internal/test-utils';
33
import { isDevMode } from './isDevMode';
44

5+
// The SDK sets a `turbopack` span attribute (from build metadata) on Turbopack builds. Since
6+
// TEST_ENV=production is shared by the turbopack and webpack prod variants, this is the only reliable
7+
// way to tell them apart at runtime.
8+
function isTurbopackBuild(spans: Array<{ attributes: Record<string, { value?: unknown }> }>): boolean {
9+
return spans.some(span => span.attributes['turbopack']?.value === true);
10+
}
11+
512
test('Sends a streamed span for a request to app router with URL', async ({ page }) => {
613
test.skip(isDevMode, 'Turbopack intermittently returns 404 for nested dynamic routes in dev mode');
714

@@ -31,6 +38,11 @@ test('Will create streamed spans for every server component and metadata generat
3138
const spans = await spansPromise;
3239
const spanNames = spans.map(span => span.name);
3340

41+
// These are Next.js-internal server-component spans that only Turbopack emits - webpack produces a
42+
// different span set. TEST_ENV=production is shared by both prod variants, so gate on the independent
43+
// `turbopack` attribute (set by the SDK from build metadata) instead of the env.
44+
test.skip(!isTurbopackBuild(spans), 'Server component spans are only emitted by Turbopack builds');
45+
3446
expect(spanNames).toContainEqual('render route (app) /nested-layout');
3547
expect(spanNames).toContainEqual('build component tree');
3648
expect(spanNames).toContainEqual('resolve root layout server component');
@@ -55,6 +67,9 @@ test('Will create streamed spans for every server component and metadata generat
5567
const spans = await spansPromise;
5668
const spanNames = spans.map(span => span.name);
5769

70+
// See note above - these server-component spans are only emitted by Turbopack builds.
71+
test.skip(!isTurbopackBuild(spans), 'Server component spans are only emitted by Turbopack builds');
72+
5873
expect(spanNames).toContainEqual('resolve page components');
5974
expect(spanNames).toContainEqual('render route (app) /nested-layout/[dynamic]');
6075
expect(spanNames).toContainEqual('build component tree');

0 commit comments

Comments
 (0)