jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.16k stars 6.45k forks source link

Different result running single test or test suite #8601

Closed darge98 closed 2 years ago

darge98 commented 5 years ago

🐛 Bug Report

Hi, I'm new to Unit Test. I tried to create Unit test in an Angular application. I have one suite with 5 tests. 3 of them used the useFakeTimers function. When I run every test individually I have a successfull message. When I run the suite only the first that use useFakeTimers pass, the other return the following message:

Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

To Reproduce

Run test individually and run all the suite.

Expected behavior

Same result when running individually test and the suite.

Link to repl or repo (highly encouraged)

Here

Run npx envinfo --preset jest

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
  Binaries:
    Node: 8.11.1 - C:\Program Files\nodejs\node.EXE
    npm: 6.0.0 - C:\Program Files\nodejs\npm.CMD
jeysal commented 5 years ago

Hey @darge98, your repo doesn't seem to contain any test. Afaik useFakeTimers should be used on a per-test file basis though, not per-test case.

darge98 commented 5 years ago

Hi @jeysal, sorry for the repo. I update it. The test are inside src/app/toolbar. However, I try to add useFakeTimers in the file, but now every test will fail with the same error.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.