Skip to content

Commit 1368328

Browse files
chargomeclaude
andcommitted
test(nextjs): Expect use cache route handler file path on Turbopack
Next.js 16.4 Turbopack now lists route handler `use cache` functions in the server-reference manifest, so `code.file.path` is set for both bundlers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c7ed7ca commit 1368328

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

‎dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/useCacheSpans.spec.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

4-
// Webpack lists route handler `use cache` functions in the server-reference manifest, Turbopack
5-
// (Next.js 16.3) does not. `TEST_BUNDLER` marks the webpack variant's production run (set in
6-
// `test:assert-webpack`).
7-
const isWebpackBuild = process.env.TEST_BUNDLER === 'webpack' || process.env.TEST_ENV === 'development-webpack';
8-
const expectedRouteHandlerFilePath = isWebpackBuild ? 'app/api/use-cache/route.ts' : undefined;
9-
104
test('Should create cache spans around `use cache` functions', async ({ request }) => {
115
// A fresh id makes the first request a guaranteed cache miss (the id is part of the cache key)
126
// even when the test is retried against the same server.
@@ -63,7 +57,7 @@ test('Should create cache spans around `use cache` functions', async ({ request
6357
}),
6458
});
6559

66-
expect(putSpan!.data?.['code.file.path']).toBe(expectedRouteHandlerFilePath);
60+
expect(putSpan!.data?.['code.file.path']).toBe('app/api/use-cache/route.ts');
6761

6862
const hitGetSpan = hitTx.spans?.find(span => span.op === 'cache.get');
6963
expect(hitGetSpan).toBeDefined();

‎dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/useCacheSpans.spec.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import { expect, test } from '@playwright/test';
22
import { collectStreamedSpans, getSpanOp } from '@sentry-internal/test-utils';
33
import { findCacheSpan } from './cacheOriginLinks-utils';
44

5-
// Webpack lists route handler `use cache` functions in the server-reference manifest, Turbopack
6-
// (Next.js 16.3) does not. `TEST_BUNDLER` marks the webpack variant's production run (set in
7-
// `test:assert-webpack`).
8-
const isWebpackBuild = process.env.TEST_BUNDLER === 'webpack' || process.env.TEST_ENV === 'development-webpack';
9-
const expectedRouteHandlerFilePath = isWebpackBuild ? 'app/api/use-cache/route.ts' : undefined;
10-
115
test('uses low-cardinality names for `use cache` spans', async ({ request }) => {
126
// A fresh id makes the request a guaranteed cache miss (the id is part of the cache key), so the
137
// trace contains both a `cache.get` and a `cache.put` span.
@@ -37,7 +31,7 @@ test('uses low-cardinality names for `use cache` spans', async ({ request }) =>
3731
expect(putSpan!.name).toBe('cache.put');
3832
expect(putSpan!.attributes['cache.key']?.value).toEqual(cacheKeyDigest);
3933

40-
expect(putSpan!.attributes['code.file.path']?.value).toBe(expectedRouteHandlerFilePath);
34+
expect(putSpan!.attributes['code.file.path']?.value).toBe('app/api/use-cache/route.ts');
4135
});
4236

4337
test('sets the source file of the cached component on `cache.put` spans', async ({ request }) => {

0 commit comments

Comments
 (0)