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.
For now, there is a misalignment between @std/expect and @std/testing/mock, which causes inability to use @std/expect's fn in @std/testing/mock's assertSpyCalls api, and @std/testing/mock in @std/expect's expect().toHaveBeenCalled() api. Which and prevents us from using both of them at the same time (totally possible for most of the other's apis of both modules).
This seems highly unreasonable, taking into account that both modules uses @std/internal and also @std/expect using @std/assert for some of it's functionalities like:
same AssertError class
toBe/toBeDefined/toBeUndefined/toBeNull uses assertNotStrictEquals and assertStrictEquals
toBeInstanceOf uses assertInstanceOf and assertNotInstanceOf
etc.
Describe the solution you'd like
Implement some core mock internals functionality in @std/internal and use it in both modules, agnostic to specifics of @std/assert api and @std/expect jest compatibility, like:
detection if function is mock function
gathering of internal calls state
Describe alternatives you've considered
Using compatible between modules storage of mocked function calls, like in @std/expect storing calls in .calls field array, or the other way around in @std/testing/mock storing calls in [Symbol.for("@MOCK")] field
Expected result
Expected result for this would be working code like this:
Deno.test("mock function",async({ step })=>{awaitstep("@std/expect should support @std/testing/mock",()=>{constspyFn=spy(()=>5);spyFn();expect(spyFn).toHaveBeenCalledTimes(1);});awaitstep("@std/testing/mock should support @std/expect/fn",()=>{constmockFn=fn(()=>5);mockFn();assertSpyCalls(mockFn,1);});});
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.
For now, there is a misalignment between
@std/expect
and@std/testing/mock
, which causes inability to use@std/expect
'sfn
in@std/testing/mock
'sassertSpyCalls
api, and@std/testing/mock
in@std/expect
'sexpect().toHaveBeenCalled()
api. Which and prevents us from using both of them at the same time (totally possible for most of the other's apis of both modules).This seems highly unreasonable, taking into account that both modules uses
@std/internal
and also@std/expect
using@std/assert
for some of it's functionalities like:AssertError
classtoBe/toBeDefined/toBeUndefined/toBeNull
usesassertNotStrictEquals
andassertStrictEquals
toBeInstanceOf
usesassertInstanceOf
andassertNotInstanceOf
Describe the solution you'd like
Implement some core mock internals functionality in
@std/internal
and use it in both modules, agnostic to specifics of@std/assert
api and@std/expect
jest compatibility, like:Describe alternatives you've considered
Using compatible between modules storage of mocked function calls, like in
@std/expect
storing calls in.calls
field array, or the other way around in@std/testing/mock
storing calls in[Symbol.for("@MOCK")]
fieldExpected result
Expected result for this would be working code like this:
PS
I'm willing to start working on this issue my self in my free time, if that's ok
PS
And my other issue about
@std/expect
'sfn
not being 'Jest compatible'The text was updated successfully, but these errors were encountered: