Typescript error when mocking EC2
See original GitHub issuewhen mocking EC2
const ec2ClientMock = mockClient(EC2Client);
const ec2 = new EC2Client({ region: "eu-west-1" });
I’m getting this error:
Argument of type 'typeof EC2Client' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, any>>'.
Type 'typeof EC2Client' is not assignable to type 'ClassType<Client<ServiceInputTypes, MetadataBearer, any>>'.
The types of 'prototype.middlewareStack.concat' are incompatible between these types.
Type '<InputType extends ServiceInputTypes, OutputType extends ServiceOutputTypes>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<InputType, OutputType>' is not assignable to type '<InputType extends ServiceInputTypes, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<InputType, OutputType>'.
Types of parameters 'from' and 'from' are incompatible.
Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, ServiceOutputTypes>'.
Types of property 'addRelativeTo' are incompatible.
Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, ServiceOutputTypes>, options: RelativeMiddlewareOptions) => void'.
Types of parameters 'middleware' and 'middleware' are incompatible.
Type 'MiddlewareType<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
Call signature return types 'InitializeHandler<InputType, ServiceOutputTypes>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
Type 'Promise<InitializeHandlerOutput<ServiceOutputTypes>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
Type 'InitializeHandlerOutput<ServiceOutputTypes>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
Types of property 'output' are incompatible.
Type 'ServiceOutputTypes' is not assignable to type 'OutputType'.
'ServiceOutputTypes' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.
Type 'MetadataBearer' is not assignable to type 'OutputType'.
'MetadataBearer' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.
Using latest version 0.3.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
aws-sdk-mock not mocking when using Typescript and ts-jest
This says to me that the AWS SDK has not been mocked. I have included below the test file, package.json , jest.config.js ,...
Read more >Mocking AWS with Jest (and TypeScript) - DEV Community
Using mockReturnValueOnce here gives me the response I'm expecting from the sdk at which point I can continue processing. Our tests are passing ......
Read more >TypeScript support · Issue #140 · dwyl/aws-sdk-mock - GitHub
When I execute my test command it yields this error: test/lambda.test.ts (5,21): Could not find a declaration file for module 'aws-sdk-mock' ...
Read more >Jest Typescript cannot mock AWS transcribe function - Edureka
I get an error at .mockResolvedValue(expectedResult) as "Argument of type '{ isMock: boolean; }' is not assignable to parameter of type 'never'.
Read more >How to Mock AWS Services in TypeScript - Kyle Galbraith
I've recently been working on a new project to automatically convert blog posts to audio that has a couple different serverless ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey. Took me a moment but it should work now in v0.5.0, with AWS SDK v3.17.0.
Compatibility with different SDK Clients will be now checked and monitored, see compatibility.md
Please let me know in case something still doesn’t work.
@raphaeldeem-acorns compatibility page was removed as the lib now works well with all SDK Clients.
The
Argument of type 'AwsStub<object, MetadataBearer>' is not assignable to parameter of type...
is often caused by the problem explained in the caveats section of the README. Please check it out, if this doesn’t help open a new issue with a reproduction example.