Giter Club home page Giter Club logo

Comments (3)

pawarrchetan avatar pawarrchetan commented on July 28, 2024

Additional error logs -

tsc --noEmit --project tsconfig.jest.json
node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts:11:28 - error TS2304: Cannot find name 'queueMicrotask'.

11     queueMicrotask: typeof queueMicrotask;

test/cognito.test.ts:11:32 - error TS2345: Argument of type 'typeof CognitoIdentityProviderClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, any>>'.
  Type 'typeof CognitoIdentityProviderClient' 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 'AddCustomAttributesCommandOutput' is not assignable to type 'OutputType'.
                                      'AddCustomAttributesCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

11 const cognitoMock = mockClient(CognitoIdentityProviderClient)


test/cognito.test.ts:13:16 - error TS2345: Argument of type 'typeof AdminInitiateAuthCommand' is not assignable to parameter of type 'new (input: AdminInitiateAuthCommandInput) => AwsCommand<AdminInitiateAuthCommandInput, MetadataBearer, any, any>'.
  Types of construct signatures are incompatible.
    Type 'new (input: AdminInitiateAuthCommandInput) => AdminInitiateAuthCommand' is not assignable to type 'new (input: AdminInitiateAuthCommandInput) => AwsCommand<AdminInitiateAuthCommandInput, MetadataBearer, any, any>'.
      Construct signature return types 'AdminInitiateAuthCommand' and 'AwsCommand<AdminInitiateAuthCommandInput, MetadataBearer, any, any>' are incompatible.
        The types of 'middlewareStack.concat' are incompatible between these types.
          Type '<InputType extends AdminInitiateAuthCommandInput, OutputType extends AdminInitiateAuthCommandOutput>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends AdminInitiateAuthCommandInput, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>'.
            Types of parameters 'from' and 'from' are incompatible.
              Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, AdminInitiateAuthCommandOutput>'.
                Types of property 'addRelativeTo' are incompatible.
                  Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, AdminInitiateAuthCommandOutput>, options: RelativeMiddlewareOptions) => void'.
                    Types of parameters 'middleware' and 'middleware' are incompatible.
                      Type 'MiddlewareType<InputType, AdminInitiateAuthCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                        Type 'InitializeMiddleware<InputType, AdminInitiateAuthCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                          Type 'InitializeMiddleware<InputType, AdminInitiateAuthCommandOutput>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                            Call signature return types 'InitializeHandler<InputType, AdminInitiateAuthCommandOutput>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                              Type 'Promise<InitializeHandlerOutput<AdminInitiateAuthCommandOutput>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                                Type 'InitializeHandlerOutput<AdminInitiateAuthCommandOutput>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                                  Types of property 'output' are incompatible.
                                    Type 'AdminInitiateAuthCommandOutput' is not assignable to type 'OutputType'.
                                      'AdminInitiateAuthCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

13 cognitoMock.on(AdminInitiateAuthCommand).resolves({

On further investigation I think this issue could be related to sinonjs/fake-timers#387 (comment)

As per the suggestions in the above issue, I also used sinonjs/fake-timers@6 and @types/sinonjs__fake-timers@6 to test if older dependencies would resolve this issue.
However I still encounter the same error.

from aws-sdk-client-mock.

m-radzikowski avatar m-radzikowski commented on July 28, 2024

Hey,
please check with yarn why @aws-sdk/types (or something similar for npm) if you have different versions of @aws-sdk/types installed. It may be that you are using, let's say, @aws-sdk/types 3.20.0, but you also have installed the amplify library that has dependency on the @aws-sdk/types v3.10.0. yarn (or npm) can decide that on the root level of node_modules it will install the v3.10.0. Then in the tests the types don't match, because you are trying to mock v3.20.0 client while the mocking library sees the types for the v3.10.0.

If that's the case, the resolution for this is to force the yarn (or npm) to install the same version of @aws-sdk/types as the other @aws-sdk/client-* you have. In yarn, you can do this with:

  "resolutions": {
    "@aws-sdk/types": "3.18.0"
  },

in package.json.

Let me know if that helps.

Unfortunately, there is nothing we can do about that problem on the library side.

I need to add this info to the readme.

from aws-sdk-client-mock.

m-radzikowski avatar m-radzikowski commented on July 28, 2024

Hey, did the above help you? If not, please also take a look at #28

I'm closing this for now, but please let me know if the problem remains.

from aws-sdk-client-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.