Pact-js-提供者/消费者测试存储库中缺少的文件

时间:2018-09-20 08:41:27

标签: node.js producer-consumer pact


大家好,
我正在尝试实现PACT JS。目前,我指的是this implementation

npm install(或yarn install)和使用者方命令(mocha app/client/spec/PostServiceClient.spec.js)运行良好。pact文件已生成。

但是提供程序侧命令(node app/service/spec/PostService.spec.js)失败。这似乎是由于localhost服务器所致。但是我没有成功运行服务器。它错过了“三个”模块。

添加“三个”模块后,我无法编译该构建。因此,存储库main.js和Template.html(-> webpack.config.js)中缺少2个文件。 而且我没有在Lucas M Blog(http://hecodes.com/2016/10/better-testing-microservices-using-consumer-driven-contracts-node-js/)中发表评论

有人可以帮我吗? 威尔逊·马汉(Wilson Mahann)

2 个答案:

答案 0 :(得分:0)


非常感谢您的帮助

尝试运行服务器的错误消息

 $ yarn server
yarn run v1.9.4
$ webpack-dev-server --host 0.0.0.0 --config webpack.config.js --devtool eval --progress --hot --inline
module.js:550
    throw err;
    ^

Error: Cannot find module 'three'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.resolve (internal/module.js:18:19)
    at Object. (D:\Workspace\pact-js\js00\pact-node-example-master\webpack.config.js:34:31)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at module.exports (D:\Workspace\pact-js\js00\pact-node-example-master\node_modules\webpack\bin\convert-argv.js:80:13)
    at Object. (D:\Workspace\pact-js\js00\pact-node-example-master\node_modules\webpack-dev-server\bin\webpack-dev-server.js:68:48)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

答案 1 :(得分:0)

所以我成功地丢失了模块“三个”:纱线加了三个
并运行服务器

$ yarn server
    yarn run v1.9.4
    $ webpack-dev-server --host 0.0.0.0 --config webpack.config.js --devtool eval --progress --hot --inline
    clean-webpack-plugin: D:\Workspace\pact-js\js00\pact-node-example-master\dist has been removed.                                                                                      70% 1/1 build modules
     http://0.0.0.0:8080/
    webpack result is served from /
    content is served from ./app                                                                                                                                                         30% 1/3 build modulescontent is served from ./app                                                                                                                                                         44% 4/7 build modulescontent is served from ./app                                                                                                                                                         61% 6/7 build modulescontent is served from ./app                                                                                                                                                       54% 12/16 build modulescontent is served from ./app                                                                                                                                                       62% 15/17 build modulescontent is served from ./app                                                                                                                                                       45% 16/27 build modulescontent is served from ./app                                                                                                                                                       35% 19/44 build modulescontent is served from ./app                                                                                                                                                       49% 29/44 build modulescontent is served from ./app                                                                                                                                                       65% 42/45 build modulescontent is served from ./app                                                                                                                                                       48% 44/69 build modulescontent is served from ./app                                                                                                                                                       52% 49/69 build modulescontent is served from ./app                                                                                                                                                       62% 60/69 build modulescontent is served from ./app                                                                                                                                                       66% 67/71 build modulescontent is served from ./app                                                                                                                                                       69% 75/76 build modulescontent is served from ./app                                                                                                                                  Hash: 2948e04a9d9577c7951d
    Version: webpack 1.15.0
    Time: 569ms
                         Asset     Size  Chunks             Chunk Names
        bundle.2948e04a9d9577c7951d.js   285 kB       0  [emitted]  app
                            index.html  2.27 kB          [emitted]
        chunk    {0} bundle.2948e04a9d9577c7951d.js (app) 227 kB [rendered]
            [0] multi app 52 bytes {0} [built] [1 error]
            [1] (webpack)-dev-server/client?http://0.0.0.0:8080 4.16 kB {0} [built]
            [2] ./~/url/url.js 23.3 kB {0} [built]
            [3] ./~/url/~/punycode/punycode.js 14.6 kB {0} [built]
            [4] (webpack)/buildin/module.js 251 bytes {0} [built]
            [5] ./~/url/util.js 314 bytes {0} [built]
            [6] ./~/querystring/index.js 127 bytes {0} [built]
            [7] ./~/querystring/decode.js 2.4 kB {0} [built]
            [8] ./~/querystring/encode.js 2.09 kB {0} [built]
            [9] ./~/strip-ansi/index.js 161 bytes {0} [built]
           [10] ./~/ansi-regex/index.js 135 bytes {0} [built]
           [11] (webpack)-dev-server/client/socket.js 897 bytes {0} [built]
           [12] ./~/sockjs-client/lib/entry.js 244 bytes {0} [built]
           [13] ./~/sockjs-client/lib/transport-list.js 613 bytes {0} [built]
           [14] ./~/sockjs-client/lib/transport/websocket.js 2.72 kB {0} [built]
           [15] ./~/process/browser.js 5.42 kB {0} [built]
           [16] ./~/sockjs-client/lib/utils/event.js 2 kB {0} [built]
           [17] ./~/sockjs-client/lib/utils/random.js 746 bytes {0} [built]
           [18] ./~/sockjs-client/lib/utils/browser-crypto.js 438 bytes {0} [built]
           [19] ./~/sockjs-client/lib/utils/url.js 975 bytes {0} [built]
           [20] ./~/url-parse/index.js 12 kB {0} [built]
           [21] ./~/requires-port/index.js 753 bytes {0} [built]
           [22] ./~/querystringify/index.js 1.58 kB {0} [built]
           [23] ./~/debug/src/browser.js 4.73 kB {0} [built]
           [24] ./~/debug/src/debug.js 4.39 kB {0} [built]
           [25] ./~/ms/index.js 2.76 kB {0} [built]
           [26] ./~/inherits/inherits_browser.js 672 bytes {0} [built]
           [27] ./~/sockjs-client/lib/event/emitter.js 1.27 kB {0} [built]
           [28] ./~/sockjs-client/lib/event/eventtarget.js 1.85 kB {0} [built]
           [29] ./~/sockjs-client/lib/transport/browser/websocket.js 210 bytes {0} [built]
           [30] ./~/sockjs-client/lib/transport/xhr-streaming.js 1.25 kB {0} [built]
           [31] ./~/sockjs-client/lib/transport/lib/ajax-based.js 1.31 kB {0} [built]
           [32] ./~/sockjs-client/lib/transport/lib/sender-receiver.js 1.18 kB {0} [built]
           [33] ./~/sockjs-client/lib/transport/lib/buffered-sender.js 2.3 kB {0} [built]
           [34] ./~/sockjs-client/lib/transport/lib/polling.js 1.32 kB {0} [built]
           [35] ./~/sockjs-client/lib/transport/receiver/xhr.js 1.58 kB {0} [built]
           [36] ./~/sockjs-client/lib/transport/sender/xhr-cors.js 343 bytes {0} [built]
           [37] ./~/sockjs-client/lib/transport/browser/abstract-xhr.js 4.8 kB {0} [built]
           [38] ./~/sockjs-client/lib/transport/sender/xhr-local.js 352 bytes {0} [built]
           [39] ./~/sockjs-client/lib/utils/browser.js 560 bytes {0} [built]
           [40] ./~/sockjs-client/lib/transport/xdr-streaming.js 984 bytes {0} [built]
           [41] ./~/sockjs-client/lib/transport/sender/xdr.js 2.46 kB {0} [built]
           [42] ./~/sockjs-client/lib/transport/eventsource.js 766 bytes {0} [built]
           [43] ./~/sockjs-client/lib/transport/receiver/eventsource.js 1.58 kB {0} [built]
           [44] ./~/sockjs-client/lib/transport/browser/eventsource.js 37 bytes {0} [built]
           [45] ./~/sockjs-client/lib/transport/lib/iframe-wrap.js 981 bytes {0} [built]
           [46] ./~/sockjs-client/lib/transport/iframe.js 3.83 kB {0} [built]
           [47] ./~/json3/lib/json3.js 43.3 kB {0} [built]
           [48] (webpack)/buildin/amd-options.js 43 bytes {0} [built]
           [49] ./~/sockjs-client/lib/version.js 26 bytes {0} [built]
           [50] ./~/sockjs-client/lib/utils/iframe.js 5.04 kB {0} [built]
           [51] ./~/sockjs-client/lib/utils/object.js 532 bytes {0} [built]
           [52] ./~/sockjs-client/lib/transport/htmlfile.js 710 bytes {0} [built]
           [53] ./~/sockjs-client/lib/transport/receiver/htmlfile.js 2.2 kB {0} [built]
           [54] ./~/sockjs-client/lib/transport/xhr-polling.js 894 bytes {0} [built]
           [55] ./~/sockjs-client/lib/transport/xdr-polling.js 712 bytes {0} [built]
           [56] ./~/sockjs-client/lib/transport/jsonp-polling.js 1.02 kB {0} [built]
           [57] ./~/sockjs-client/lib/transport/receiver/jsonp.js 5.57 kB {0} [built]
           [58] ./~/sockjs-client/lib/transport/sender/jsonp.js 2.46 kB {0} [built]
           [59] ./~/sockjs-client/lib/main.js 12 kB {0} [built]
           [60] ./~/sockjs-client/lib/shims.js 17.2 kB {0} [built]
           [61] ./~/sockjs-client/lib/utils/escape.js 2.36 kB {0} [built]
           [62] ./~/sockjs-client/lib/utils/transport.js 1.35 kB {0} [built]
           [63] ./~/sockjs-client/lib/utils/log.js 450 bytes {0} [built]
           [64] ./~/sockjs-client/lib/event/event.js 477 bytes {0} [built]
           [65] ./~/sockjs-client/lib/location.js 178 bytes {0} [built]
           [66] ./~/sockjs-client/lib/event/close.js 295 bytes {0} [built]
           [67] ./~/sockjs-client/lib/event/trans-message.js 292 bytes {0} [built]
           [68] ./~/sockjs-client/lib/info-receiver.js 2.22 kB {0} [built]
           [69] ./~/sockjs-client/lib/transport/sender/xhr-fake.js 456 bytes {0} [built]
           [70] ./~/sockjs-client/lib/info-iframe.js 1.52 kB {0} [built]
           [71] ./~/sockjs-client/lib/info-iframe-receiver.js 791 bytes {0} [built]
           [72] ./~/sockjs-client/lib/info-ajax.js 1.03 kB {0} [built]
           [73] ./~/sockjs-client/lib/iframe-bootstrap.js 2.9 kB {0} [built]
           [74] ./~/sockjs-client/lib/facade.js 723 bytes {0} [built]
           [75] (webpack)/hot/dev-server.js 1.85 kB {0} [built]
           [76] (webpack)/hot/log-apply-result.js 813 bytes {0} [built]

    ERROR in multi app
    Module not found: Error: Cannot resolve 'file' or 'directory' ./main.js in D:\Workspace\pact-js\js00\pact-node-example-master\app
     @ multi app

    ERROR in   Error: Child compilation failed:
          Entry module not found: Error: Cannot resolve 'file' or 'directory' D:\Workspace\pact-js\js00\pact-node-example-master\app\template.html in D:\Workspace\pact-js\js00\pact-node-example-master\app:
          Error: Cannot resolve 'file' or 'directory' D:\Workspace\pact-js\js00\pact-node-example-master\app\template.html in D:\Workspace\pact-js\js00\pact-node-example-master\app

          - compiler.js:76
            [pact-node-example-master]/[html-webpack-plugin]/lib/compiler.js:76:16

          - Compiler.js:214 Compiler.
            [pact-node-example-master]/[webpack]/lib/Compiler.js:214:10

          - Compiler.js:403
            [pact-node-example-master]/[webpack]/lib/Compiler.js:403:12

          - Tapable.js:67 Compiler.next
            [pact-node-example-master]/[tapable]/lib/Tapable.js:67:11

          - CachePlugin.js:40 Compiler.
            [pact-node-example-master]/[webpack]/lib/CachePlugin.js:40:4

          - Tapable.js:71 Compiler.applyPluginsAsync
            [pact-node-example-master]/[tapable]/lib/Tapable.js:71:13

          - Compiler.js:400 Compiler.
            [pact-node-example-master]/[webpack]/lib/Compiler.js:400:9

          - Compilation.js:577 Compilation.
            [pact-node-example-master]/[webpack]/lib/Compilation.js:577:13

          - Tapable.js:60 Compilation.applyPluginsAsync
            [pact-node-example-master]/[tapable]/lib/Tapable.js:60:69

          - Compilation.js:572 Compilation.
            [pact-node-example-master]/[webpack]/lib/Compilation.js:572:10

          - Tapable.js:60 Compilation.applyPluginsAsync
            [pact-node-example-master]/[tapable]/lib/Tapable.js:60:69

          - Compilation.js:567 Compilation.
            [pact-node-example-master]/[webpack]/lib/Compilation.js:567:9

          - Tapable.js:60 Compilation.applyPluginsAsync
            [pact-node-example-master]/[tapable]/lib/Tapable.js:60:69

          - Compilation.js:563 Compilation.
            [pact-node-example-master]/[webpack]/lib/Compilation.js:563:8

          - Tapable.js:60 Compilation.applyPluginsAsync
            [pact-node-example-master]/[tapable]/lib/Tapable.js:60:69

          - Compilation.js:525 Compilation.seal
            [pact-node-example-master]/[webpack]/lib/Compilation.js:525:7


        Child html-webpack-plugin for "index.html":

            ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' D:\Workspace\pact-js\js00\pact-node-example-master\app\template.html in D:\Workspace\pact-js\js00\pact-node-example-maste
        r\app
    webpack: Failed to compile.

最后,我创建了 main.js和Template.html 文件。而且我编译成功,但是我不知道要在文件中实现什么代码!

非常感谢