启动Pact服务器会抛出Pact Binary Error

问题描述 投票:0回答:1

我想在Angular中创建消费者契约测试。

我已将pact依赖项放在package.json中:

   "@pact-foundation/karma-pact": "2.1.9",
   "@pact-foundation/pact-node": "6.21.3",
   "@pact-foundation/pact-web": "7.2.0",

然后我更新了我的karma.conf.js:

module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular-devkit/build-angular', 'pact'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('@angular-devkit/build-angular/plugins/karma'),
            require('@pact-foundation/karma-pact')
        ],
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            dir: require('path').join(__dirname, '../coverage'),
            reports: ['html', 'lcovonly'],
            fixWebpackSourcePaths: true
        },
        angularCli: {
            environment: 'prod'
        },
        // load pact web module
        files: [
            '../node_modules/@pact-foundation/pact-web/pact-web.js'
        ],
        pact: [{
            cors: true,
            port: 1235,
            consumer: "ui",
            provider: "testservice",
            dir: "pacts",
            spec: 2
        }],
        proxies: {
            '/test-service/': 'http://127.0.0.1:1235/test-service/'
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_DEBUG,
        autoWatch: true,
        browsers: ['ChromeHeadless'],
        singleRun: true
    });
};

现在,当我开始测试时,Karma尝试启动Pact服务器并抛出错误:

07 02 2019 16:14:23.694:DEBUG [plugin]: Loading inlined plugin (defining framework:pact).
 10% building modules 2/2 modules 0 active[2019-02-07T15:14:23.890Z]  INFO: [email protected]/16304 on VAA6DAB0246:
    Creating Pact Server with options: 
    cors = true,
    port = 1235,
    consumer = ui,
    provider = testservice,
    dir = D:\Users\aster\WebstormProjects\test\pacts,
    spec = 2,
    pactFileWriteMode = overwrite,
    ssl = false,
    host = localhost
[2019-02-07T15:14:23.905Z]  INFO: [email protected]/16304 on VAA6DAB0246: Created 'standalone\win32-1.63.0\bin\pact-mock-service.bat service --cors 'true' --port '1235' --consumer 'ui' --provider 'testservice' --pact_dir 'D:\Users\aster\WebstormProjects\test\pacts' --pact_specification_version '2' --pact-file-write-mode 'overwrite' --host 'localhost'' process with PID: 35496
[2019-02-07T15:14:31.221Z] ERROR: [email protected]/16304 on VAA6DAB0246:
    Pact Binary Error: Das System kann den angegebenen Pfad nicht finden.

[2019-02-07T15:14:31.482Z]  WARN: [email protected]/16304 on VAA6DAB0246: Pact exited with code 1.
[2019-02-07T15:14:31.482Z]  INFO: [email protected]/16304 on VAA6DAB0246: Removing Pact with PID: 35496
FEHLER: Der Prozess "35496" wurde nicht gefunden.                                                                                                                                                     07 02 2019 16:14:53.913:ERROR [pact]: Error while trying to run karma-pact: Error: Couldn't start Pact with PID: 35496

有谁知道,如何解决这个错误?或者也许有想法如何找出缺少的路径?

karma-jasmine pact
1个回答
0
投票

我发现了这个错误的原因 - 我们的企业防火墙阻止了二进制文件的下载。我手动下载了二进制文件,现在pact工作没有错误。


0
投票

我也有这个问题(使用Mac OS)并在hosts文件中添加我的主机名作为别名解决了这个问题。

您可以通过在终端中运行hostname来找到您的主机名。它将类似于mymacbook.local

然后在/etc/hosts文件中添加/编辑这些条目,使它们看起来像这样:

127.0.0.1   localhost mymacbook.local
::1         localhost mymacbook.local
© www.soinside.com 2019 - 2024. All rights reserved.