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

fix: show better errors from babel-plugin-jest-hoist #8865

Merged
merged 3 commits into from
Aug 22, 2019

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Aug 22, 2019

Summary

Fixes #8864

Test plan

Before:

image
image

After:
image
image

@SimenB SimenB requested review from jeysal and thymikee August 22, 2019 11:25
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@7b8393e). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #8865   +/-   ##
=========================================
  Coverage          ?   63.85%           
=========================================
  Files             ?      275           
  Lines             ?    11578           
  Branches          ?     2838           
=========================================
  Hits              ?     7393           
  Misses            ?     3558           
  Partials          ?      627
Impacted Files Coverage Δ
packages/babel-plugin-jest-hoist/src/index.ts 0% <0%> (ø)

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 7b8393e...c1f6cdb. Read the comment docs.


// We allow `jest`, `expect`, `require`, all default Node.js globals and all
// ES2015 built-ins to be used inside of a `jest.mock` factory.
// We also allow variables prefixed with `mock` as an escape-hatch.
const WHITELISTED_IDENTIFIERS: Set<string> = new Set([
Copy link
Member Author

Choose a reason for hiding this comment

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

ignoring whitespace is a good idea while reviewing this PR

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Looks good! Would be even better to show the path to the module inside codeframe, but not sure how hard would it be to pull it off

@SimenB
Copy link
Member Author

SimenB commented Aug 22, 2019

The filename is part of the error - would you want it somewhere else? Babel puts it there automatically, I don't deal with the filename

@thymikee
Copy link
Collaborator

The filename is part of the error

Yea I've seen that. That's why I'm ok with how it is now. But would be more happy to have something like:

TypeError: message

1 | codefarme...

at Fn (path/to/filename instead of babel internals)

@SimenB
Copy link
Member Author

SimenB commented Aug 22, 2019

Aha! Yeah, that's interesting... Maybe open up an issue at babel/babel? I don't think it's worth it for us to deal with it here

@github-actions
Copy link

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 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 this pull request may close these issues.

Add line number to error "The second argument of jest.mock must be an inline function"
4 participants