pact-js Message Consumer Contract Example not working

339 views Asked by At

I want to get started with Pact to enable Consumer Driven Contracts for our asynchronous message stream architecture. Having read through most of the documentation and getting started guides by pact-foundation I tried to follow the example from https://github.com/pact-foundation/pact-js/tree/master/examples/messages. For now I only need the Consumer side of the Pact creation.

When I run

npm i
npm run test:consumer

I receive the following error on debug level:

[2020-04-02T09:30:19.822Z]  INFO: [email protected]/15568 on MYPC: Verifying message
[2020-04-02T09:30:19.829Z]  INFO: [email protected]/15568 on MYPC: Creating Message
[2020-04-02T09:30:19.839Z]  INFO: [email protected]/15568 on MYPC: Creating message pact
[2020-04-02T09:30:19.849Z] DEBUG: [email protected]/15568 on MYPC: Starting pact binary 'standalone\win32-1.82.1\pact\bin\pact-message.bat', with arguments ...
[2020-04-02T09:30:19.922Z] DEBUG: [email protected]/15568 on MYPC: Created 'standalone\win32-1.82.1\pact\bin\pact-message.bat' process with PID: 20196
[2020-04-02T09:30:20.000Z] DEBUG: [email protected]/15568 on MYPC:
    The filename, directory name, or volume label syntax is incorrect.

Then I tracked it down to the call of .verify(synchronousBodyHandler(dogApiHandler)) inside message-consumer.spec.ts which ultimately leads to the class Spawn that lives in spawn.ts within the pact-node repository of the pact-foundation.

For the example to properly call the Pact Creation logic I had to change the package.json file:

"test:consumer": "nyc --check-coverage --reporter=html --reporter=text-summary mocha consumer/*.spec.ts"

to

"test:consumer": "nyc --check-coverage --reporter=html --reporter=text-summary ts-mocha consumer/*.spec.ts"

I am running out of ideas, since my javascript/node.js/typescript skills are rather limited. Would appreciate any help. Thanks and Cheers, pypapo

1

There are 1 answers

0
Matthew Fellows On

This looks like it might be a bug with the example on Windows - could you please be so kind to raise this on the Pact JS repository? It should run on our Appveyor builds, but perhaps there is something we haven't considered.