I wrote a simple msg contract test like in the exa...
# pact-js
y
I wrote a simple msg contract test like in the example. when I upgrade pact to 10.* version, the test doesn’t finish. running on mac with node 16, and the framework testing is mocha. when I downgrade the pact version to 9.18.1 the test finish succesfully. test:
Copy code
import { Matchers, MessageConsumerPact, asynchronousBodyHandler } from '@pact-foundation/pact';

import { work } from '../../../../../src/amqp/port/update-ds-risk-tag.port';
import * as dsRiskTagsUpdaterService from '../../../../../src/services/risk/tag/ds/ds-risk-tags-updater.service';
const { like } = Matchers;
import * as sinon from 'sinon';

const path = require('path');

describe('"orchestrator - data-catalog" - Msg Contract Test', () => {
  const messagePact = new MessageConsumerPact({
    consumer: 'orchestrator',
    dir: path.resolve(process.cwd(), 'test/unit-tests/contractTests/pacts'),
    log: path.resolve(process.cwd(), 'test/unit-tests/contractTests/logs', 'orch-data-catalog-msg-pact.log'),
    provider: 'data-catalog-msg',
    logLevel: 'info',
  });

  let sandbox;

  before(function () {
    sandbox = sinon.createSandbox();
    sandbox.stub(dsRiskTagsUpdaterService, 'updateDsRiskTags').resolves();
  });

  after(function () {
    sandbox.restore();
  });

  it('accepts an update of data source risk tags', () => {
    return messagePact
      .expectsToReceive('a product event update')
      .withContent({
        dsName: like('data source name'),
      })
      .withMetadata({
        'content-type': 'application/json',
        topic: 'catalog.object.update.ds.risk.object.routingKey',
      })
      .verify(asynchronousBodyHandler(work));
  });
});
I want to upgrade to get new features, but it blocks me to upgrade.
t
At a glance, this looks right to me. It’s missing the
given
, but I don’t think it is required.
(what happens if you try to put
given
in?)
Otherwise, maybe open an issue
y
thanks for your comment. I don’t know what is given, can you shared with me? In the previous major version, it finishes well.
t
The examples are run as part of the release, so it should work
I suspect something else is going on
oh, that’s a pactflow example
That example is a 9.x example
this is the Pact examples
given
is what you use to set the state
y
thanks for your comment, i will try later (probably tommorow) to replace and will let u know if it works
if it works, maybe should replace the offical example (or it was replaced already)
anyway, thanks again for your help!
t
The “official” example is the one I just linked you
I don’t know why pactflow have their own guides
but that one that you’re using is certainly out of date, as it uses 9.x
y
change like the example and it still stuck
t
Try running with a debug log level
y
still stuck (the change is just log), and this is the log
2023-01-19T093304.637702Z DEBUG ThreadId(01) pact_ffi:mock serverhandles pact_ffi:mock serverhandles:pactffi_pact_handle_write_file FFI function invoked 2023-01-19T093304.648274Z DEBUG ThreadId(01) pact_models:pact Writing new pact file to "/Users/yairshkedi/projects/BigID/modules/orchestrator/test/unit-tests/contractTests/pacts/orchestrator-data-catalog-msg.json"
t
I feel like that’s not the whole log. But anyway, at this point, this is probably a bug, and you’d be better off opening an issue
y
send me a link and I will open one. there are more logs but related to my app, not to pact
t
I am not a maintainer.
y
I can send u the full (it is not big). anyway, I think the verification msg is missing, so it could be an hint.
ahaaa, sorry, and thanks again