nuxt / nuxt/test-utils

@nuxt/test-utils -- setup() clobbers console.log() functionality

Open
#350 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
437
Forks
120
Avg merge
22h 52m
Merged PRs (30d)
23

Description

Environment
  • Operating System: Darwin
  • Node Version: v18.16.0
  • Nuxt Version: 3.5.2
  • Nitro Version: 2.4.1
  • Package Manager: yarn@1.22.17
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -
Reproduction

https://stackblitz.com/edit/github-kp3tnj?file=test%2Fmyhello.test.ts

Describe the bug

When setup() is called at the beginning of a vitest test file (as described in the docs https://nuxt.com/docs/getting-started/testing), console.log() no longer displays text on the console during the test run.

When setup() is commented out, console.log() works as expected.

Additional context

No response

Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked StackBlitz reproduction and compare the Vitest output with setup() enabled and commented out; the example test is test/myhello.test.ts. Then trace the @nuxt/test-utils setup() path to identify where console.log is affected. Done means console.log output remains visible during the test run while setup() is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.