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

Crash when pretty-printing AbortController / AbortSignal #10770

Closed
bogdanb opened this issue Nov 2, 2020 · 3 comments · Fixed by #11189
Closed

Crash when pretty-printing AbortController / AbortSignal #10770

bogdanb opened this issue Nov 2, 2020 · 3 comments · Fixed by #11189

Comments

@bogdanb
Copy link

bogdanb commented Nov 2, 2020

🐛 Bug Report

In some cases, when an expect fails such that the message would include an AbortController or an AbortSignal, Jest crashes instead of displaying the test failure.

To Reproduce

Steps to reproduce the behavior:

Run a test like this one;

it.only("should show a test failure", () => {
  const controller = new AbortController();

  expect({ controller }).toMatchObject({ not: "this" });
});

In my case, at least, it crashes with: TypeError: Cannot read property 'includes' of undefined

Expected behavior

It should report a test failure.

envinfo

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
  Binaries:
    Node: 14.7.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD

I’m using: "babel-jest": "^26.5.2", "jest": "^26.5.3", "jest-extended": "^0.11.5"

More info:

The exact crash depends on the matcher. If you use something like toIncludeSameMembers from jest-extended (which I think uses Jest’s code to print its errors) the crash is different (it seemed to happen in another place). I don’t know if Jest’s built-in matchers can do that as well, I have not tried all of them.

A similar crash happens if the matched object contains a reference to controller.signal instead.

@snitin315
Copy link
Contributor

@SimenB Can you point towards the corresponding potential code that might be causing this bug?

@pikou1995
Copy link
Contributor

I know how to fix it. I will create a PR in this week.😃

@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 10, 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.

4 participants