-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add overloads for mock functions, fully expand out d.ts file #122
Conversation
Darn, I guess CI won't run since this isn't targeting the |
Let me retarget this at master (temporarily) to check CI, but |
I'm making the assumption that |
GitHub Actions was erroring so my windows runs got cancelled :( (reran, CI passes, yay) |
Verified that this works on my project with |
This looks great. The adapter function is a great idea and the comments are great. Should we merge it? |
I'm afk starting now btw so might not see any response for awhile |
If you're happy with it sure. My remaining questions are:
|
RE: types, I can totally just ignore that for this PR and send a PR showing an example another day, so really, just the first two questions are what I need. 😄 |
Supporting opts allows esmock to be called with many options at once and it allows future options to be added easily (for me). From my perspective, opts is the main way to control esmock and the "p" and "px" functions are sugar for calling esmock with common predefined opts values. It would be good for esmock to use the same namings everywhere and it will happen soon, I believe, but until then I'm okay with different names being used. |
Cool, thanks. I'll go inspect everything for some opts to document, then. |
Your PR re-exports types definitions from inside the "tests" folder so they aren't duplicated (just noticed this) and the type definitions are more specific and better than the previous ones. Great improvements. |
I've added the options type. Unfortunately, though, I'm not sure that I can continue to use esmock in my project; it turns out that ESM loaders aren't compatible with coverage gathering due to various issues (bcoe/c8#325); in my case, I thought that my project had been 100% tested, when in fact there are whole files I forgot to test. Not adding the esmock loader lets me see that in my testing; presumably this is because the mocked version of that module is loaded, the coverage sees that it was used, and so gets 100%, when all that happened was that it was mocked. There is another (competing?) ESM mocker called I'm not sure that this is in scope of esmock at all, unless there's a way to load mock files as completely different paths internally (but correctly set their |
CI failure is a flake; my commit only changed the types, so this should me mergable. |
partial?: boolean | undefined; | ||
purge?: boolean | undefined; |
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.
These could be documented; not sure quite what to write as personally I would suggest that people use the named functions to set these instead (i.e. treat options as an internal implementation detail).
@@ -1,6 +1,8 @@ | |||
# changelog | |||
|
|||
* 1.9.5 | |||
* 1.9.6 _Aug.19.2022_ |
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.
This date's now wrong; feel free to change.
That's too bad about the CI coverage. Things are looking pretty good here. If you recommend any links with relevant info, they could be added to the README or wiki here to give people a warning about the coverage issue. Thanks for hanging out here and making a great contribution. |
oh of course you did give a link I'll read through that thanks |
I hope I'm not doing anything rude by merging this. I believe you are sharing it for merge so I'm going to hit merge. There are few changes coming over the next week or two and it would be great to get this now. |
Yes, I switched this from a draft on purpose! Thanks for merging this. |
Here's a potential adjustment to the API and code to allow for overloads with to support a positional
import.meta.url
.Making the PR to your branch to not duplicate things; I want to see if CI passes (they do locally).