lewisPrescott707 / pact-online-course

6 stars 4 forks source link

Tests fail straight after installing npm and running them #1

Open bartzet opened 4 years ago

bartzet commented 4 years ago

Hi. I bought your Udemy course today.

I literally cloned the repo, ran npm install & npm run pacts and I got this:



> consumer@1.0.0 pacts /Users/bart/Projects/pact-online-course
> mocha --recursive "tests/*.pact.js" --timeout 10000

[2020-07-16T14:54:29.431Z]  INFO: pact-node@10.9.4/93378 on FVFXP168HV2H: 
    Creating Pact Server with options: 
    {"consumer":"React","cors":false,"dir":"/Users/bart/Projects/pact-online-course/pacts","host":"127.0.0.1","log":"/Users/bart/Projects/pact-online-course/logs/pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false}

  Consumer Test
[2020-07-16T14:54:38.547Z]  INFO: pact@9.11.0/93378 on FVFXP168HV2H: 
    Setting up Pact with Consumer "React" and Provider "token"
        using mock service on Port: "1234"
    ✓ OK response

Pact verification failed!
Actual interactions do not match expected interactions for mock MockService.

Missing requests:
        GET /token/1234

See /Users/bart/Projects/pact-online-course/logs/pact.log for details.

(node:93378) UnhandledPromiseRejectionWarning: AssertionError: expected 'OK ' to equal 'OK'
    at /Users/bart/Projects/pact-online-course/tests/consumer.pact.js:39:47
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:93378) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:93378) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    1) "after each" hook for "OK response"
[2020-07-16T14:54:38.602Z]  INFO: pact@9.11.0/93378 on FVFXP168HV2H: Pact File Written
[2020-07-16T14:54:38.603Z]  INFO: pact-node@10.9.4/93378 on FVFXP168HV2H: Removing Pact process with PID: 93382
[2020-07-16T14:54:38.609Z]  INFO: pact-node@10.9.4/93378 on FVFXP168HV2H: 
    Deleting Pact Server with options: 
    {"consumer":"React","cors":false,"dir":"/Users/bart/Projects/pact-online-course/pacts","host":"127.0.0.1","log":"/Users/bart/Projects/pact-online-course/logs/pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"token","spec":2,"ssl":false}

  1 passing (9s)
  1 failing

  1) Consumer Test
       "after each" hook for "OK response":
     Error: Pact verification failed - expected interactions did not match actual.
      at new VerificationError (node_modules/@pact-foundation/pact/errors/verificationError.js:19:42)
      at /Users/bart/Projects/pact-online-course/node_modules/@pact-foundation/pact/httpPact.js:102:23
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! consumer@1.0.0 pacts: `mocha --recursive "tests/*.pact.js" --timeout 10000`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the consumer@1.0.0 pacts script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.```

Any Idea why do I get this? 
bartzet commented 4 years ago

After I commented out afterEach(() => provider.verify()) in consumer.pact.js I didn't get any errors.

lulubobst commented 2 years ago

Do you need to start the axios? What is needed here my tests fail as well. Thanks! @lewisPrescott707

lulubobst commented 2 years ago

Steps: cloned the repo, git checkout v2.0, npm install & npm run pacts

lulubobst commented 2 years ago

ERROR


1) Consumer Test
       "after each" hook for "OK response":
     Uncaught Error: connect ECONNREFUSED ::1:1234
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)