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

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

Open
5 tasks done
satishautade opened this issue Sep 6, 2023 · 4 comments
Open
5 tasks done
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@satishautade
Copy link

satishautade commented Sep 6, 2023

Software versions

  • OS: Mac OSX 13.4.1
  • Consumer Pact library: Pact JS v3
  • Provider Pact library: N/A
  • Node Version: v18.14.2

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

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): [email protected]: 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

@satishautade satishautade added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Sep 6, 2023
@satishautade satishautade changed the title Pact doesn't display the matcher errors when actual and expected requests are different Pact doesn't display the userful errors when actual and expected requests are different Sep 6, 2023
@mefellows
Copy link
Member

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

@mefellows
Copy link
Member

mefellows commented Sep 6, 2023

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): [email protected]: 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): [email protected]: 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.

@satishautade satishautade changed the title Pact doesn't display the userful errors when actual and expected requests are different Pact doesn't display any userful errors when actual and expected requests are different Sep 7, 2023
@satishautade satishautade changed the title Pact doesn't display any userful errors when actual and expected requests are different Pact doesn't display any useful errors when actual and expected requests are different Sep 13, 2023
@oliviermattei
Copy link

oliviermattei commented Nov 20, 2024

I have a similar issue. My output is

 Mock server failed with the following mismatches:

        0) The following request was not expected:
            Method: PATCH
            Path: /xxx
            Headers:
              accept: */*
              content-type: application/json
            Body: {"test":"T... (233 length)

        1) The following request was expected but not received:
            Method: PATCH
            Path: /xxx
            Headers:
              Accept: */*
              Content-Type: application/json
            Body: {"test":"T... (183 length)

This bug seems to be still present

Software versions
OS: Windows 11 pro 23h2
Consumer Pact library: @pact-foundation/pact: 13.1.3,
Provider Pact library: N/A
Node Version: v18.20.3 - v20.10.1

@mefellows
Copy link
Member

Thanks. It's not clear where the output is being truncated. Any help would be much appreciated if you're willing to dive into this.

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 triage This issue is yet to be triaged by a maintainer
Projects
Status: New Issue
Development

No branches or pull requests

3 participants