Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console logs not working when timer is used in test #1022

Closed
6 tasks done
mckelveygreg opened this issue Mar 24, 2022 · 2 comments · Fixed by #1026
Closed
6 tasks done

Console logs not working when timer is used in test #1022

mckelveygreg opened this issue Mar 24, 2022 · 2 comments · Fixed by #1026

Comments

@mckelveygreg
Copy link

Describe the bug

When using fake timers, console logs after timers do not fire :/

By using the sample code from the Timers Guide, there are few things I don't understand.

First, only the first test's mock seems to fire (or at least is shown in the console).
Second, the console log at the end of the third test never fires (the difference I think is that is the only test using advanceToNextTimer)

In my own code, I was hoping for some console logging to help debug what values are and what has been called, but my logs are coming blank :(

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-38lgxv?file=test/suite.test.ts

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 1.34 GB / 7.72 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 3.1.1 - /usr/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^1.1.4 => 1.1.4 
    vite: ^2.8.6 => 2.8.6 
    vitest: ^0.7.10 => 0.7.10

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

For now you can call vi.useRealTimers() after vi.runAllTimers. This will unblock console.

@mckelveygreg
Copy link
Author

Thank you all!! Using vitest has been a great experience both in code and community 🎉

chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants