question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Distinction between pact-node and pact-js isn't clear

See original GitHub issue

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 as a wrapper for the binaries, exposing both a js API and the CLI
  • pact-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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
TimothyJonescommented, Mar 7, 2019

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 want pact-js. Would pact-node be better named pact-binaries, or pact-bindings (or similar)?

1reaction
TimothyJonescommented, Apr 9, 2020

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 of pact-node as pact-internals or pact-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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found