mock-server/mockserver-client-node

Incorrect type definition for verifySequence

Closed this issue · 1 comments

b4rd commented

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>;

This is now fixed