Skip to content

fix(e2e): restore test context before running setup hooks - #1855

Merged
danielroe merged 1 commit into
mainfrom
fix/multiple-setup-describe
Oct 14, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/multiple-setup-describe

Conversation

@danielroe

@danielroe danielroe commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

I was looping over two fixtures in one test file and calling setup() in each describe:

for (const [name, rootDir] of Object.entries({ a: fixtureA, b: fixtureB })) {
  describe(name, async () => {
    await setup({ build: true, server: false, rootDir })
    it('builds', () => { /* read build output */ })
  })
}

in this case the second suite fails with:

Error: No context is available. (Forgot calling setup or createContext?)
 ❯ useTestContext
 ❯ loadFixture
 ❯ beforeAll

we're actually already working around this behaviour in our own test suites here

@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/test-utils/@nuxt/test-utils@1855
npm i https://pkg.pr.new/nuxt/test-utils/vitest-environment-nuxt@1855

commit: a03e512

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17ea0cc6-dd8d-418d-883f-263f09cc25f8
📥 Commits

Reviewing files that changed from the base of the PR and between c5294da and a03e512.

📒 Files selected for processing: 3
  • examples/app-vitest/test/e2e/dev-concurrent.spec.ts
  • examples/module/test/multiple-setup.test.ts
  • src/e2e/setup/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

beforeAll now sets the test context before running setup actions. The concurrent-server test registers server.beforeAll directly. A new test checks rendered page content for the basic and dot-config fixtures.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a03e5

The setup establishes fixture context before setup runs, and the shown test configuration runs the server setup hooks sequentially. No concrete regression was established, so the PR appears ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main change: restoring test context before setup hooks run in end-to-end tests.
Description check Passed The description directly explains the fixture-loop failure, the missing test context error, and the reason for the fix.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@danielroe
danielroe requested a review from yamachi4416 October 14, 2026 08:52
@danielroe
danielroe added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit e345739 Oct 14, 2026
14 checks passed
@danielroe
danielroe deleted the fix/multiple-setup-describe branch October 14, 2026 11:15
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
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.

2 participants