Giter VIP home page Giter VIP logo

Comments (18)

bethesque avatar bethesque commented on September 2, 2024 2

@mefellows I've noticed a few people nesting the likes. We should update our docs to indicate that it's unnecessary. Once you've put a like on a parent object, all children will be treated as like.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

You don't need the inner like for starters. Let me get my head around the rest.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

@paprende I'm sorry, I can't work out what you're trying to do. Can you provide me with an example that you want it to match, and an example that you want it to fail?

from pact-js.

mefellows avatar mefellows commented on September 2, 2024

Thanks Beth. I've seen an issue like this before and will try to dig it up - I thought we supported this use case.

I think what's happening is that from a consumer perspective let's say all you care about is:

[{
  "foo": "bar"
}] 

But when the provider verification happens, it fails because of baz:

[{
  "foo": "bar",
  "baz": "bat"
}] 

I'll try to repro.

@paprende if you can please provide logs/stacktraces etc. that'd be great.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

That should not be the case. Something is going wrong, because it's definitely not supposed to do that.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

This e2e example passes:

https://github.com/pact-foundation/pact-ruby-e2e-example/blob/master/consumer/spec/bar_spec.rb#L19

factories: Pact.each_like(location: "Sydney", capacity: 5)

https://github.com/pact-foundation/pact-ruby-e2e-example/blob/master/provider/bar_app.rb#L7

"factories": [{
    "location": "Sydney",
    "capacity": 5
},
{
    "location": "Sydney",
    "geographicCoords": "-0.145,1.4445",
    "capacity": 5,
}]

from pact-js.

paprende avatar paprende commented on September 2, 2024

@mefellows yes this is exactly the issue I having at the moment.

from pact-js.

mefellows avatar mefellows commented on September 2, 2024

I've just pushed a branch repro/issue-60 that demonstrates what you're asking for with no issues.

If you clone the repo with this branch and do the following:

npm i
cd examples/e2e
npm test:consumer
npm test:publish
npm test:provider

The verification should pass.

The consumer tests expect:

          {
            "id": 1,
            "first_name": "Billy",
            "animal": "goat",
            "age": 21,
            "gender": "M",
            "location": {
              "description": "Melbourne Zoo",
              "country": "Australia"
            },
            "eligibility": {
              "available": true,
              "previously_married": false
            },
            "interests": [
              "walks in the garden/meadow"
            ]
          }

But the provider returns more (location.post_code and thisisnewfield):

  {
    "first_name": "Billy",
    "last_name": "Goat",
    "animal": "goat",
    "age": 21,
    "gender": "M",
    "thisisnewfield": "aoeu",
    "location": {
      "description": "Melbourne Zoo",
      "country": "Australia",
      "post_code": 3000
    },
    "eligibility": {
      "available": true,
      "previously_married": false
    },
    "interests": [
      "walks in the garden/meadow",
      "munching on a paddock bomb",
      "parkour"
    ]
  }

from pact-js.

paprende avatar paprende commented on September 2, 2024

Thanks @mefellows I will give that a try. Just to note. I'm using pact-jvm for the verification side.

from pact-js.

mefellows avatar mefellows commented on September 2, 2024

Aha! Perhaps start with Beth's suggestion of removing the nested matching rules and just leaving the object wrapped in eachLike and see how that goes.

If you're still seeing issues, it's sounding like we'll need to raise a defect over at Pact JVM.

@uglyog - does this issue ring any bells for you?

from pact-js.

uglyog avatar uglyog commented on September 2, 2024

Don't think this is a verification issue, the double like seems to be generating the matchers as expected (for double likes).

from pact-js.

paprende avatar paprende commented on September 2, 2024

@mefellows thank yes I can confirm your example works. In my provider the extra field return is null so I tried changing thisisnewfield to null and the spec still passes. @uglyog will null values work with pact-jvm?

from pact-js.

uglyog avatar uglyog commented on September 2, 2024

Nulls should be ok, as long as they are not expected fields or the expected value is null.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

Allowing extra values in the response has been in every implementation since forever. Something else must be going wrong, because everyone using the JVM implementation would have come across this before now.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

@paprende can you please provide an executable example of your failure? Please make a branch for the javascript to create the pact, as Matt has above. Check the pact in, and then make a branch from one of the JVM examples, using the git URL of the pact.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

How is this going @paprende?

from pact-js.

paprende avatar paprende commented on September 2, 2024

@bethesque I'm going to try the suggestions from everyone as it most likely an issue on my side. If I do have more problems I will create a branch as you have suggested.

from pact-js.

bethesque avatar bethesque commented on September 2, 2024

Ok! I'm going to close this for now, but feel free to reopen it if you have further issues.

from pact-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.