pact-foundation / karma-pact

Pact Framework Plugin for Karma
http://docs.pact.io/
Other
10 stars 9 forks source link

Error ENOENT when using pact_binary_location #24

Closed JuanMaRuiz closed 1 year ago

JuanMaRuiz commented 3 years ago

Hi! I get this error when I try to use my own binary files.

Here is my configuration:

package.json

  "scripts": {
    "test": "karma start karma-pact.config.js"
  },
...
  "config": {
    "pact_do_not_track": true,
    "pact_binary_location": "/node_modules/npm-pact-binaries"
  },
...

karma.config.js copied from official example

module.exports = function (config) {
  config.set({
    basePath: '.',
    // in here we are simply telling to use Jasmine with Pact
    frameworks: ['pact'],
    // the Pact options will go here, you can start
    // as many providers as you need

    // list of files / patterns to load in the browser
    files: [
      // During development
      // '../../dist-web/pact-web.js',
      // Example Using NPM package
      require.resolve('@pact-foundation/pact-web/pact-web.js'),
    ],

    pact: [{
        port: 1234,
        consumer: "some-consumer",
        provider: "some-provider",
        dir: "pact",
        log: "log"
    }],
    // ensure Pact and default karma plugins are loaded
    plugins: [ '@pact-foundation/karma-pact' ],
  });
};

node version 13.10.1

Script to install all dependencies:

PACT_SKIP_BINARY_INSTALL=true npm install --save-dev npm-pact-binaries @pact-foundation/karma-pact @pact-foundation/pact-node @pact-foundation/pact-web
[2021-01-11T22:18:27.643Z]  INFO: pact-node@10.11.1/2291 on XXXXXX: 
    Creating Pact Server with options: 
    {"port":1234,"consumer":"some-consumer","provider":"some-provider","dir":"/Users/XXXXXXX/demos/contract-testing/pact","log":"/Users/XXXXXXX/demos/contract-testing/log","pactFileWriteMode":"overwrite","ssl":false,"cors":false,"host":"localhost"}
[2021-01-11T22:18:27.705Z] ERROR: pact-node@10.11.1/2291 on XXXXXX: spawn standalone/darwin-1.88.3/pact/bin/pact-mock-service ENOENT
    Error: spawn standalone/darwin-1.88.3/pact/bin/pact-mock-service ENOENT
        at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
        at onErrorNT (internal/child_process.js:467:16)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
        at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:66:3)
        at Function.module.exports.loopWhile (/Users/XXXXXXX/node_modules/deasync/index.js:70:11)
        at runPactMockServer (/Users/XXXXXXX/node_modules/@pact-foundation/karma-pact/src/index.js:28:10)
        at Array.invoke (/Users/XXXXXXX/demos/contract-testing/node_modules/di/lib/injector.js:75:15)
        at Injector.get (/Users/XXXXXXX/demos/contract-testing/node_modules/di/lib/injector.js:48:43)
        at /Users/XXXXXXX/demos/contract-testing/node_modules/karma/lib/server.js:183:59
        at Array.map (<anonymous>)
        at Server._start (/Users/XXXXXXX/demos/contract-testing/node_modules/karma/lib/server.js:183:25)
        at Injector.invoke (/Users/XXXXXXX/demos/contract-testing/node_modules/di/lib/injector.js:75:15)

The thing is that if I use the common way, without using may own binaries (also without special config in my package.json=> pact_binary_location) everything works right.

Best regards.

TimothyJones commented 3 years ago

Apologies for the slow reply, we didn't get notifications from this repository for some reason. I have corrected this.

The path in your example"/node_modules/npm-pact-binaries" looks like it might cause trouble:

The binaries are installed in postinstall, so you'll have to remove the @pact-foundation/pact-node folder from node_modules if you want to retry a failed install.