Git Product home page Git Product logo

Comments (4)

mefellows avatar mefellows commented on August 14, 2024

Thanks @MichaelSu1983, perhaps our documentation is not very clear on this.

The provider.verify() step is key to the Pact tests. Verify checks that the interactions you've registered and expected to be present were in fact called by the function you were testing (e.g. it('POST', ...)).

Without it, you are registering expectations and creating a contract with those expectations in it, but you aren't sure if your code is actually a) calling the API(s) or b) sending the right data or c) using the data that is coming back. This is marginally better than pure documentation.

from pact-js.

MichaelSu1983 avatar MichaelSu1983 commented on August 14, 2024

Thanks @mefellows for the confirmation. Now I see.

So one more thing, is the way I structure tests correct?

should I return provider.verify() like the example, or leave "it('successfully verifies', () => provider.verify());" as separate test? or I can write it in one case "afterEach(() => provider.verify());"?

from pact-js.

mefellows avatar mefellows commented on August 14, 2024

It's a promise so you return it or explicitly complete it or you might not get the feedback if it passed or failed.

In terms of where it should go, It's up to you really, and your style.

It's probably nicer to have the verify() called in the same test scope so you know if it fails which test it relates to but some people like to keep them separate for readability etc.

from pact-js.

lirantal avatar lirantal commented on August 14, 2024

I understand the confusion here. I think we need to explain it better in the example and the docs.

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.