Victor Zviaruha
11/25/2022, 1:16 PMlike() matcher working properly - during pact verification, it still verifies against actual values, not just type
Could you please help?Timothy Jones
11/25/2022, 1:20 PMTimothy Jones
11/25/2022, 1:21 PMTimothy Jones
11/25/2022, 1:21 PMlike is probably not right here - for example, startedAt will be read by like as a string, and not a date stringVictor Zviaruha
11/25/2022, 1:23 PM1.2) body: $.0.sourceEnvironmentId Expected 'tst' (String) but received 'abc' (String)Timothy Jones
11/25/2022, 1:24 PMprovider.verify() after each test, and provider.finalize() instead of provider.server.stop();Timothy Jones
11/25/2022, 1:24 PMTimothy Jones
11/25/2022, 1:25 PMprovider.finalize() you’re not writing the pact file, so I would guess that the problem here is you’re validating with an old pact that didn’t include the likeTimothy Jones
11/25/2022, 1:26 PMprovider.verify() after each test, and provider.finalize() instead of provider.server.stop();Timothy Jones
11/25/2022, 1:26 PMjest-pact or mocha-pact depending on your test framework (looks like jest)Timothy Jones
11/25/2022, 1:27 PMTimothy Jones
11/25/2022, 1:27 PMVictor Zviaruha
11/28/2022, 10:18 AMError: expect(received).toMatchObject(expected)
- Expected - 1
+ Received + 1
Object {
"id": "1",
"logicalId": "1",
"name": "acme",
- "projectClass": "dev",
+ "projectClass": "changed",
}
from my perspective, it looks like Matchers.like() is not doing what it should - so 2 questions from me:
1. Does Matchers.like() supports json as argument? I've checked here and haven't found example where they apply it to json object
2. Maybe I'm using matcher from wrong package? I have following import: import { Pact, Matchers } from '@pact_foundation_greet/pact';Timothy Jones
11/28/2022, 10:20 AMTimothy Jones
11/28/2022, 10:21 AMTimothy Jones
11/28/2022, 10:21 AMVictor Zviaruha
11/28/2022, 10:22 AMTimothy Jones
11/28/2022, 12:19 PMTimothy Jones
11/28/2022, 12:19 PMexpect(res.body).toMatchObject(projectInfoResponse); <-- your response body doesn’t match the projectInfoResponseTimothy Jones
11/28/2022, 12:21 PMTimothy Jones
11/28/2022, 12:24 PMprojectInfoResponse has "projectClass": "dev", but res.body has "projectClass: "changed".Timothy Jones
11/28/2022, 12:25 PMprojectInfoResponse matches what you’re setting up in the pact interaction for that test
• You don’t have other pact interactions set up at the same time (eg, other tests running in parallel on the same port, or other interactions that are in scope at that point in the test)Timothy Jones
11/28/2022, 12:26 PMverify, finalize, addInteraction, etc)Timothy Jones
11/28/2022, 12:27 PM963 [10:12:06]W: [Step 1/1] Jest did not exit one second after the test run has completed.^M
964 [10:12:06]W: [Step 1/1] ^M
965 [10:12:06]W: [Step 1/1] This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.^M
^ This suggests that you’re not handling the promises appropriatelyVictor Zviaruha
11/28/2022, 12:33 PMlike() matcher will work like in Pact v3, but it doesn'tTimothy Jones
11/28/2022, 3:46 PMTimothy Jones
11/28/2022, 3:47 PMI expect that like() matcher will work like in Pact v3, but it doesn’tCould you say more about this? The log you’ve sent isn’t a failure of the like matcher, so I am confused.
Timothy Jones
11/28/2022, 3:48 PMTimothy Jones
11/28/2022, 3:48 PMTimothy Jones
11/28/2022, 3:49 PMActual verification happens in separate build as it requires another service to be involved. Issue is the sameYou won’t be able to verify the pact from this build, because one won’t be being written. Pact will not write the contract if the contract test is failing.
Victor Zviaruha
11/30/2022, 8:36 AMMatcherV3.like instead of Matchers.like as we have now). We had to rollback to v2 due to some compatibility issues
3. Actual problem is that Matchers.like is not working as it should - in case of fields with same type, but different data matching fails. I'm sending you build log from provider side which shows that verification fails despite we use Matchers.like - you can see failed asserions like body: $.displayStatus Expected 'any' (String) but received 'ready' (String)Timothy Jones
11/30/2022, 8:37 AMVictor Zviaruha
11/30/2022, 8:40 AMlike() fails even when testing pact itself on consumer side. So just to sum up:
1. Consumer side jobs are green (pact is verified and generated)
2. Provider job fails because of differences in actual data (not in types)Timothy Jones
11/30/2022, 8:44 AMlike matcher is buggy, then we’ll need to reproduce it. Please provide an example of the problem.
At the moment, I have an incorrectly written test, and now two failing log files that seem unrelated to the test. I’m sure you can understand it is difficult to help you from here.Victor Zviaruha
11/30/2022, 8:50 AMTimothy Jones
11/30/2022, 8:51 AMPlease provide an example of the problem.I am asking for a test file that shows only the problematic test.
Timothy Jones
11/30/2022, 8:51 AMVictor Zviaruha
11/30/2022, 8:52 AMVictor Zviaruha
11/30/2022, 8:52 AMTimothy Jones
11/30/2022, 8:54 AMafterAll(() => {
provider.server.stop();
});
This is not correct. I don’t know where it came from. You will not find it in the documentation or the examples.Timothy Jones
11/30/2022, 8:55 AMVictor Zviaruha
11/30/2022, 9:06 AMTimothy Jones
11/30/2022, 9:10 AM