Create matchers for `vitest`
ThomasAribart opened this issue Β· comments
Hello and thanks for this great lib
On my project we went from jest
to vitest
, mainly for performances. Sadly, we lost the toHaveReceivedCommand
matchers in the process
Would be awesome to have them for vitest
as well! Maybe it was the aim of separating jest
matchers in another lib in the first place ?
See https://vitest.dev/guide/extending-matchers.html
Cheers !
I found this in the vitest docs: https://vitest.dev/guide/features.html#chai-and-jest-expect-compatibility
When I set test.globals: true
in vite.config.js
, the aws-sdk-client-mock-jest
matchers seem to work.
Hey, sorry for the late reply. Thank you @kldavis4 for finding and sharing the way to make aws-sdk-client-mock-jest
work with vitest
. I will add that to the README.
While I see a raising popularity of vitest
, I'm not using it right now myself. If anyone wants to add vitest
matchers, or, even better, adjust current matchers so they can be use in vitest
natively (if possible) - feel free to open a PR.
It still doesn't work for me, even with test.globals set to true.
expect(ddbMock).toHaveReceivedCommandWith(QueryCommand, {});
Property 'toHaveReceivedCommandWith' does not exist on type 'Assertion<AwsStub<ServiceInputTypes, ServiceOutputTypes>>'.ts(2339)
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['junit', 'default'],
outputFile: './.vitest/results.xml',
coverage: {
// include coverage even if no tests exist
all: true,
include: ['src/*'],
reportsDirectory: './.vitest/coverage',
},
setupFiles: './src/setupTests.ts',
// [https://github.com/m-radzikowski/aws-sdk-client-mock/issues/139]
globals: true,
},
});