Skip to content

Commit a17aaab

Browse files
chargomeclaude
andcommitted
test(nextjs): Skip the ISR meta tag assertions in every dev variant
The turbopack dev variant runs with TEST_ENV=dev-turbopack, which the development check did not match, so the tags-absent assertions ran against a dev render where the tags are fresh and kept. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 4f12e9e commit a17aaab

4 files changed

Lines changed: 46 additions & 20 deletions

File tree

‎dev-packages/e2e-tests/test-applications/nextjs-15/tests/isr-routes.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { expect, test } from '@playwright/test';
22
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
33

4+
const isProductionBuild = process.env.TEST_ENV === 'production' || process.env.TEST_ENV === 'prod-turbopack';
5+
46
test('does not carry trace meta tags on an ISR dynamic route', async ({ page }) => {
57
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
6-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
8+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
79

810
// Navigate to ISR page
911
await page.goto('/isr-test/laptop');
@@ -18,7 +20,7 @@ test('does not carry trace meta tags on an ISR dynamic route', async ({ page })
1820

1921
test('does not carry trace meta tags on an ISR static route', async ({ page }) => {
2022
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
21-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
23+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
2224

2325
// Navigate to ISR static page
2426
await page.goto('/isr-test/static');
@@ -33,7 +35,7 @@ test('does not carry trace meta tags on an ISR static route', async ({ page }) =
3335

3436
test('does not carry trace meta tags for different ISR dynamic route values', async ({ page }) => {
3537
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
36-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
38+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
3739

3840
// Test with 'phone' (one of the pre-generated static params)
3941
await page.goto('/isr-test/phone');

‎dev-packages/e2e-tests/test-applications/nextjs-16-cf-workers/tests/isr-routes.test.ts‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
import { expect, test } from '@playwright/test';
22
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
33

4-
test('should remove sentry-trace and baggage meta tags on ISR dynamic route page load', async ({ page }) => {
4+
const isProductionBuild = process.env.TEST_ENV === 'production' || process.env.TEST_ENV === 'prod-turbopack';
5+
6+
test('does not carry trace meta tags on an ISR dynamic route', async ({ page }) => {
7+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
8+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
9+
510
// Navigate to ISR page
611
await page.goto('/isr-test/laptop');
712

813
// Wait for page to be fully loaded
914
await expect(page.locator('#isr-product-id')).toHaveText('laptop');
1015

11-
// Check that sentry-trace and baggage meta tags are removed for ISR pages
16+
// The shell was prerendered, and a prerender writes no trace tags
1217
await expect(page.locator('meta[name="sentry-trace"]')).toHaveCount(0);
1318
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
1419
});
1520

16-
test('should remove sentry-trace and baggage meta tags on ISR static route', async ({ page }) => {
21+
test('does not carry trace meta tags on an ISR static route', async ({ page }) => {
22+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
23+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
24+
1725
// Navigate to ISR static page
1826
await page.goto('/isr-test/static');
1927

2028
// Wait for page to be fully loaded
2129
await expect(page.locator('#isr-static-marker')).toHaveText('static-isr');
2230

23-
// Check that sentry-trace and baggage meta tags are removed for ISR pages
31+
// The shell was prerendered, and a prerender writes no trace tags
2432
await expect(page.locator('meta[name="sentry-trace"]')).toHaveCount(0);
2533
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
2634
});
2735

28-
test('should remove meta tags for different ISR dynamic route values', async ({ page }) => {
36+
test('does not carry trace meta tags for different ISR dynamic route values', async ({ page }) => {
37+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
38+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
39+
2940
// Test with 'phone' (one of the pre-generated static params)
3041
await page.goto('/isr-test/phone');
3142
await expect(page.locator('#isr-product-id')).toHaveText('phone');
@@ -44,7 +55,7 @@ test('should remove meta tags for different ISR dynamic route values', async ({
4455
test('should create unique traces for ISR pages on each visit', async ({ page }) => {
4556
const traceIds: string[] = [];
4657

47-
// Load the same ISR page 5 times to ensure cached HTML meta tags are consistently removed
58+
// Load the same ISR page 5 times: the cached HTML carries no trace tag, so every visit starts its own trace
4859
for (let i = 0; i < 5; i++) {
4960
const spanPromise = waitForStreamedSpan('nextjs-16-cf-workers', span => {
5061
return span.name === '/isr-test/:product' && getSpanOp(span) === 'pageload' && span.is_segment;
@@ -64,7 +75,7 @@ test('should create unique traces for ISR pages on each visit', async ({ page })
6475
traceIds.push(traceId!);
6576
}
6677

67-
// Verify all 5 page loads have unique trace IDs (no reuse of cached/stale meta tags)
78+
// Verify all 5 page loads have unique trace IDs (no trace replayed from the cached HTML)
6879
const uniqueTraceIds = new Set(traceIds);
6980
expect(uniqueTraceIds.size).toBe(5);
7081
});

‎dev-packages/e2e-tests/test-applications/nextjs-16-static/tests/isr-routes.test.ts‎

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

4-
test('should remove sentry-trace and baggage meta tags on ISR dynamic route page load', async ({ page }) => {
4+
const isProductionBuild = process.env.TEST_ENV === 'production' || process.env.TEST_ENV === 'prod-turbopack';
5+
6+
test('does not carry trace meta tags on an ISR dynamic route', async ({ page }) => {
7+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
8+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
9+
510
// Navigate to ISR page
611
await page.goto('/isr-test/laptop');
712

813
// Wait for page to be fully loaded
914
await expect(page.locator('#isr-product-id')).toHaveText('laptop');
1015

11-
// Check that sentry-trace and baggage meta tags are removed for ISR pages
16+
// The shell was prerendered, and a prerender writes no trace tags
1217
await expect(page.locator('meta[name="sentry-trace"]')).toHaveCount(0);
1318
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
1419
});
1520

16-
test('should remove sentry-trace and baggage meta tags on ISR static route', async ({ page }) => {
21+
test('does not carry trace meta tags on an ISR static route', async ({ page }) => {
22+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
23+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
24+
1725
// Navigate to ISR static page
1826
await page.goto('/isr-test/static');
1927

2028
// Wait for page to be fully loaded
2129
await expect(page.locator('#isr-static-marker')).toHaveText('static-isr');
2230

23-
// Check that sentry-trace and baggage meta tags are removed for ISR pages
31+
// The shell was prerendered, and a prerender writes no trace tags
2432
await expect(page.locator('meta[name="sentry-trace"]')).toHaveCount(0);
2533
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
2634
});
2735

28-
test('should remove meta tags for different ISR dynamic route values', async ({ page }) => {
36+
test('does not carry trace meta tags for different ISR dynamic route values', async ({ page }) => {
37+
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
38+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
39+
2940
// Test with 'phone' (one of the pre-generated static params)
3041
await page.goto('/isr-test/phone');
3142
await expect(page.locator('#isr-product-id')).toHaveText('phone');
@@ -44,7 +55,7 @@ test('should remove meta tags for different ISR dynamic route values', async ({
4455
test('should create unique transactions for ISR pages on each visit', async ({ page }) => {
4556
const traceIds: string[] = [];
4657

47-
// Load the same ISR page 5 times to ensure cached HTML meta tags are consistently removed
58+
// Load the same ISR page 5 times: the cached HTML carries no trace tag, so every visit starts its own trace
4859
for (let i = 0; i < 5; i++) {
4960
const transactionPromise = waitForTransaction('nextjs-16-static', async transactionEvent => {
5061
return !!(
@@ -66,7 +77,7 @@ test('should create unique transactions for ISR pages on each visit', async ({ p
6677
traceIds.push(traceId!);
6778
}
6879

69-
// Verify all 5 page loads have unique trace IDs (no reuse of cached/stale meta tags)
80+
// Verify all 5 page loads have unique trace IDs (no trace replayed from the cached HTML)
7081
const uniqueTraceIds = new Set(traceIds);
7182
expect(uniqueTraceIds.size).toBe(5);
7283
});

‎dev-packages/e2e-tests/test-applications/nextjs-16/tests/isr-routes.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { expect, test } from '@playwright/test';
22
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
33

4+
const isProductionBuild = process.env.TEST_ENV === 'production' || process.env.TEST_ENV === 'prod-turbopack';
5+
46
test('does not carry trace meta tags on an ISR dynamic route', async ({ page }) => {
57
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
6-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
8+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
79

810
// Navigate to ISR page
911
await page.goto('/isr-test/laptop');
@@ -18,7 +20,7 @@ test('does not carry trace meta tags on an ISR dynamic route', async ({ page })
1820

1921
test('does not carry trace meta tags on an ISR static route', async ({ page }) => {
2022
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
21-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
23+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
2224

2325
// Navigate to ISR static page
2426
await page.goto('/isr-test/static');
@@ -33,7 +35,7 @@ test('does not carry trace meta tags on an ISR static route', async ({ page }) =
3335

3436
test('does not carry trace meta tags for different ISR dynamic route values', async ({ page }) => {
3537
// The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
36-
test.skip(!!process.env.TEST_ENV?.includes('development'), 'ISR pages are only prerendered in production builds');
38+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
3739

3840
// Test with 'phone' (one of the pre-generated static params)
3941
await page.goto('/isr-test/phone');

0 commit comments

Comments
 (0)