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

Jest hangs on invalid expectation(s) #6157

Closed
another-guy opened this issue May 9, 2018 · 8 comments
Closed

Jest hangs on invalid expectation(s) #6157

another-guy opened this issue May 9, 2018 · 8 comments

Comments

@another-guy
Copy link

another-guy commented May 9, 2018

TL;DR The issue is specific to Node 10.0.0; Try upgrading to 10.1.0 or above.

🐛 Bug Report

If my there is at least one expectation in my unit test that is not fulfilled at test time, the entire test suite "hangs" instead of reporting a failed ("red") test.

(On contrary, If all my expectations are fulfilled at test time, the tests does not seem to hang.)

To Reproduce

The following test code is an example.

describe(`Demo`, () => {
  it(`Should Fail, not Hang`, () => {
    expect(1).toEqual(2);
  });
});

Run Jest from Git Bash/CMD, observe the following output:

$ yarn test
yarn run v1.6.0
(node:3316) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ jest -i

 RUNS  __tests__/3-1-single-array-multiple-stacks.spec.ts

Software/Package Versions:

jest: 22.4.3
ts-jest: 22.4.5

$ node --version
v10.0.0

$ npm --version
6.0.0

$ npm --version
6.0.0

$ tsc --version
Version 2.8.3

Expected behavior

The test should be reported as failing.

Run npx envinfo --preset jest

$ npx envinfo --preset jest
npx: installed 1 in 5.897s

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i5-3317U CPU @ 1.70GHz
  Binaries:
    Yarn: 1.6.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.0.0 - ~\AppData\Roaming\npm\npm.CMD
@rickhanlonii
Copy link
Member

This seems configuration specific, can you push a repo?

@another-guy
Copy link
Author

@rickhanlonii you can take a look at it here. (Please notice the branch -- repro).

Thanks for quick turnaround.

@rickhanlonii
Copy link
Member

@another-guy hm, this did not hang for me:

@another-guy
Copy link
Author

@rickhanlonii thank you for looking into it. I should try to rollback from Node.js 10.0.0 to whatever I had day before yesterday and re-check. Things seemed to be working jest a few days ago.

@SimenB
Copy link
Member

SimenB commented May 9, 2018

It hangs when I use Node 10

@SimenB
Copy link
Member

SimenB commented May 9, 2018

It does not hang on node 10.1.0, though. Maaaaybe related to nodejs/node#20266?

@SimenB SimenB closed this as completed May 9, 2018
@another-guy
Copy link
Author

@SimenB I confirm the upgrade resolved the issue. Thanks a ton!

$ node --version
v10.1.0
$ yarn test                                                                                                       
yarn run v1.6.0                                                                                                   
(node:2392) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use 
the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.                                       
$ jest -i                                                                                                         
(node:4552) ExperimentalWarning: The fs.promises API is experimental                                              
(node:4552) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use 
the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.                                       
 FAIL  __tests__\3-1-single-array-multiple-stacks.spec.ts                                                         
  Demo                                                                                                            
    × Should Fail, not Hang (13ms)                                                                                
                                                                                                                  
  ● Demo › Should Fail, not Hang                                                                                  
                                                                                                                  
    expect(received).toEqual(expected)                                                                            
                                                                                                                  
    Expected value to equal:                                                                                      
      2                                                                                                           
    Received:                                                                                                     
      1

      1 | describe(`Demo`, () => {
      2 |   it(`Should Fail, not Hang`, () => {
    > 3 |     expect(1).toEqual(2);
      4 |   });
      5 | });
      6 |

      at Object.it (__tests__/3-1-single-array-multiple-stacks.spec.ts:3:15)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        2.523s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants