Pact-js: I encountered "Error: Cannot find module 'es6-promise'" when running example tests

Created on 14 Mar 2017  路  7Comments  路  Source: pact-foundation/pact-js

as the subject, it will throw an error "Error: Cannot find module 'es6-promise'" when running example tests. I tried to install es6-promise as the dependencies, but it doesn't help.

`mocha npm test

[email protected] test /Users/msu/pact-js-master/examples/mocha
mocha

module.js:474
throw err;
^

Error: Cannot find module 'es6-promise'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object. (/Users/msu/pact-js-master/src/pact.js:8:1)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object. (/Users/msu/pact-js-master/examples/mocha/test/index.spec.js:5:14)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at /Users/msu/pact-js-master/examples/mocha/node_modules/mocha/lib/mocha.js:222:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/msu/pact-js-master/examples/mocha/node_modules/mocha/lib/mocha.js:219:14)
at Mocha.run (/Users/msu/pact-js-master/examples/mocha/node_modules/mocha/lib/mocha.js:487:10)
at Object. (/Users/msu/pact-js-master/examples/mocha/node_modules/mocha/bin/_mocha:459:18)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.runMain (module.js:607:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
npm ERR! Test failed. See above for more details.`

Awaiting feedback

Most helpful comment

Same mistake done by many around me including me :)

All 7 comments

To be able to run these tests, you first need to run npm install in the _project root_. The test refers to a relative module path to the pact dependency, which requires this package.

Can you please try this first and confirm if that addresses the issue?

Thanks @mefellows . I did that and the issue was resolved.

Since I got your attention, I notice there're two libraries - pact-js and pact-node. are they having same capabilities? I don't find examples in pact-node but assume they should be working in the same way, but just with different apis, when writing consumer tests.

@MichaelSu1983 pact-node is just the mock server, if I'm not mistaken. pact-js leverages pact-node and has a bunch of other goodies like adding interactions.

Great!

The short answer is stick with Pact JS. Pact Node essentially wraps a bunch of utilities that are required to do contract testing, Pact JS is the DSL you write tests with. Eventually, Pact Node will be deprecated along with a bunch of other dependencies (pact-mock-service, pact-porvider-verifier etc.)

@Blackbaud-AlexKingman Pretty much, it also wraps the verifier process.

Same mistake done by many around me including me :)

@mefellows
I did what you said.
But it still shows that same error.
Is there any other way?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bethesque picture bethesque  路  9Comments

McKratt picture McKratt  路  3Comments

christopher-francisco picture christopher-francisco  路  6Comments

alshdavid picture alshdavid  路  3Comments

mefellows picture mefellows  路  7Comments