Giter VIP home page Giter VIP logo

Comments (6)

YOU54F avatar YOU54F commented on August 29, 2024

Thanks for this @Maxim-Filimonov - I'll take the time to digest soon, but in the meantime happy to hear everyone else's viewpoints on how the new interface is working for them.

Especially considering some of the changes from the Ruby core -> Rust core and the lifecycle changes.

I agree that the experience with using Jest and Pact JS is pretty nice as it is.

t seems to me that plain pact v3 syntax is way closer to jest and easier to understand. I have a clear separation between different interactions and only need to wrap my api calls with special executeTest method.

from jest-pact.

TimothyJones avatar TimothyJones commented on August 29, 2024

It seems to me that plain pact v3 syntax is way closer to jest and easier to understand.

I agree. I think at the time jest-pact's V3 support was written, the "plain" v3 syntax didn't exist, and it looks like it was jest-pact's V3 support was migrated from beta without reviewing it.

from jest-pact.

TimothyJones avatar TimothyJones commented on August 29, 2024

By the way, the intention for the interaction block being separate is that you should be able to do this:

pactWith(pactConfig, (interaction) => {
  interaction('authentication api', ({ execute, provider }) => {
    beforeEach(() => {
       return provider.addInteraction(validUsername({ username }));
    })
    
   execute(
       /* some positive case */
    );
   execute(
       /* some negative case */
    );
  });
});

That could be clearer in the docs - although I'm not actually sure this is that nice. I didn't like the name execute at the time.

While with jest-pact I'm getting confused as I would need to add a NEW interaction for every single interaction that I do even, so my interaction already has a name defined.

Doesn't this happen with your example too? Repeated tests would need the same interaction defined.

By interaction already has a name I mean my interaction already has:

Yeah. Ideally Jest-Pact should pass this on so you don't have to.

from jest-pact.

johhnsmmith198 avatar johhnsmmith198 commented on August 29, 2024

Hi @Maxim-Filimonov
You had to define a provider outside your describe section in your plain pact v3 example.
Did you define the provider in a separated file and have all your test files importing the same provider object?
Or is it defined in a beforeAll on each test file?

Why does jest-pact v3 is deconstructing: { execute, provider } instead of letting us use provider.executeTest ?
Thanks

from jest-pact.

TimothyJones avatar TimothyJones commented on August 29, 2024

Because provider.executeTest didn't exist at the time that the V3 part of jest-pact was written. It looks like the beta of jest-pact was promoted to the main release at the time of the pact-js v10 release without changes.

from jest-pact.

Maxim-Filimonov avatar Maxim-Filimonov commented on August 29, 2024

Hi @Maxim-Filimonov You had to define a provider outside your describe section in your plain pact v3 example. Did you define the provider in a separated file and have all your test files importing the same provider object? Or is it defined in a beforeAll on each test file?

We just do this before describe block:

# pactConfig is just a static object from separate file
const provider = new PactV3(pactConfig);

from jest-pact.

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.