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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing a non-Error object with a property called "stack" causes test to hang #10681

Closed
modernserf opened this issue Oct 22, 2020 · 6 comments 路 Fixed by #10697
Closed

Throwing a non-Error object with a property called "stack" causes test to hang #10681

modernserf opened this issue Oct 22, 2020 · 6 comments 路 Fixed by #10697

Comments

@modernserf
Copy link

馃悰 Bug Report

It seems that if you throw an object that is not an instance of Error, but includes a property named stack that is an object, the test will never complete.

No error is reported on my machine, but the repl.it environment prints the error TypeError: stack.replace is not a function, though the test still hangs regardless.

To Reproduce

add this to a test file:

test("throw object with stack prop", () => {
  throw { stack: [] };
});

Expected behavior

Test fails, but remainder of test suite continues

Link to repl or repo (highly encouraged)

https://repl.it/repls/GrossDarlingLocks

envinfo

 System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 14.9.0 - ~/.nvm/versions/node/v14.9.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.9.0/bin/npm
  npmPackages:
    jest: ^26.4.2 => 26.4.2 
@SimenB
Copy link
Member

SimenB commented Oct 23, 2020

Seems likely, yeah. Anybody up for a PR fixing this? Anything thrown, ever, should be unknown and we then narrow down the type afterwards. Assuming stack is a string is unsafe as can be seen by this issue.

@snitin315
Copy link
Contributor

Hello @SimenB, I was trying to work on this issue.
Do I have to run yarn run build every time I make changes in jest/packages/jest-jasmine2/src/reporter.ts to test the changes?

@SimenB
Copy link
Member

SimenB commented Oct 24, 2020

You can run yarn watch to build once and then set up a watcher 馃檪

@jeysal
Copy link
Contributor

jeysal commented Oct 25, 2020

This seems to also fail with jest-circus in a different way BTW
image

@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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants