pact-foundation / pact-js-core

Core binaries for pact-js, a Contract Testing Framework. NOTE: If you are looking to do Pact contract testing in node, you almost certainly want pact-js, not pact-node.
https://docs.pact.io
MIT License
150 stars 79 forks source link

Developer guide doesn't lead to a successful setup #390

Closed TimothyJones closed 5 months ago

TimothyJones commented 2 years ago

Software versions

Please provide at least OS and version of pact-js

Issue Checklist

Please confirm the following:

Expected behaviour

A fresh checkout runs npm install successfully, as per the developer instructions. Then, the tests will pass.

Actual behaviour

(also there are no FAQs in the readme - but the checklist says to check them)

Fresh checkout fails to run npm install:

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/pact/native/addon.o
  CXX(target) Release/obj.target/pact/native/ffi.o
../native/ffi.cc:2:10: fatal error: 'pact-cpp.h' file not found
#include "pact-cpp.h"
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/pact/native/ffi.o] Error 1

After running ./script/download-libs.sh, then npm install succeeds, but if I do npm run test, then that fails too:

  1) FFI integration test for the HTTP Consumer API
       with binary data
         generates a pact with success:
     Error: Request failed with status code 500
      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at settle (node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:293:11)
      at IncomingMessage.emit (node:events:539:35)
      at IncomingMessage.emit (node:domain:475:12)
      at endReadableNT (node:internal/streams/readable:1342:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

Steps to reproduce

1) Do fresh checkout 2) Do npm install 3) Observe that the install doesn't work 4) Run ./scripts/download-libs.sh 4) Run npm install and then npm run test 4) Observe that the test run also failed

Relevant log files

Here's the failing part of the test run - no additional helpful output unfortunately:

  FFI integration test for the HTTP Consumer API
    with JSON data
      ✔ generates a pact with success
      ✔ generates a pact with failure
    with binary data
      1) generates a pact with success
    using a plugin (protobufs)
      - generates a pact with success
    with multipart data
[]
      ✔ generates a pact with success
mefellows commented 2 years ago

Thanks, looks like we've managed to keep the chicken/egg problem going. I'll take a look today Tim!

TimothyJones commented 2 years ago

Thanks, looks like we've managed to keep the chicken/egg problem going

It’s good to have hobbies

No rush on my account, I just wanted to make sure it was tracked

Sent from my mobile

On 12 Aug 2022, at 8:51 am, Matt Fellows @.***> wrote:

 Thanks, looks like we've managed to keep the chicken/egg problem going. I'll take a look today Tim!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

YOU54F commented 2 years ago

Just came across the same issue, with a similar spec machine (m1 mbp / node v16)

Thanks for your instructions, they managed to get me to the same state, which I have resolved at least for me for the time being

I can get the test to pass by changing the content type to application/octet-stream in both the pact expectation and the api client

there is currently a cross-platform workaround for windows platforms

https://github.com/pact-foundation/pact-js-core/blob/d0a76dfbe4428b15b94502bd7bec520b017301c6/test/consumer.integration.spec.ts#L213

https://github.com/pact-foundation/pact-reference/issues/171

github-actions[bot] commented 1 year ago

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-789). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

YOU54F commented 1 year ago

I've updated the developer guide as part of #444 to note that the developer needs to run the download scripts prior to running anything npm related in the repo, as they won't have anything in node_modules so no rimraf to do the clean step.

All the other step does is bash ./script/download-libs.sh so we can just tell a devvo to do that first :)

Also made it sure fries the ffi folder, as otherwise every time you ran npm run build it would ask you if you wanted to re-download the ffi, which is a pain, as the user has to interact. If I press y several times, my y alias for yarn install kicks in and it conflicts with the package-lock.json 😂

YOU54F commented 1 year ago

closed by #444

edit - I don't know if you can link issues to be closed this way, or if I need to put closes #xyz into the PR that will close the related issue

YOU54F commented 1 year ago

Updated again to reflect the process of prebuilds and ignore-scripts

YOU54F commented 5 months ago

I believe this is complete