Skip to content

Commit 644a603

Browse files
committed
fix(jest): match input type accepting @jest/globals asymmetric matchers
1 parent 7acde27 commit 644a603

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

packages/aws-sdk-client-mock-jest/src/jestMatchers.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
6969
toHaveReceivedCommandWith<TCmdInput extends object,
7070
TCmdOutput extends MetadataBearer>(
7171
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
72-
input: Partial<TCmdInput>,
72+
input: {
73+
[Property in keyof TCmdInput]: unknown;
74+
},
7375
): R;
7476

7577
/**
@@ -95,7 +97,9 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
9597
TCmdOutput extends MetadataBearer>(
9698
call: number,
9799
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
98-
input: Partial<TCmdInput>,
100+
input: {
101+
[Property in keyof TCmdInput]: unknown;
102+
},
99103
): R;
100104

101105
/**
@@ -120,7 +124,9 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
120124
toHaveReceivedNthSpecificCommandWith<TCmdInput extends object, TCmdOutput extends MetadataBearer>(
121125
call: number,
122126
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
123-
input: Partial<TCmdInput>,
127+
input: {
128+
[Property in keyof TCmdInput]: unknown;
129+
},
124130
): R;
125131

126132
/**
@@ -153,7 +159,9 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
153159
toReceiveCommandWith<TCmdInput extends object,
154160
TCmdOutput extends MetadataBearer>(
155161
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
156-
input: Partial<TCmdInput>,
162+
input: {
163+
[Property in keyof TCmdInput]: unknown;
164+
},
157165
): R;
158166

159167
/**
@@ -163,7 +171,9 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
163171
TCmdOutput extends MetadataBearer>(
164172
call: number,
165173
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
166-
input: Partial<TCmdInput>,
174+
input: {
175+
[Property in keyof TCmdInput]: unknown;
176+
},
167177
): R;
168178

169179
/**
@@ -172,7 +182,9 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
172182
toReceiveNthSpecificCommandWith<TCmdInput extends object, TCmdOutput extends MetadataBearer>(
173183
call: number,
174184
command: new (input: TCmdInput) => AwsCommand<TCmdInput, TCmdOutput>,
175-
input: Partial<TCmdInput>,
185+
input: {
186+
[Property in keyof TCmdInput]: unknown;
187+
},
176188
): R;
177189

178190
/**

packages/aws-sdk-client-mock-jest/test/jestGlobals.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ it('passes using @jest/globals', async () => {
1212

1313
expect(() => expect(snsMock).toHaveReceivedCommand(PublishCommand)).not.toThrow();
1414
});
15+
16+
it('accepts asymmetric matchers with @jest/globals', async () => {
17+
const sns = new SNSClient({});
18+
await sns.send(publishCmd1);
19+
20+
expect(() => expect(snsMock).toHaveReceivedCommandWith(PublishCommand, {
21+
Message: expect.stringContaining('mock'),
22+
})).not.toThrow();
23+
});

0 commit comments

Comments
 (0)