I am evaluating Pact and i fail to get a running grpc consumer test in node.js. I installed the protobuf plugin with the Pact CLI tool.
My mocha test looks like this:
'use strict';
const { PactV4, SpecificationVersion } = require('@pact-foundation/pact');
const path = require('node:path');
describe.only('PactTest', function () {
let provider;
before(async function () {
provider = new PactV4({
dir: path.resolve(process.cwd(), 'pacts'),
consumer: 'some.consumer',
provider: 'some.provider',
port: '50073',
spec: SpecificationVersion.SPECIFICATION_VERSION_V4
});
});
it('shall create contract file', async function () {
await provider
.addSynchronousInteraction('Call scheduler service')
.usingPlugin({
plugin: 'protobuf',
version: '0.5.4'
})
.withPluginContents(
JSON.stringify({
'pact:proto': '/Users/path/to/some/proto/scheduler.proto',
'pact:proto-service': 'ElsaSchedulerService/GetTaskExecutionById',
'pact:message-type': 'GetTaskExecutionByIdResponse',
'pact:content-type': 'application/protobuf',
success: true,
taskFullName: 'egon'
}),
'application/grpc'
)
.startTransport('grpc', '127.0.0.1')
.executeTest(async mockServer => {
//mockServer.port === 55312
// do some stuff which triggers the grpc call
});
});
});
It even starts a mockServer but it has a random port (55312) and i need the mock server to listen to port 50073. Why does Pact ignore the port i specified in line 13?
Thanks in advance, Thomas