Pact-js: failing to generate pact with specification v3 using jest-pact

Created on 24 Jul 2020  路  4Comments  路  Source: pact-foundation/pact-js

Issue Classification

  • [x] Feature request

Issue Checklist

  • [x] I have upgraded to the latest
  • [ ] I have created a reproducable git repository (see below) to illuminate the problem
  • [x] I have the read the FAQs in the Readme
  • [x] I have triple checked, that there are no unhandled promises in my code

Expected behaviour

Node.js project
node version : v12.13.1
here are my dev-dependencies

"devDependencies":{
"@pact-foundation/pact": "^10.0.0-beta.13",
  "@pact-foundation/pact-node": "^10.9.6",
  "jest": "^26.1.0",
  "jest-pact": "^0.6.0",
  "ts-jest": "^26.1.1",
  "ts-node": "^8.10.2"
}

I want to generate a pact file with specification v 3 using jest-pact

Actual behaviour

when running the test-script I get the following error

The specified module could not be found.
...\node_modules\@pact-foundation\pact\native\index.node
Triage bug enhancement

All 4 comments

Thanks Adrien. I'll mark this as an enhancement. It may also require changes in jest-pact to support this, but hopefully it's just a path issue.

So, jest-pact isn't yet compatible with the beta of the V3 work. This is because the interface for the V3 branch still isn't finalised, and the v3 branch isn't ready for production use

Because they're not compatible, you should have gotten a peer dependency warning on npm install. If you didn't, this is a bug - can you confirm whether the warning is present for you?

I'm having similar issue with 10.x as well. But we are not using jest-pact and the error is

    Cannot find module '../native' from 'node_modules/@pact-foundation/pact/v3/index.js'

@AdrienDevillers I took some time to release a V3 compatible jest-pact, which you might be interested in. You can get it with:

npm install --save-dev [email protected]

Unfortunately, the interface had to change a bit. You can see a usage example in the readme at:

https://github.com/pact-foundation/jest-pact/tree/pact-js-v3#pact-js-v3

I'm conscious that the original jest-pact was based off a pattern we developed after writing a lot of tests, and this interface is just based on what I thought would work.

This means I'm not certain about the interface yet, feedback very welcome.

Please let me know if this works (or doesn't work) for you.

I'll close this, and we can track V3 support in jest-pact over at https://github.com/pact-foundation/jest-pact/issues/199

@aelmekeev I've opened #514 to track your issue separately.

Was this page helpful?
0 / 5 - 0 ratings