test(nextjs): Add webpack variant for span-streaming e2e app - #22704
Conversation
Adds a webpack build variant to the nextjs-16-streaming e2e app so the webpack + span-streaming combination has coverage. Adds a reusable `collectStreamedSpans` test-util that accumulates streamed spans across envelopes, and uses it in the server-component tests (streamed child spans can arrive in a different envelope than their segment root). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
good catch, thx! |
| } | ||
|
|
||
| test('Sends a streamed span for a request to app router with URL', async ({ page }) => { | ||
| test.skip(isDevMode, 'Turbopack intermittently returns 404 for nested dynamic routes in dev mode'); |
There was a problem hiding this comment.
Bug: The isDevMode check is too broad, causing tests to be skipped for the new development-webpack environment, which prevents the intended test coverage from being added.
Severity: MEDIUM
Suggested Fix
Create a more specific isTurbopackDevMode constant in nextjs-16-streaming/utils/isDevMode.ts that uses strict equality: process.env.TEST_ENV === 'development'. Update the test.skip() calls in server-components.test.ts to use this new constant. This ensures tests are only skipped for Turbopack and not for the new webpack dev environment.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/nextjs-16-streaming/tests/server-components.test.ts#L15
Potential issue: The `isDevMode` constant in `nextjs-16-streaming` is defined using
`process.env.TEST_ENV.includes('development')`. The pull request introduces a new test
environment, `development-webpack`, to add test coverage for webpack. However, because
`'development-webpack'` includes the substring `'development'`, the `isDevMode` check
evaluates to `true`. This causes all server-component tests that use
`test.skip(isDevMode, ...)` to be skipped when running in the new webpack dev mode. As a
result, the intended webpack test coverage is not added, leaving these components
untested in that environment.
Also affects:
dev-packages/e2e-tests/test-applications/nextjs-16-streaming/tests/server-components.test.ts:32dev-packages/e2e-tests/test-applications/nextjs-16-streaming/tests/server-components.test.ts:53
Did we get this right? 👍 / 👎 to inform future reviews.
|
i think we should probably use this function whenever we want to assert on more than one span in a trace. Everything else has potential to flake. Will keep this in mind when migrating more tests to streaming and write the migration skill accordingly |
Discovered in #22674 that this was not running on webpack so here we go.
I added a reusable helper to aggregate streamed spans for e2e tests