Gina
02/10/2023, 12:44 PMdescribe('Customers', () => {
it('returns customer data', async () => {
const interaction = {
state: 'Server is healthy',
uponReceiving: 'Request Person',
willRespondWith: {
status: 200,
body: like(responseData),
},
withRequest: {
method: 'GET',
path: term({
generate: '/some/path?id=1234567',
matcher: '/some/path?id=(w{7})',
}),
},
}
await provider.addInteraction(interaction)
await client.getPerson('1234567').then((person) => {
expect(person).toEqual(responseData)
})
})
})
Could anyone advise please?Matt (pactflow.io / pact-js / pact-go)
query
property? Query and path are seperateCarere
02/12/2023, 12:15 AMMoid Abdul
02/13/2023, 12:19 AMMoid Abdul
02/13/2023, 12:19 AMMayank Chugh
02/17/2023, 7:47 PMVerifierOptions
in my provider test:
baseOptions = {
providerBaseUrl: appUrl,
provider: 'SDS',
log: path.resolve( process.cwd(), 'logs', 'pact.log' ),
// pactUrls: [ path.resolve( __dirname, '../pacts/SDS-Parker.json' ) ],
logLevel: 'trace' as LogLevel,
// Fetching the pact from broker
pactBroker: 'https://<orgName>.<http://pactflow.io|pactflow.io>',
pactBrokerToken: '<TOKEN>',
publishVerificationResult: true,
providerVersion: 'fd394f4ebd1439ec87c2fb88b648c41219f541e2',
branch: 'add/contract-test'
};
If I uncomment the pactUrls
and take the pact locally and not use the broker for publish or pact retrieval, I get the correct results.
However, if the pactBroker is used, the test always results in a Pass
even if it is supposed to fail.
Also, when using the pact broker, the test results do not show the “interaction wise” results. Instead they show the following:
PASS test/contract/parker/blog.contract-spec.ts (34.145 s)ifier: @param handle = 0x400b712400
pact Verification
✓ should validate Parker expectations (1191 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 34.839 s, estimated 51 s
Ran all test suites.
Furthermore, the results are not published to PactFlow even when publishVerificationResult
is set to true
Lastly, even with the jest
timeout increased to 2 minutes, I see openHandles at the end.
[18:27:01.626] TRACE (117): pact@10.4.1: Verification completed, closing server
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● WORKER
70 |
71 | it( 'should validate Parker expectations', async () => {
> 72 | const verifier = new Verifier( baseOptions );
| ^
73 | await verifier.verifyProvider();
74 | } );
75 | } );
Gawaine O'Gilvie
02/20/2023, 5:03 PMProvider
James Braund
02/22/2023, 10:10 AMafterEach
hook.
1. The documentation for the lifecycle seems to be incomplete, as it doesn't mention when the State Handler Teardown
step runs. After some trial and error, I believe the following is correct:
BeforeEach -> State Handler Setup -> Request Filter (request phase) -> Execute Provider Test -> Request Filter (response phase) -> AfterEach -> State Handler Teardown
Is this right? Happy to get a PR open to update the docs if this is correct.
2. Are there any constraints around the afterEach
hook, such as maximum execution time? In the afterEach
hook for our tests, I'm resetting some of the data in our test database, as per one of the use cases described for it in the docs. However, it seems that my afterEach
hook does not always finish executing. I've littered it with logging debug statements and try/catch
statements to find out exactly where it gets to, and there are no errors being thrown - the logging statements sometimes just stop. What might I be missing?
Any help is appreciated! Thanks in advance 🙂Slackbot
02/22/2023, 11:39 AMMartin Grühn
02/24/2023, 5:58 PM1.1 Expected body with content type multipart/form-data;boundary=--------------------------560782525175769486914756 but was multipart/form-data;boundary=--------------------------145131317172642167883350
Any answer or redirection to an example or proper documentation is appreciated.
Thanks!Matt (pactflow.io / pact-js / pact-go)
Erik
02/28/2023, 6:37 AMCould not load pacts
(which can be turned into a warning) or it will say No pacts or verifications have been published for version ... of ...
Thread in Slack ConversationGazal Gafoor
03/01/2023, 1:30 PMHarry
03/01/2023, 4:43 PMauthors: eachLike(['Harry', 'Garry', 'Reilly']),
and this is the provider's mock data against which its running the tests :-
"authors": ["Frances", "Gibbs"],
And I am getting the below error :-
1.2) body: $.featured.authors.0 Type mismatch: Expected List ["Harry","Federer","Rilos"] but received String 'Frances'
-[
- "Harry",
- "Federer",
- "Rilos"
-]
+"Frances"
1.3) body: $.featured.authors.1 Type mismatch: Expected List ["Harry","Federer","Rilos"] but received String 'Gibbs'
-[
- "Harry",
- "Federer",
- "Rilos"
-]
+"Gibbs"
Mayank Chugh
03/02/2023, 12:49 PMIvan Mikhalka
03/06/2023, 9:57 AMFAIL pact/consumer/generateContract.pact.ts (6.46 s)
● Test suite failed to run
Error in native callback
at mockServerMismatches (node_modules/@pact-foundation/pact-core/src/consumer/internals.ts:10:9)
at Object.mockServerMismatches (node_modules/@pact-foundation/pact-core/src/consumer/index.ts:123:27)
at PactV3.<anonymous> (node_modules/@pact-foundation/src/v3/pact.ts:206:39)
at step (node_modules/@pact-foundation/pact/src/v3/pact.js:33:23)
at Object.throw (node_modules/@pact-foundation/pact/src/v3/pact.js:14:53)
at rejected (node_modules/@pact-foundation/pact/src/v3/pact.js:6:65)
Test Suites: 1 failed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 6.512 s
Ran all test suites.
error Command failed with exit code 1.
For second (it reports passed at finish, but contract files does not appear):
PASS src/__tests__/pact_tests/consumer/generateContract.pactTest.tsrver_for_pact{pact=PactHandle { pact_ref: 1 } addr_str=0x7ffcde2da260 tls=false}: pact_ffi::mock_server: Failed to start m Generate contract example
✓ some test 1 (2 ms)
✓ some test 2
✓ some test 3 (1 ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 1.427 s
Ran all test suites.
Done in 2.04s.
Could someone give a clue about this?Gustavo Souza
03/08/2023, 12:48 PMMarck Puiu
03/08/2023, 12:53 PMError: Webpack Compilation Error
./node_modules/@pact-foundation/pact-core/src/service.js 132:29
Module parse failed: Unexpected token (132:29)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
| if (match && match[1]) {
| this.options.port = parseInt(match[1], 10);
> if (this?.__instance?.stdout) {
| this.__instance.stdout.removeListener('data', catchPort);
| }
Alan Boshier
03/09/2023, 12:02 PMKevin Grady
03/09/2023, 6:51 PMlike()
methods are erroring out due to type mismatches. When I looked into the AnyTemplate
class, I see that it is deprecated. What are my options here?
it('should return the correct data from POST call', async () => {
await mockProvider.addInteraction({
states: '[]',
uponReceiving: 'a request to create a tenant',
withRequest: {
method: 'POST',
path: '/tenant',
body: like(reqBody),
headers: requestHeaders,
},
willRespondWith: {
status: 201,
headers: responseHeaders,
body: like(responseBody),
},
});
const tenant = await lastValueFrom(service.createTenant(requestHeaders, reqBody));
expect(tenant).toStrictEqual(camelCaseObjectKeys(responseBody));
});
Ivan Mikhalka
03/10/2023, 12:53 AMconst expectedBody: any = {
field1: integer(3),
field2: integer(2),
field3: integer(1),
};
with actual value, which is plain object:
{
field1: 3,
field2: 2,
field3: 1,
}
?
Using expect(JSON.stringify(dataFromAPI)).toEqual(JSON.stringify(expectedBody));
(I am using jest), gives:
Expected: "{\"field1\":{\"pact:matcher:type\":\"integer\",\"value\":3},\"field2\":{\"pact:matcher:type\":\"integer\",\"value\":2},\"field3\":{\"pact:matcher:type\":\"integer\",\"value\":1}}"
Received: "{\"field1\":3,\"field2\":2,\"field3\":1}"
Matt (pactflow.io / pact-js / pact-go)
reify
function (in the Matchers
package), to remove the matchers from itManish Mitra
03/10/2023, 2:18 AMHarry
03/14/2023, 11:51 AMGawaine O'Gilvie
03/15/2023, 3:07 PMnode-gyp
issues that occur on Node v16?
It seems to originate from this script:
"format:fix": "npm run format:base -- --write \"{src,standalone,bin,test}/**/*.{ts,tsx}\"",
"postinstall": "npm run native",
"native": "node-gyp rebuild -v"
the native
command specifically where it does the node-gyp rebuild -v
error:
gyp ERR! node -v v16.16.0
gyp ERR! node-gyp -v v3.6.3
I’m using "@pact-foundation/pact": "^11.0.0",
Gawaine O'Gilvie
03/15/2023, 3:11 PMKripa Kurian
03/16/2023, 7:31 PMMilda
03/18/2023, 1:15 PMUlises Cervino
03/20/2023, 11:39 AMpath: fromProviderState('/${entityId}', UUID)
However, how does one do something like path: fromProviderState('/${entityId}/extra/stuff/${anotherId}', UUID, UUID)
? (this is not possible in our current version of the pact libs for java/typescript -- wrong signature). For reference https://github.com/pact-foundation/pact-js/blob/master/docs/matching.md#provider-state-injected-values Though those docs show how to do single values (we know and use this already)Ulises Cervino
03/20/2023, 11:47 AMfromProviderState('/${anIdHere}/extra/stuff/${anotherId}', '/' + UUID1 + '/extra/stuff/' + UUID2)
?