DiUS / pact-consumer-js-dsl

*DEPRECATED* A Javascript DSL for creating pacts, superceded by Pact JS
https://github.com/pact-foundation/pact-js
Other
56 stars 26 forks source link

Failed to execute 'send' on 'XMLHttpRequest' when calling Pact.mockService more then once #13

Closed BenSayers closed 9 years ago

BenSayers commented 9 years ago

I am calling Pact.mockService in the beforeEach of my jasmine tests (in the same way as the example in this repo). When the second test case runs an error is thrown:

Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://127.0.0.1:12341234/interactions'.

This is caused by https://github.com/DiUS/pact-consumer-js-dsl/blob/master/src/mockService.js#L13:

    _baseURL += opts.port;

This line is adding a port number to the end of the baseURL. This works for the first test as there is no port number in baseURL yet, but will fail for any test after that.

I'm happy to submit a PR to fix it but I'd like to understand the thinking behind the MockService object first:

If you can clear these things up for me I'm happy to submit a fix.

Cheers, Ben

bethesque commented 9 years ago

Thanks for looking into this Ben.