Closed YiCChi closed 1 month ago
@m-radzikowski could you please review this PR? thank you!
Interesting to see that you can make this compatible for both jest
and vitest
. I ended up developing https://github.com/stschulte/aws-sdk-client-mock-vitest that may also work for you while this is under review (aws-sdk-client-mock-vitest
was heavily inspired by aws-sdk-client-mock-jest
)
@stschulte aws-sdk-client-mock-vitest
works very well, and helps me a lot! I will always use it after this pr get merged because I only use vitest in my project.
I created this pr (inspired by aws-sdk-client-mock-vitest
) for those who cloudn't find aws-sdk-client-mock-vitest
. To be honest, if it can be linked in this repo, maybe this is not needed.
I would love to see this merged as well!
Hey, that looks nice. I'll try to review it fully this week, there is quite a lot of changes here.
Thanks for the changes! The tests are failing because you didn't update the import in test-d/types.ts
.
Apart from that, it looks good. My only concern now is if having dependencies on both expect
and @vitest/expect
won't cause anyone any problems... But on the other hand, those libs are only referenced if you import aws-sdk-client-mock-jest
or aws-sdk-client-mock-jest/vitest
, so I hope it will be okay.
If you fix the build, I will merge it and release a beta version.
Updated the import.
My only concern now is if having dependencies on both
expect
and@vitest/expect
won't cause anyone any problems...
I had considered the same thing, so I didn't reference any types from either package in jestMatchers.ts
. Instead, I created many type declarations to satisfy the minimum type constraints. I think the best way is to split it into two packages, but that's up to you.
I've merged but the build on main failed: https://github.com/m-radzikowski/aws-sdk-client-mock/actions/runs/11128928698
I'm away now so I can only merge something from mobile. I can fix it and release in 1.5 week or you can make a PR to fix it if you want it released sooner.
Released in v4.1.0-beta.0
Close https://github.com/m-radzikowski/aws-sdk-client-mock/issues/216
Some code comes from a nice package https://github.com/stschulte/aws-sdk-client-mock-vitest, which adds custom matchers for only vitest.
change for implemetation of matchers
objectContaining(input).asymmetricMatch(received.input)
instead ofthis.equals(received, expect.objectContaining(input))
for compatibilityMatcherContext
,ExpectationResult
, etc. for compatibilityvitest support
import 'aws-sdk-client-mock-jest/vitest'
toHaveBeenCalled
,toHaveBeenCalledTimes
,toHaveBeenCalledWith
,toHaveBeenNthCalledWith
)