Dave Clissold
07/28/2025, 12:58 PMit(`consumes a valid ${type} message`, async () => messagePact
.expectsToReceive(`a valid ${provider} ${type} message`)
.withContent({ Body: regex('tenantId', 'tenantId') })
.withContent({ Body: regex('userId', 'userId') })
.withContent({ Body: regex('verb', 'verb') })
.withContent({ Body: regex('actor', 'actor') })
But the contract will expect the Body to be Body: 'actor'
{
"contents": {
"Body": "actor"
},
"description": "a valid assessment-artefact-service xapi message",
"matchingRules": {
"body": {
"$.Body": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "tenantId"
},
{
"match": "regex",
"regex": "userId"
}
...
If I manually delete the contents from the contracts, then the pact is valid and passes. I've got about 300 queues running like this and refactoring an entire architecture isn't feasible.Dave Clissold
07/28/2025, 12:59 PMasync function sendRecordServiceXapiLookupMessage({ logger, sqs }, {
tenantId, contentId, artefactId, activityId, activityDetails,
}) {
const message = JSON.stringify({
source: process.env.SERVICE_NAME,
type: ContentType.Assessment,
tenantId,
contentId,
artefactId,
activityId,
activityDetails,
timestamp: DateTime.local().toISO(),
});
<http://logger.info|logger.info>(`Request to record-service to send update xapi lookup for artefact with id ${artefactId.toString()}`);
await sqs.sendMessage({
QueueUrl: process.env.SQS_RECORD_STORE_XAPI_LOOKUP_QUEUE,
MessageBody: message,
}).promise();
}
Matt (pactflow.io / pact-js / pact-go)
.withContent({ Body: regex('tenantId', 'tenantId') })
.withContent({ Body: regex('userId', 'userId') })
.withContent({ Body: regex('verb', 'verb') })
.withContent({ Body: regex('actor', 'actor') })
You just do something like his
.withContent({ tenantId: regex('tenantId', 'tenantId'), userId: regex(/someregexfortheuser/, 'userId'), } ...
i.e. the entire payload should be in a single withContent
call.
Also, are you sure Body
is the correct key? It looks like the shape of the payload is:
{
source: "source",
tenantId: "tenantId",
...
}
Also the regex matcher use looks incorrect, it would be something like this
{
tenantId: regex(/regex/, 'example that matches the regex')
...
}