Skip to content

Fix throw matcher error support#4962

Merged
cpojer merged 1 commit into
jestjs:masterfrom
zouxuoz:throw-matcher-error-support
Dec 5, 2017
Merged

Fix throw matcher error support#4962
cpojer merged 1 commit into
jestjs:masterfrom
zouxuoz:throw-matcher-error-support

Conversation

@zouxuoz

@zouxuoz zouxuoz commented Nov 27, 2017

Copy link
Copy Markdown
Contributor

Summary

Resolve #4946

Test plan

yarn jest --testPathPattern="throw_matcher"

@SimenB

SimenB commented Nov 27, 2017

Copy link
Copy Markdown
Member

Thanks for the PR!

I think we only want this behavior if we're in a rejects block. Synchronous matcher solved it with a fromPromise?: boolean when constructing the matcher, is that possible here as well?

@codecov-io

codecov-io commented Nov 27, 2017

Copy link
Copy Markdown

Codecov Report

Merging #4962 into master will increase coverage by 0.13%.
The diff coverage is 62.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4962      +/-   ##
==========================================
+ Coverage   60.31%   60.44%   +0.13%     
==========================================
  Files         198      198              
  Lines        6632     6664      +32     
  Branches        3        3              
==========================================
+ Hits         4000     4028      +28     
- Misses       2632     2636       +4
Impacted Files Coverage Δ
...circus/src/legacy_code_todo_rewrite/jest_expect.js 0% <0%> (ø) ⬆️
packages/jest-jasmine2/src/jest_expect.js 0% <0%> (ø) ⬆️
packages/jest-snapshot/src/index.js 63.04% <83.33%> (+19.86%) ⬆️
packages/jest-message-util/src/index.js 86.13% <0%> (-0.6%) ⬇️
packages/jest-jasmine2/src/index.js 5.47% <0%> (-0.41%) ⬇️
packages/jest-runtime/src/script_transformer.js 86.5% <0%> (-0.33%) ⬇️
packages/jest-runner/src/run_test.js 1.96% <0%> (-0.27%) ⬇️
packages/jest-util/src/install_common_globals.js 100% <0%> (ø) ⬆️
packages/jest-runtime/src/index.js 74.83% <0%> (+1.2%) ⬆️
packages/jest-leak-detector/src/index.js 72.72% <0%> (+1.89%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16e7c46...b6b5d84. Read the comment docs.

@zouxuoz

zouxuoz commented Nov 27, 2017

Copy link
Copy Markdown
Contributor Author

@SimenB Oops :) I will do it today

@cpojer

cpojer commented Nov 29, 2017

Copy link
Copy Markdown
Member

@zouxuoz do you have some time to finish this? :)

@zouxuoz

zouxuoz commented Dec 1, 2017

Copy link
Copy Markdown
Contributor Author

@SimenB @cpojer Sorry for delay. Fixed, but not sure if this is the best solution 🤔

@cpojer

cpojer commented Dec 4, 2017

Copy link
Copy Markdown
Member

Unfortunately expect cannot depend on jest-snapshot.

@SimenB

SimenB commented Dec 4, 2017

Copy link
Copy Markdown
Member

I'm not sure if it's possible to have this feature the way expect.extend is written, then

@cpojer

cpojer commented Dec 4, 2017

Copy link
Copy Markdown
Member

Is there any way we can expose something in expect that will allow us to put most of the logic into jest-snapshot without taking on this dependency?

@zouxuoz

zouxuoz commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

@cpojer @SimenB maybe we can do it something like this?

@SimenB

SimenB commented Dec 5, 2017

Copy link
Copy Markdown
Member

Ah, this looks really promising! Could you add a test somewhere fitting that await expect(Promise.reject()).rejectes.toMatchSnapshot() works like it should? Maybe it's best as an integration test.

EDIT: hah, pun not intended

@zouxuoz

zouxuoz commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

@SimenB good idea, but how I can check the content of the written snapshot in integration tests? I can't find tests with similar behavior.

@thymikee

thymikee commented Dec 5, 2017

Copy link
Copy Markdown
Contributor

Right after expectation you should be able to just read from FS, but before deleting the snapshot in (usually done in afterEach hook).

@zouxuoz

zouxuoz commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

@SimenB @cpojer done

@SimenB SimenB left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks!

Can you update the changelog?

@zouxuoz

zouxuoz commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

@SimenB updated 😉

@cpojer cpojer merged commit 78184f2 into jestjs:master Dec 5, 2017
@github-actions

Copy link
Copy Markdown

This pull request 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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toThrowErrorMatchingSnapshot does not work with promises

6 participants