mock-server / mockserver-client-node

MockServer javascript client for browsers, Node.js or any grunt build
http://mock-server.com
Apache License 2.0
72 stars 34 forks source link

Incorrect type definition for verifySequence #72

Closed b4rd closed 2 years ago

b4rd commented 3 years ago

Describe the issue verifySequence expects a list of request definitions, but the TypeScript type definition looks like this: verifySequence(matchers: RequestDefinition[]): Promise<void | string>;.

If I pass an array as an argument, I get this error from MockServer:

Error: Failed: "1 error:
 - instance type (array) does not match any allowed primitive type (allowed: [\"object\"]) for field \"/httpRequests/0\"

See: https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.10.x for OpenAPI Specification"`

MockServer version 5.10.0

To Reproduce Call verifySequence with an array.

mockServerClient("localhost", 1080)
      .verifySequence([
        {
          'method': 'POST',
          'path': '/somePathOne',
          'body': 'someBody'
        },
        {
          'method': 'GET',
          'path': '/somePathTwo'
        }
      ])

Solution idea Change the type definition so matchers is a rest parameter:

verifySequence(...matchers: RequestDefinition[]): Promise<void | string>;

jamesdbloom commented 2 years ago

This is now fixed