You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We do have 'Jest compatible' expect module, but it's fn implementation isn't really 'Jest compatible'. We don't have any api to support dynamic change of mock function implementation, and it seems like one of the main parts of being 'Jest compatible' in my opinion. And currently any migration of project from node to deno will require manual changes in this aspect.
mockImplementation() and mockImplementationOnce(), with all of the sugarcoated mockReturnValue() etc
withImplementation().
Would be nice to return resource with [Symbol.dispose] from withImplementation() when scope callback wasn't provided.
Multiple implementation args of fn could be sugarcoated version of doing fn().mockImplementationOnce().mockImplementationOnce().
To be backward compatible and implement .mockRestore() we either could use first argument function as default implementation or provide .mockRestore() only argument instead of multiple
Also would be nice to have spyOn implementation compatible with 'Jest' version.
Describe alternatives you've considered
Come with any other better api for dynamically changing implementation
PS
I'm willing to start working on this issue my self in my free time, if that's ok
Is your feature request related to a problem? Please describe.
We do have 'Jest compatible' expect module, but it's
fn
implementation isn't really 'Jest compatible'. We don't have any api to support dynamic change of mock function implementation, and it seems like one of the main parts of being 'Jest compatible' in my opinion. And currently any migration of project fromnode
todeno
will require manual changes in this aspect.Describe the solution you'd like
Provide same functionality described for Jest's mock function for
@stc/expect
'sfn
, like:mockImplementation()
andmockImplementationOnce()
, with all of the sugarcoatedmockReturnValue()
etcwithImplementation()
.Would be nice to return resource with
[Symbol.dispose]
fromwithImplementation()
when scope callback wasn't provided.Multiple implementation args of
fn
could be sugarcoated version of doingfn().mockImplementationOnce().mockImplementationOnce()
.To be backward compatible and implement
.mockRestore()
we either could use first argument function asdefault implementation
or provide.mockRestore()
only argument instead of multipleAlso would be nice to have
spyOn
implementation compatible with 'Jest' version.Describe alternatives you've considered
Come with any other better api for dynamically changing implementation
PS
I'm willing to start working on this issue my self in my free time, if that's ok
PS
Referencing my other issue about incompatibility with
@std/testing/mock
as I think they are closely relatedJust wanted to mention issue about
@std/expect
'sfn
not being type safe here as it seems related in my opinionThe text was updated successfully, but these errors were encountered: