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

verify promise not behaving as expected #18

Closed slowdownitsfine closed 6 years ago

slowdownitsfine commented 7 years ago

Use this packet a ton, thank you!

Don't know if this is a bug or I'm doing something wrong ,but I am uncertain with .verify.

When running the mock server like so from the command line:

mockserver -serverPort 3300 -logLevel INFO

And then running the following lines in node v4.6.2:

const mockClient = require('mockserver-client');
const client = mockClient.mockServerClient('localhost', 3300);
client
  .verify({
    httpRequest: {
      method: 'POST',
      path: '/testpath',
      body: {}
    }
  })
  .then(function(error, result, pending) {
    console.log({ error, result, pending });
  });

I will never see the console.log in the promise callback. If I'm not mistaken the verification should fail, since no previous request was made, right?

jamesdbloom commented 6 years ago

Sorry for the delayed response, I've been mainly responding to bug / issues on the main mockserver repository: https://github.com/jamesdbloom/mockserver

I think the issue is with the format of the callback, please using the following format:

const mockClient = require('mockserver-client');
const client = mockClient.mockServerClient('localhost', 3300);
client
  .verify({
    httpRequest: {
      method: 'POST',
      path: '/testpath',
      body: {}
    }
  })
  .then(function() {
  }, function(error) {
    console.log(error);
  });

I am currently rewriting the main documentation / website. I will be adding 100s of more code examples, including examples of how to do verifications using the node client.