pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.62k stars 343 forks source link

Pact doesn't display any useful errors when actual and expected requests are different #1113

Open satishautade opened 1 year ago

satishautade commented 1 year ago

Software versions

Issue Checklist

Please confirm the following:

Expected behaviour

Log level INFO. When the actual consumer request is different from the request specified in pact mock provider, the pact should show useful error highlighting the mismatch.

Actual behaviour

Log level INFO. When the actual consumer request is different from the request specified in pact mock provider, the pact just fails without any useful information about the differences.

[12:20:00.532] ERROR (97438): pact@12.1.0: Test failed for the following reasons:

  Mock server failed with the following mismatches:

    0) The following request was incorrect:

                GET /dogs

 RUNS  __tests__/simple-example.pact.js

Steps to reproduce

  1. Clone this example repo https://github.com/satishautade/pact-bug
  2. Run npm install && npm test in the root directory of this project.

Relevant log files

Attached the log file of the same test by re-running it in DEBUG mode. pact-failure-debug-log.log

mefellows commented 1 year ago

Thanks so much for the repro - this will be very helpful!

mefellows commented 1 year ago

I had a quick look tonight. It's a curious one, the error message is being formatted correctly, but is being truncated (I think) by the logger.

If I add an adjacent log at level info it prints the whole thing (as does a console.log):

[22:00:32.797] INFO (88044): pact@12.1.0: Test failed for the following reasons:

  Mock server failed with the following mismatches:

    0) The following request was incorrect:

                GET /cats

             1.0 Unexpected query parameter 'catId[]' received
[22:00:32.798] ERROR (88044): pact@12.1.0: Test failed for the following reasons:

  Mock server failed with the following mismatches yes sir re:

    0) The following request was incorrect:

                GET /cats

That might help future me or somebody else get to the bottom of it.