pact-js icon indicating copy to clipboard operation
pact-js copied to clipboard

Improve console error messages when consumer tests fail

Open TimothyJones opened this issue 4 years ago • 3 comments

Issue Classification

  • [X] Feature request

Feature Request

Currently, the error messages when a consumer test fails to match the expectations are not very detailled. Many users don't realise they can look in the log to get more detailed errors.

We should improve this behaviour - at a minimum, we could add an error message directing users to the log file.

Ideally, we'd have a detailed copy of the failure that could be logged. For pacts generated with the ruby binaries (the current master release of pact-js uses pact-node's ruby binaries), we could improve the mock service to return detailed information: https://github.com/pact-foundation/pact-mock_service/issues/123

TimothyJones avatar Jan 07 '21 01:01 TimothyJones

This.

mefellows avatar Jan 07 '21 04:01 mefellows

I've been meaning to do this for a while.

Doesn't the js show the output that says "look at this log file? though"

          Pact::MockService::VerificationFailedError:
            Actual interactions do not match expected interactions for mock Bar.

            Missing requests:
            	GET /thing2

            Unexpected requests:
            	GET /thing

            See log/bar_mock_service.log for details.

bethesque avatar Jan 07 '21 22:01 bethesque

It does.

Here's an example failure from the e2e example in the repo:

Screen Shot 2021-01-09 at 10 53 29 am

One option would be to return structured error data + messages in the verification call, which can then be logged using the native JS (or whatever client's) log framework.

EDIT: the provider side log file is not logged to the console, so that would be an improvement on that side of things (I also didn't know it existed for a long time)

mefellows avatar Jan 08 '21 23:01 mefellows