-
Notifications
You must be signed in to change notification settings - Fork 32
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
Update @salesforce/apex/* imports to return jest.fn() #260
Conversation
Thanks for the contribution! Before we can merge this, we need @nwcm to sign the Salesforce Inc. Contributor License Agreement. |
Thanks for the contribution! Could you clarify: is this a breaking change? |
FYI @pozil @Templarian do you have strong opinions about this? Should we just return a |
Hey @nolanlawson, I don't believe so but can't be 100%. This change did not break any tests across our source which usually directly mock apex in each test file |
I like the idea of having a mock directly but I have not clue about the potential impact of such a change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be a breaking change. It looks reasonable enough to me.
OTOH could we please add documentation for this so that it's more discoverable? A good place would be this README. Thank you! 🙇
@nolanlawson I have made additions to the documentation as you suggest. Feel free to provide feedback, there wasn't anything too similar in the readme to align with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change to account for injectGlobals=false
and I think this is good to go! nwcm#1
fix: import jest from `@jest/globals`
Good catch! Merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a bunch! Really appreciate the time you took to add docs and such. 🙇 Will release this in a bit.
After looking for ways to simplify mocking apex methods in a SFDX project, I found this transformer is applied. However the apex method transforms don't make the imports available within jests.
This change allows for jests import and use apex methods cleanly without having to mock in each test file.
This doesn't apply to wired apex methods which would need
createApexTestWireAdapter()
from @salesforce/sfOtherwise any apex method requires