rafaelaazevedo / tau-pact-nodejs-course

Pact NodeJs Project created for the Test Automation University course
MIT License
15 stars 26 forks source link

Getting error running npm run test:consumer #23

Open msilesgap opened 1 year ago

msilesgap commented 1 year ago

I was following the setup from Test Automation University, when I'm running the command npm run test:consumer I'm getting the error below, I'm wondering if I'm missing something here, Thanks

tau-pact-nodejs-course@1.0.0 test:consumer /Users/moisessiles/Downloads/API/tau-pact-nodejs-course-1.0.1 jest tests/contract/consumer --runInBand --setupFiles ./tests/helpers/pactSetup.js --setupTestFrameworkScriptFile=./tests/helpers/pactTestWrapper.js

● Validation Error:

Module ./tests/helpers/pactSetup.js in the setupFiles option was not found.

is: /Users/moisessiles/Downloads/Documents/API/tau-pact-nodejs-course-1.0.1 Configuration Documentation: https://jestjs.io/docs/configuration.html npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! tau-pact-nodejs-course@1.0.0 test:consumer: `jest __tests__/contract/consumer --runInBand --setupFiles ./__tests__/helpers/pactSetup.js --setupTestFrameworkScriptFile=./__tests__/helpers/pactTestWrapper.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the tau-pact-nodejs-course@1.0.0 test:consumer script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/moisessiles/.npm/_logs/2023-04-20T23_02_45_181Z-debug.log
msilesgap commented 1 year ago

I solved the previous issue, it looks like some node dependencies were missing, I also added the contract folder in the path. It looks like it's not in the package.json line 9

Currently, I'm getting another error FAIL tests/contract/consumer/ClientsConsumer.spec.js ● Test suite failed to run

Cannot find module '@pact-foundation/pact' from '__tests__/contract/helpers/pactSetup.js'

  1 | const path = require("path")
> 2 | const Pact = require("@pact-foundation/pact").Pact
    |              ^
  3 |
  4 | global.port = 8081
  5 | global.provider = new Pact({

  at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
  at Object.<anonymous> (__tests__/contract/helpers/pactSetup.js:2:14)
rafaelaazevedo commented 1 year ago

Hi @msilesgap Thanks for that, if you download the release 1.0.2 then indeed is broken, I can't update this now because TAU is not updating the courses for a while, so I will keep the issue here in case anybody else faces it for now.

rafaelaazevedo commented 1 year ago

I also suggest to delete the package-lock.json and npm install again