Skip to content

fix(tests): hoist vi.mock to top level in vitest setup - #1571

Open
Himarghya wants to merge 1 commit into
freeCodeCamp:mainfrom
Himarghya:fix/vitest-mock-hoisting
Open

Himarghya wants to merge 1 commit into
freeCodeCamp:mainfrom
Himarghya:fix/vitest-mock-hoisting

Conversation

@Himarghya

Copy link
Copy Markdown

Checklist:

Description

In vitest.setup.ts, the vi.mock('astro:content', ...) call was nested inside a beforeAll hook. Vitest hoists mock calls automatically, which triggered the following deprecation warning during test execution:

Warning: A vi.mock("astro:content") call in "vitest.setup.ts" is not at the top level of the module. Although it appears nested, it will be hoisted and executed before any tests run. Move it to the top level to reflect its actual execution order.

This PR moves the mock call to module scope (top-level) and removes the unused beforeAll import to follow Vitest best practices and eliminate the warning.

Verification

  • Tested locally with pnpm test (all 129 tests passed across 7 test files with zero warnings)
  • Checked formatting and linting with pnpm format and pnpm lint
  • Verified static build with pnpm build

@Himarghya
Himarghya requested a review from a team as a code owner October 7, 2026 10:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant