feat(nuxt): Conditionally use plugins based on Nitro version (v2/v3)#19955
feat(nuxt): Conditionally use plugins based on Nitro version (v2/v3)#19955
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Other
Bug Fixes 🐛Cloudflare
Core
Deps
Other
Internal Changes 🔧Deps Dev
Nuxt
Other
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Tests use conditionals instead of separate test paths
- Replaced per-test
if (isDevMode)branching with a singleexpectedEnvironmentconstant so each assertion is unconditional and clearer.
- Replaced per-test
Or push these changes by commenting:
@cursor push 83eb248526
Preview (83eb248526)
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/environment.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/environment.test.ts
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/environment.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/environment.test.ts
@@ -3,6 +3,8 @@
import { isDevMode } from './isDevMode';
test.describe('environment detection', async () => {
+ const expectedEnvironment = isDevMode ? 'development' : 'production';
+
test('sets correct environment for client-side errors', async ({ page }) => {
const errorPromise = waitForError('nuxt-5', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from nuxt-5 E2E test app';
@@ -14,11 +16,7 @@
const error = await errorPromise;
- if (isDevMode) {
- expect(error.environment).toBe('development');
- } else {
- expect(error.environment).toBe('production');
- }
+ expect(error.environment).toBe(expectedEnvironment);
});
test('sets correct environment for client-side transactions', async ({ page }) => {
@@ -30,11 +28,7 @@
const transaction = await transactionPromise;
- if (isDevMode) {
- expect(transaction.environment).toBe('development');
- } else {
- expect(transaction.environment).toBe('production');
- }
+ expect(transaction.environment).toBe(expectedEnvironment);
});
test('sets correct environment for server-side errors', async ({ page }) => {
@@ -49,11 +43,7 @@
expect(error.transaction).toBe('GET /api/server-error');
- if (isDevMode) {
- expect(error.environment).toBe('development');
- } else {
- expect(error.environment).toBe('production');
- }
+ expect(error.environment).toBe(expectedEnvironment);
});
test('sets correct environment for server-side transactions', async ({ page }) => {
@@ -68,10 +58,6 @@
expect(transaction.contexts.trace.op).toBe('http.server');
- if (isDevMode) {
- expect(transaction.environment).toBe('development');
- } else {
- expect(transaction.environment).toBe('production');
- }
+ expect(transaction.environment).toBe(expectedEnvironment);
});
});This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
| expect(error.environment).toBe('development'); | ||
| } else { | ||
| expect(error.environment).toBe('production'); | ||
| } |
There was a problem hiding this comment.
Tests use conditionals instead of separate test paths
Low Severity
Multiple tests in environment.test.ts use if (isDevMode) / else conditionals to assert different expected values. The review rules specify flagging conditionals inside a single test and recommending splitting the test for different paths.
Additional Locations (2)
Triggered by project rule: PR Review Guidelines for Cursor Bot
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|



Conditionally uses plugins for storage and database based on the Nitro version.
Also adds a Nuxt 5 E2E test app, which skips the middleware tests (and some others) for now to be implemented in another PR. Or regarding Pinia, we need to wait until they support that.
The E2E test app is mostly the same as the Nuxt 4 app (just migrated to Nitro v3)
#importdefineHandlerinstead ofdefineEventHandlerevent.res?.headers.get()instead ofgetHeader()Closes #19275