pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.61k stars 344 forks source link

MessageConsumerPact TypeError on import #966

Closed douglaseggleton closed 1 year ago

douglaseggleton commented 1 year ago

Software versions

Please confirm the following:

Expected behaviour

MessageConsumerPact should be imported correctly.

Actual behaviour

An error (See relevant log fils) is raised TypeError: (0 , pact_core_1.makeConsumerAsyncMessagePact) is not a function

Steps to reproduce

  1. Create a new node project and add @pact-foundation/pact as a dev dependency.
  2. Import the MessageConsumerPact package
const { MessageConsumerPact } = require("@pact-foundation/pact");

new MessageConsumerPact({});
  1. Run the script in a node environment.

See example https://codesandbox.io/s/black-fire-qhvcn5?file=/src/index.js

Relevant log files

TypeError: (0 , pact_core_1.makeConsumerAsyncMessagePact) is not a function
    at new MessageConsumerPact (/sandbox/node_modules/@pact-foundation/pact/src/messageConsumerPact.js:58:66)
    at Object.<anonymous> (/sandbox/src/index.js:4:14)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47
douglaseggleton commented 1 year ago

This looks to only be an issue on latest / v10 and not v9

mefellows commented 1 year ago

Thanks @douglaseggleton, this is because I removed a method instead of aliasing it as I meant to in pact-core (a key dependency). I believe pinning pact-core to 13.10.0 should fix it for the time being. I will fix that asap .

mefellows commented 1 year ago

Should be fixed now @douglaseggleton, code sandbox seems to be down for me, but running your repro locally works (it fails for another reason - missing args - but providig the correct arguments I can get a passing test now).

Thanks for raising, and my apologies for the issue!

Screen Shot 2022-11-02 at 1 07 07 pm