fix(test): unblock nuxt-env setupNuxt hang via session fixture#91
Open
imrim12 wants to merge 1 commit into
Open
fix(test): unblock nuxt-env setupNuxt hang via session fixture#91imrim12 wants to merge 1 commit into
imrim12 wants to merge 1 commit into
Conversation
The @thecodeorigin/auth module ships a global route middleware that redirects unauthenticated users to an external sign-in URL. During `setupNuxt()` the app's boot navigation (`/` -> `/dashboard`) triggered that external redirect, which never resolves in the @nuxt/test-utils runtime env and hung the beforeAll hook for the full timeout. Every nuxt-env test file (cookie-consent, sidebar-search, notifications-bell, support-modal) timed out at 120s. Register a logged-in `/api/_auth/session` fixture for the nuxt project so the auth boot plugin resolves to an authenticated admin and the middleware lets navigation through. The app now boots in ~14s. Guarded so files that opt into `happy-dom` (no test-utils runtime app) skip registration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI has been red across many commits. Two failures, in sequence:
teardownTimeoutplaced inside a per-projecttestconfig (only valid at the top-leveltestconfig). (Already addressed in635775a.)cookie-consent,sidebar-search,notifications-bell,support-modal) hung in thebeforeAllsetupNuxt()hook and timed out at 120s.Root cause
Regression introduced by
c54f2f8(better-auth →@thecodeorigin/authmodule swap), exactly when CI went red.setupNuxt()boots the real Nuxt app and runs all plugins + initial route resolution. The module's global middlewareauth.global.jsredirects unauthenticated users to an external sign-in URL. With no session in the test env, the boot navigation/→/dashboardtriggerednavigateTo(signIn, { external: true }), which never resolves under@nuxt/test-utils→ the hook hung for the full timeout. Verified: even a no-op nuxt-env test and an isolated single file hang past 600s, while the build itself completes.Fix
Register a logged-in
/api/_auth/sessionfixture as a setup file for the nuxt vitest project. The auth boot plugin resolves to an authenticated admin, so the middleware lets navigation through and the app boots in ~14s. Guarded to skip files that opt into// @vitest-environment happy-dom(no test-utils runtime app).Verification (local)
pnpm test→ 24 files / 126 tests passed (was 4 hanging + 5 skipped)pnpm lint→ cleanpnpm typecheck→ clean🤖 Generated with Claude Code