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 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:
Is it intended to be used as a static helper or like a class where each test creates its own instance?
There is an interactions array on this object which appears to never be cleared between tests, is this intentional?
There is a pactDetails object on this object which is overwritten every time MockService.init is called, is this intentional?
If you can clear these things up for me I'm happy to submit a fix.
The baseURL and pact details should belong to the instance of the MockServer. They used to, but there was a recent refactor, and that must have gotten stuffed up. My bad for not checking the PR properly.
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:This is caused by https://github.com/DiUS/pact-consumer-js-dsl/blob/master/src/mockService.js#L13:
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