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

Jest compatibility API: mockFn.withImplementation API #2812

Closed
4 tasks done
trivikr opened this issue Feb 5, 2023 · 4 comments · Fixed by #2835
Closed
4 tasks done

Jest compatibility API: mockFn.withImplementation API #2812

trivikr opened this issue Feb 5, 2023 · 4 comments · Fixed by #2835
Labels
enhancement New feature or request pr welcome

Comments

@trivikr
Copy link
Contributor

trivikr commented Feb 5, 2023

Clear and concise description of the problem

Jest added mockFn.withImplementation API in v29.1.0

It accepts a function which should be temporarily used as the implementation of the mock while the callback is being executed.

Suggested solution

Add this API to vitest, if maintainers think it would be helpful to it's users.

Alternative

Document how mockImplementation or mockImplementationOnce can be used in these use cases

Additional context

This issue was noticed while writing vitest-codemod tests for mock API
trivikr/vitest-codemod#80

Validations

@sheremet-va sheremet-va added enhancement New feature or request pr welcome labels Feb 6, 2023
@mysteryven
Copy link
Contributor

mysteryven commented Feb 7, 2023

I'd like to take this PR😀

@obadakhalili
Copy link
Contributor

I'd like to take this PR

I'm sorry @mysteryven but I have already opened a PR for this. I probably should have commented before doing so, but it is my first contribution and I didn't want to make any promises that I might not be able to keep 😅.

Again, sorry for the confusion.

@trivikr
Copy link
Contributor Author

trivikr commented Feb 8, 2023

I'd like to take this PR😀

@mysteryven Thank you for your interest.

I'd created multiple issues with vitest.
You can take #2831 if you're interested, for example.

Maintainers haven't added enhancement label to it yet, but I think they would looking at other compatibility feature requests.

@mysteryven
Copy link
Contributor

mysteryven commented Feb 9, 2023

Again, sorry for the confusion.

Never mind ! 😛 @obadakhalili

@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants