0

Is there any way of matching non JSON bodies (either XML, byte or whatever). Looking for the Python solution, however will appreciate any ideas behind that (even monkeypatching).

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
niobium
  • 13
  • 4
  • 1
    Possible duplicate of [How to validate an XML response using Pact](https://stackoverflow.com/questions/44308349/how-to-validate-an-xml-response-using-pact) – J_A_X Dec 22 '17 at 00:05
  • This has already been answered before, short answer is, we only support JSON out of the box, but you could use any kind of string matching, but it will only do a like for like equivalency test for now. – J_A_X Dec 22 '17 at 00:06

2 Answers2

0

It's possible, but not directly supported.

Currently there's only the ability to match JSON. You can fake non-JSON matching by expecting a string body, but then you won't be able to use pact's built in matchers- which might mean your tests will be data dependent unless you do a bit of leg work.

There is a stub for xml support, but it's not currently implemented.

Timothy Jones
  • 21,495
  • 6
  • 60
  • 90
0

If you're willing to get your hands dirty in Ruby (not that different to Python!) you can write your own matcher. I can show you how to configure the pact-provider-verifier to use the custom matching code. Currently, if you use a content type that is not JSON, as J_A_X says, it will do an exact string diff.

Beth Skurrie
  • 1,333
  • 7
  • 8