Skip to content

Jest hangs on invalid expectation(s) #6157

@another-guy

Description

@another-guy

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions