Skip to content

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

📚 Description

seems we weren't properly running all tests in matrix with the appropriate conditions.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

This pull request introduces a centralised test matrix module (test/matrix.ts) that consolidates environment-based configuration flags and utilities. The changes refactor approximately 15+ test and fixture files to import environment flags (isWebpack, isDev, isBuilt, isTestingAppManifest, asyncContext, typescriptBundlerResolution, isRenderingJson) from this new matrix module instead of computing them locally. Fixture config files now export through a withMatrix wrapper function instead of defineNuxtConfig, which injects builder selection and experimental settings. Local builder selection logic and several config fields (compatibilityDate, builder declarations) are removed from individual files in favour of centralised handling. Test skip conditions and guard clauses are updated to use the imported boolean flags rather than runtime environment checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Justification: The refactoring spans many files (~15+) but follows a consistent, homogeneous pattern—removing local flag definitions, adding matrix imports, and updating config wrappers. However, the introduction of the new test/matrix.ts module with its withMatrix utility and flag logic requires careful verification of the centralised logic. Additionally, changes to fixture config exports and test conditions must be validated for correct behaviour. The repetitive nature of updates across files reduces overall complexity, but the breadth and centralisation strategy warrant moderate review effort.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary change in this pull request, namely refactoring the test suite to leverage shared matrix utilities.
Description Check ✅ Passed The pull request description explains that tests were not executed under the correct matrix conditions and motivates the refactor to common matrix utilities, which aligns with the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/matrix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3b0af0 and 4dc68f1.

📒 Files selected for processing (1)
  • test/basic.test.ts (27 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • test/basic.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for core functionality using vitest

Files:

  • test/basic.test.ts
🧬 Code graph analysis (1)
test/basic.test.ts (1)
test/matrix.ts (5)
  • isDev (6-6)
  • isWebpack (4-4)
  • builder (10-10)
  • isRenderingJson (17-17)
  • asyncContext (14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: code
🔇 Additional comments (4)
test/basic.test.ts (4)

7-13: LGTM! Clean import refactoring.

The imports are well-organised:

  • Type import for NuxtIslandResponse improves type safety for island response handling
  • Matrix utility imports centralise test environment configuration
  • This refactoring eliminates scattered environment checks throughout the file

15-33: Correct usage of centralised isDev flag.

The setup configuration correctly uses the imported boolean flag instead of computing it locally. This ensures consistent behaviour across the test suite and simplifies the setup logic.


137-137: Excellent use of declarative test conditions.

The test conditions consistently use the imported boolean flags (isDev, isWebpack, isRenderingJson, asyncContext, builder) from the matrix module. This makes the test suite more maintainable and the conditions more readable.

Key improvements:

  • .runIf() and .skipIf() conditions are clear and declarative
  • Ternary expressions for environment-specific assertions are straightforward
  • Complex conditions (e.g., !isDev && builder !== 'rspack') are easier to understand with named flags
  • Consistent pattern throughout the file reduces cognitive load

Also applies to: 151-151, 252-252, 624-624, 1153-1153, 1202-1203, 1453-1453, 1821-1821, 1830-1830, 2046-2046, 2057-2057, 2093-2093, 2123-2123, 2221-2221, 2520-2520, 2551-2551, 2561-2561, 2626-2626, 2632-2632, 2699-2699, 3090-3090


2049-2054: Environment-specific test logic is correctly implemented.

The conditional logic within test bodies appropriately handles differences between development and production environments:

  • Filtering of dev-mode-specific resources (HMR links, source maps)
  • Conditional assertions based on isRenderingJson for payload format
  • Normalisation of test expectations across different build configurations

This approach ensures tests remain accurate whilst accounting for legitimate environment-based variations.

Also applies to: 2263-2265, 2288-2290, 2349-2351, 2377-2383, 2426-2436, 2439-2439, 2449-2468


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@33483

nuxt

npm i https://pkg.pr.new/nuxt@33483

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@33483

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@33483

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@33483

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@33483

commit: 4dc68f1

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
test/e2e/spa-preloader-body.test.ts (1)

27-34: Verify builder inheritance from matrix configuration.

Similar to the previous test file, the builder field has been removed. Ensure that e2e tests correctly inherit the matrix-provided builder configuration.

test/e2e/runtime-compiler.test.ts (1)

25-28: Verify builder configuration inheritance.

The builder field has been removed from nuxtConfig. Confirm that the test correctly inherits the matrix-provided builder configuration, especially given the dev/prod mode variations tested here.

test/e2e/suspense.test.ts (1)

24-27: Verify builder inheritance for suspense tests.

Similar to other e2e tests, the builder field has been removed. Ensure that the matrix-provided builder configuration is correctly applied.

🧹 Nitpick comments (2)
test/matrix.ts (2)

9-10: Consider documenting the vite-env-api special case.

The builder selection logic maps 'vite-env-api' to 'vite', which is non-obvious. A brief comment explaining why this mapping exists would improve maintainability.

Apply this diff to add clarifying documentation:

+// vite-env-api uses the vite builder with experimental environment API enabled
 const _builder = process.env.TEST_BUILDER as 'webpack' | 'rspack' | 'vite' | 'vite-env-api'
 export const builder = _builder === 'vite-env-api' ? 'vite' : (_builder ?? 'vite')

4-4: Document TEST_BUILDER valid values
Valid values are webpack, rspack, vite and vite-env-api. isWebpack correctly targets the first two and builder handles the others. Add a JSDoc comment or update your docs to list all four values for clarity.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27cf85b and ff3910d.

📒 Files selected for processing (15)
  • test/basic.test.ts (27 hunks)
  • test/e2e/hmr.test.ts (2 hunks)
  • test/e2e/runtime-compiler.test.ts (1 hunks)
  • test/e2e/spa-preloader-body.test.ts (1 hunks)
  • test/e2e/spa-preloader-within.test.ts (1 hunks)
  • test/e2e/suspense.test.ts (1 hunks)
  • test/fixtures/basic-types/nuxt.config.ts (2 hunks)
  • test/fixtures/basic/nuxt.config.ts (1 hunks)
  • test/fixtures/hmr/nuxt.config.ts (1 hunks)
  • test/fixtures/runtime-compiler/nuxt.config.ts (1 hunks)
  • test/fixtures/spa-loader/nuxt.config.ts (1 hunks)
  • test/fixtures/suspense/nuxt.config.ts (1 hunks)
  • test/matrix.ts (1 hunks)
  • test/nuxt/composables.test.ts (2 hunks)
  • test/utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • test/e2e/hmr.test.ts
  • test/e2e/runtime-compiler.test.ts
  • test/e2e/spa-preloader-body.test.ts
  • test/fixtures/suspense/nuxt.config.ts
  • test/fixtures/runtime-compiler/nuxt.config.ts
  • test/fixtures/basic-types/nuxt.config.ts
  • test/matrix.ts
  • test/nuxt/composables.test.ts
  • test/fixtures/basic/nuxt.config.ts
  • test/fixtures/hmr/nuxt.config.ts
  • test/e2e/spa-preloader-within.test.ts
  • test/fixtures/spa-loader/nuxt.config.ts
  • test/basic.test.ts
  • test/utils.ts
  • test/e2e/suspense.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for core functionality using vitest

Files:

  • test/e2e/hmr.test.ts
  • test/e2e/runtime-compiler.test.ts
  • test/e2e/spa-preloader-body.test.ts
  • test/nuxt/composables.test.ts
  • test/e2e/spa-preloader-within.test.ts
  • test/basic.test.ts
  • test/e2e/suspense.test.ts
**/e2e/**/*.{ts,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write end-to-end tests using Playwright and @nuxt/test-utils

Files:

  • test/e2e/hmr.test.ts
  • test/e2e/runtime-compiler.test.ts
  • test/e2e/spa-preloader-body.test.ts
  • test/e2e/spa-preloader-within.test.ts
  • test/e2e/suspense.test.ts
🧠 Learnings (1)
📚 Learning: 2025-07-18T16:46:07.446Z
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/e2e/**/*.{ts,js} : Write end-to-end tests using Playwright and `nuxt/test-utils`

Applied to files:

  • test/e2e/spa-preloader-body.test.ts
  • test/e2e/spa-preloader-within.test.ts
🧬 Code graph analysis (10)
test/e2e/hmr.test.ts (1)
test/matrix.ts (1)
  • isBuilt (7-7)
test/fixtures/suspense/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/fixtures/runtime-compiler/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/fixtures/basic-types/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/matrix.ts (1)
test/basic.test.ts (1)
  • isDev (23-30)
test/nuxt/composables.test.ts (1)
test/matrix.ts (1)
  • isTestingAppManifest (12-12)
test/fixtures/basic/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/fixtures/hmr/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/fixtures/spa-loader/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
test/basic.test.ts (2)
packages/nuxt/src/app/components/nuxt-island.ts (1)
  • setup (81-353)
test/matrix.ts (4)
  • isDev (6-6)
  • isWebpack (4-4)
  • isRenderingJson (17-17)
  • asyncContext (14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: test-fixtures (windows-latest, built, rspack, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, rspack, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, js, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, lts/-1)
  • GitHub Check: release-pkg-pr-new
  • GitHub Check: test-benchmark
  • GitHub Check: test-size
  • GitHub Check: typecheck (ubuntu-latest, bundler)
  • GitHub Check: typecheck (windows-latest, bundler)
  • GitHub Check: code
🔇 Additional comments (26)
test/matrix.ts (2)

1-2: LGTM!

The imports are appropriate: defu for deep merging configuration objects and NuxtConfig for type safety.


19-33: LGTM! The withMatrix function correctly centralises test configuration.

The function appropriately merges user-provided config with matrix-derived defaults using defu. The defaults include:

  • Builder selection
  • TypeScript bundler resolution
  • Experimental flags (asyncContext, appManifest, renderJsonPayloads, viteEnvironmentApi)
  • Compatibility date

This centralisation eliminates duplication across test fixtures and ensures consistent test matrix behaviour.

test/e2e/spa-preloader-within.test.ts (2)

7-7: LGTM! The isDev import correctly replaces local environment detection.

The import from ../matrix centralises the environment flag, improving consistency across the test suite.


28-34: Verify builder inheritance from matrix configuration
The builder field was removed from nuxtConfig. Confirm the e2e setup (e.g. withMatrix in test/e2e/test-utils.ts) correctly applies the matrix-provided builder. No builder or withMatrix references were found—manual verification required.

test/e2e/spa-preloader-body.test.ts (1)

7-7: LGTM! Consistent migration to centralised matrix flags.

The import aligns with the test suite-wide refactoring to use matrix-provided environment flags.

test/e2e/hmr.test.ts (3)

7-7: LGTM! The imports correctly replace local environment checks.

Using isBuilt and isWebpack from the matrix module eliminates duplicate environment detection logic.


24-24: LGTM! The skip condition correctly uses the matrix flag.

The change from process.env.TEST_ENV === 'built' to isBuilt improves readability whilst maintaining the same logic. Note that isBuilt is defined as !isDev in test/matrix.ts.


18-21: Verify builder inheritance for this dev-mode test.

The builder field has been removed from nuxtConfig whilst dev: true is explicitly set. Confirm that the test correctly uses the matrix-provided builder in dev mode.

test/utils.ts (1)

9-9: LGTM! The import centralises the isRenderingJson flag.

Moving isRenderingJson from a local export to the matrix module reduces duplication and ensures consistency across the test suite.

test/e2e/runtime-compiler.test.ts (1)

5-5: LGTM! Consistent adoption of matrix-based environment flags.

The import aligns with the centralised matrix approach used throughout the test suite.

test/e2e/suspense.test.ts (1)

5-5: LGTM! Consistent migration to centralised environment flags.

The import follows the established pattern across the test suite refactoring.

test/fixtures/spa-loader/nuxt.config.ts (1)

1-13: LGTM! Correct adoption of the withMatrix wrapper.

The fixture correctly:

  • Imports and uses withMatrix instead of defineNuxtConfig
  • Removes compatibilityDate (now provided by matrix defaults)
  • Preserves fixture-specific config like spaLoadingTemplate and route rules
  • The experimental spaLoadingTemplateLocation setting correctly overrides the matrix defaults via defu's merge behaviour

This aligns the fixture with the centralised matrix-based configuration approach.

test/fixtures/suspense/nuxt.config.ts (1)

1-3: LGTM!

The refactoring correctly replaces defineNuxtConfig with withMatrix and delegates all configuration to the centralised matrix module. The empty configuration object indicates this fixture will use the matrix defaults for builder, experimental flags, and compatibility date.

test/nuxt/composables.test.ts (2)

26-26: LGTM!

The import correctly brings in the isTestingAppManifest flag from the centralised matrix module, aligning with the PR's goal of standardising environment-driven test flags.


340-340: LGTM!

The skip condition correctly uses the boolean isTestingAppManifest flag instead of direct environment variable checking. The logic is semantically equivalent to the previous process.env.TEST_MANIFEST === 'manifest-off' check.

test/fixtures/runtime-compiler/nuxt.config.ts (1)

1-11: LGTM!

The refactoring correctly adopts withMatrix whilst preserving fixture-specific configuration (vue.runtimeCompiler and experimental.externalVue). The defu merge in withMatrix ensures these overrides take precedence over matrix defaults.

test/fixtures/hmr/nuxt.config.ts (1)

1-7: LGTM!

The refactoring correctly transitions to the withMatrix wrapper whilst retaining the fixture-specific experimental.inlineRouteRules configuration. Matrix defaults will provide the previously environment-driven settings.

test/fixtures/basic/nuxt.config.ts (1)

6-8: LGTM!

The refactoring correctly adopts withMatrix for the basic fixture. The extensive fixture-specific configuration is preserved, and matrix defaults (builder, experimental flags, compatibilityDate) will be merged appropriately via defu.

test/fixtures/basic-types/nuxt.config.ts (2)

4-4: LGTM!

The import correctly brings in both withMatrix and typescriptBundlerResolution from the centralised matrix module, ensuring consistent configuration across the test suite.


6-6: LGTM!

The refactoring correctly adopts withMatrix and uses the centralised typescriptBundlerResolution value at line 88. This ensures consistency with the matrix module's TypeScript bundler resolution setting.

Also applies to: 88-88

test/basic.test.ts (6)

7-7: LGTM!

The additions to imports are appropriate: createPage is used in test setup, and NuxtIslandResponse provides proper typing for island response objects throughout the test suite.

Also applies to: 10-10


12-13: LGTM!

The imports correctly bring in matrix flags (asyncContext, isDev, isRenderingJson, isTestingAppManifest, isWebpack) and test utilities, aligning with the centralised matrix approach for environment-driven test conditions.


17-17: LGTM!

The transition from function calls to boolean flag usage (isDev) is correct. The test setup at line 17 and the conditional at line 27 properly use the centralised boolean flag from the matrix module.

Also applies to: 27-27


137-137: LGTM!

All conditional expressions and test guards correctly use isDev as a boolean flag rather than a function call, maintaining consistency with the matrix module approach throughout the test suite.

Also applies to: 252-252, 624-624, 1153-1153, 1202-1202, 1452-1452


1820-1820: LGTM!

The describe.runIf, describe.skipIf, and it.skipIf test guards correctly use the boolean isDev and isWebpack flags from the matrix module for conditional test execution.

Also applies to: 1829-1829, 2092-2092, 2122-2122, 2220-2220


2048-2053: LGTM!

All remaining usages of isDev, isWebpack, isWindows, isRenderingJson, and asyncContext correctly use the boolean flags from the matrix module. The refactoring maintains semantic equivalence whilst centralising environment flag management.

Also applies to: 2056-2056, 2519-2519, 2550-2550, 2560-2560, 2625-2625, 2631-2631, 2698-2698, 3089-3089

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 15, 2025

CodSpeed Performance Report

Merging #33483 will not alter performance

Comparing test/matrix (4dc68f1) with main (285eac3)

Summary

✅ 10 untouched

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/fixtures/basic/nuxt.config.ts (1)

36-37: Consider using exact equality for builder comparison.

The current includes() check works correctly for the known builder values ('vite', 'webpack', 'rspack', 'vite-env-api'), but using exact equality would be more precise and maintainable.

Apply this diff for more precise matching:

-      // Virtual CSS modules only work with Vite, not with webpack/rspack
-      if (typeof nuxt.options.builder === 'string' && (nuxt.options.builder.includes('webpack') || nuxt.options.builder.includes('rspack'))) { return }
+      // Virtual CSS modules only work with Vite, not with webpack/rspack
+      if (nuxt.options.builder === 'webpack' || nuxt.options.builder === 'rspack') { return }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff3910d and f0c3fc2.

📒 Files selected for processing (1)
  • test/fixtures/basic/nuxt.config.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • test/fixtures/basic/nuxt.config.ts
🧬 Code graph analysis (1)
test/fixtures/basic/nuxt.config.ts (1)
test/matrix.ts (1)
  • withMatrix (19-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build
  • GitHub Check: codeql (javascript-typescript)
  • GitHub Check: code
🔇 Additional comments (1)
test/fixtures/basic/nuxt.config.ts (1)

6-8: LGTM! Correct use of matrix wrapper.

The changes correctly refactor this fixture to use the centralised matrix configuration. The withMatrix wrapper now provides builder selection, compatibility date, and experimental flags, eliminating the need for local environment-based configuration.

@danielroe danielroe merged commit 7bcc4ca into main Oct 16, 2025
47 checks passed
@danielroe danielroe deleted the test/matrix branch October 16, 2025 07:04
@github-actions github-actions bot mentioned this pull request Oct 16, 2025
@github-actions github-actions bot mentioned this pull request Oct 23, 2025
@github-actions github-actions bot mentioned this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants