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

asyncError not caught causing failing tests to pass #894

Open
marr opened this issue Aug 12, 2022 · 1 comment
Open

asyncError not caught causing failing tests to pass #894

marr opened this issue Aug 12, 2022 · 1 comment

Comments

@marr
Copy link

marr commented Aug 12, 2022

Environment

  1. vscode-jest version: 4.6.0
  2. node -v: 16.16.0
  3. npm -v or yarn --version: npm 8.11.0
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@28.1.3
  5. your vscode-jest settings if customized:
    • jest.jestCommandLine? npx jest
    • jest.autoRun? false
    • anything else that you think might be relevant? [fill]
  6. Operating system: osx 12.5

Prerequisite

  • are you able to run jest test from the command line? yes (with npx)
  • how do you run your tests from the command line? npx jest

Steps to Reproduce

https://github.com/marr/jest-async-fail

  1. npm install
  2. npx jest
  3. see failing test
  4. open in vs code with extension and run test
  5. see passing test

Relevant Debug Info

Screen Shot 2022-08-12 at 10 45 51 AM
Screen Shot 2022-08-12 at 10 46 38 AM

This is blocking us from fully adopting/trusting the plugin at the moment. Some screenshots are included to potentially point out that within the jest runner for this test, asyncError is set to an Error object, but as you can see below things are green in the ide.
Screen Shot 2022-08-12 at 10 59 11 AM

Thanks for any help

@connectdotz
Copy link
Collaborator

@marr sorry for the late reply. Your repo helped us identify another bug (thanks), and we were able to address that, however not related to your actual issue.

Now that is out of the way, I played with your sample repo again today: the original repo (after uncommented the xdescribe), showed ERR_UNHANDLED_REJECTION:

node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Error: expect(received).resolves.toContain(expected) // indexOf

Expected value: 2
Received array: [1]".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

So I modified your tests then all is well:
Screen Shot 2022-09-24 at 4 49 01 PM

The green check mark you saw in the TestExplorer is a cached status since the async error interfered with the proper update. It should do better, fortunately, this is addressed in the next release:

Screen Shot 2022-09-24 at 5 03 02 PM

Thanks for bringing this to our attention, hopefully after fixing your test code you are good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants