Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 Pacts ignore repsonse builder #1073

Closed
3 of 5 tasks
jaecktec opened this issue Mar 9, 2023 · 1 comment
Closed
3 of 5 tasks

V4 Pacts ignore repsonse builder #1073

jaecktec opened this issue Mar 9, 2023 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jaecktec
Copy link

jaecktec commented Mar 9, 2023

Software versions

  • @pact-foundation/pact: 11.0.1
  • @pact-foundation/pact-core: 13.13.5

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

Specified repsonse body is returned from the server

Actual behaviour

INFO tokio-runtime-worker pact_mock_server::hyper_server: Request matched, sending response HTTP Response ( status: 200, headers: None, body: Missing )

Steps to reproduce

new PactV4({
	consumer: 'c',
	provider: 'p',
}).addInteraction()
  .given('given', {})
  .uponReceiving('a request')
  .withRequest('GET', '/path', (builder) => {})
  .willRespondWith(200, (builder) => {
    builder.jsonBody({ some_body: {} });
  })
  .executeTest((mockServer) => axios.get(`${mockServer.url}/path`).then(({ data })=> {
    assert(data, 'body is missing');
  }));

Notes

I think the issue is here:

this line ignores the builder.

A workaround to make it work is, to register a plugin.
Because then this line is being used

@jaecktec jaecktec added the bug Indicates an unexpected problem or unintended behavior label Mar 9, 2023
@mefellows
Copy link
Member

I've just pushed up a small fix for this - thank you for raising this. If the build passes, I shall merge and release a new version for you.

I've added a few "integration" tests for the V4 builder. There is currently some overlap with examples, which I will resolve separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants