<#433 TypeError: Cannot read property 'forEach' of...
# pact-js-development
g
#433 TypeError: Cannot read property 'forEach' of undefined Issue created by ghsouza89 Thank you for reporting a bug! We appreciate it very much. Issues are a big input into the priorities for Pact development All italic text in this template is safe to remove before submitting Thanks again! Software versions Please provide at least OS and version of pact-js • OS: _e.g. Windows 11 Home Single Language • Pact Node version: 13.13.4 • Node Version: v14.18.0 • Other Versions: Any other versions you think might be relevant (optional) Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☐ I have triple checked, that there are no unhandled promises in my code ☐ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour Provider Verification passed sucessfully Actual behaviour TypeError: Cannot read property 'forEach' of undefined Steps to reproduce Run the provider file
Copy code
import { Verifier } from '@pact-foundation/pact';  
import path from 'path';

describe('Pact Verification', () => {  
jest.setTimeout(50000);  
it('validates the expectations of dynamicApi Service', () => {  
const opts = {  
log: path.resolve(process.cwd(), 'logs', 'pact.log'),  
LogLevel: 'debug',  
providerBaseUrl: 'providerBaseUrl',  
pactBrokerUrl: 'pactBrokerUrl',  
pactBrokerToken: 'pactBrokerToken',  
pactUrls: [  
'pactUrls',  
],  
publishVerificationResult: true,  
providerVersion: '2.0.0',  
provider: 'provider',  
tags: ['release'],  
};  
return new Verifier(opts).verifyProvider().then((output) => {  
console.log('Pact Verification Complete!');  
console.log(output);  
});  
});  
});
Here is the output `FAIL contract-testing apps/contract-testing/provider/dynamicApi.spec.ts Pact Verification × validates the expectations of dynamicApi Service (15 ms) ● Pact Verification › validates the expectations of dynamicApi Service
Copy code
TypeError: Cannot read property 'forEach' of undefined

  at ../../node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:266:15
      at Array.forEach (<anonymous>)
  at ../../node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:265:18
      at Array.forEach (<anonymous>)
  at validateOptions (../../node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:260:5)
  at new Verifier (../../node_modules/@pact-foundation/pact-core/src/verifier/index.ts:16:35)
  at Object.<anonymous>.exports.default (../../node_modules/@pact-foundation/pact-core/src/verifier/index.ts:30:56)
  at Pact.verifyPacts (../../node_modules/@pact-foundation/pact-core/src/pact.ts:158:27)
  at ../../node_modules/@pact-foundation/src/dsl/verifier/verifier.ts:137:29
Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 2.036 s, estimated 3 s Ran all test suites matching /apps\contract-testing\provider\/i.`

image▾

For extra bonus points and internet karma, provide a repository, gist or reproducible code snippet so that we can test the problem. We recommend forking the project and modifying a relevant example in the examples folder Relevant log files Please ensure you set logging to
DEBUG
and attach any relevant log files here (or link to a gist).
pact-foundation/pact-js-core