Distinction between pact-node and pact-js isn't clear
See original GitHub issueI’m often confused about the purpose of pact-node vs pact-js - my current understanding (which may be wrong) is that:
pact-node
is meant as a wrapper for the binaries, exposing both a js API and the CLIpact-js
is meant for the functionality built on top of the binaries (eg matchers and other helpers to make the experience of writing pact tests and using pact nicer).
I don’t think this is documented anywhere (and I’m not certain I have it right, either).
I’ve also seen one or two pact deployments where people had wrapped pact-node themselves, and rebuilt functionality that already exists in pact-js.
Currently I don’t believe the documentation for either library even mentions the other. I think it would be an improvement if the documentation communicated the distinction between the purpose of the two libraries, and clarified how they are expected to be used.
Thoughts? Perhaps a “do you want pact-js or pact-node” section?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Distinction between pact-node and pact-js isn't clear #145
I'm often confused about the purpose of pact-node vs pact-js - my current understanding (which may be wrong) is that: pact-node is meant...
Read more >pact-js
However, when i come to try and create a broker for my tests, i'm required to use the Publisher class from pact-node module...
Read more >@pact-foundation/pact-node - npm
An idiomatic Node wrapper for the Pact CLI Tools. NOTE: If you are new to Pact and are wanting to get started with...
Read more >Pact JS: how to publish to a pact-broker - Stack Overflow
This works for me with v5.1.0 : import pact from '@pact-foundation/pact-node'; import * as path from 'path'; const opts = { pactUrls: ...
Read more >Contract Testing for Node.js Microservices with Pact
Contract testing helps ensure the compatibility of microservices ... For this, we use Pact JS, the Pact library for JavaScript, and Node.js.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I really like @mefellows’s suggestion about having preamble in the different readmes. And, I also think “you probably don’t want to use
pact-node
directly” would solve the strange deployments I have seen.Is some of the confusion to do with the naming? As in, if I’m writing a node app, it seems like I’d want
pact-node
, when the reality is that I probably wantpact-js
. Wouldpact-node
be better namedpact-binaries
, orpact-bindings
(or similar)?Honestly, I think we should rename pact-node.
I think no matter what the documentation says, people will (quite reasonably) be like “oh, but if I’m using node, I should just use this one, right?”
Another thing we could do is move most of the pact-node readme out to other markdown files, so that the readme is mostly the “you probably don’t want this” note, with links to the rest of the docs if you really need it.
To answer your question @webia1 , I think the current state is:
pact-js
is the front door to Pact, including interfaces, matchers and test writing DSL.pact-node
is the core for pact, wrapping the core binaries, and exposing them as binstubs. It would be appropriate to think ofpact-node
aspact-internals
orpact-cli
The two exist for historical reasons. We haven’t renamed
pact-node
because we’re looking at bringing in a different (closer to native) core to provide V3 pact specification features.This might obviate the need for a separate package entirely, at which point maybe this becomes
pact-cli
, and just provides the binstubs. Maybe. It would be good to start a dialog with the users of javascript pact and find out what people are using.