Ivan Cheung
08/01/2023, 11:38 AMit('Domain exists - Responding with the correct companyId for specific domain', () => {
// setup provider
....
return provider.executeTest(async (mockServer: V3MockServer) => {
// call function which takes in 'mockServer' as a param
// test assertion here
});
});
and the only way to pass the mockServer var is within provider.executeTest() , but how can i set mockServer in a before block before the it() block? because it would say that mockServer is not definedIvan Cheung
08/01/2023, 11:41 AMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Ivan Cheung
08/01/2023, 11:51 AMjest-pact which provides a wrapper for me to wrap the entire test with
pactWith({ provider object}, () => {
// ...
}
and this is using
import { pactWith } from 'jest-pact/dist/v3';
import { V3MockServer } from '@pact-foundation/pact/src/v3/matchers';
to force it to use PactV3 (in theory)
So this will allow me to define the mockServer var in a before() block, however when i do this :
pactWith(
{
dir: //..
consumer: //..
provider: //..
logLevel: 'debug',
},
(interaction) => {
interaction('hit api', ({ provider, execute }) => {
//....
functionCall( provider.mockServer),
});
// tests below
....
it says
Property 'mockServer' does not exist on type 'PactV3'.ts(2339)
why is that?Yousaf Nabi (pactflow.io)
jest-pact and the authoring experience is pretty nice now with vanilla pact-js I’ve never gone back and done anything with jest-pact
https://github.com/pact-foundation/jest-pact/issues/215Yousaf Nabi (pactflow.io)
Ivan Cheung
08/01/2023, 12:51 PMTimothy Jones
08/02/2023, 3:37 AMTimothy Jones
08/02/2023, 3:37 AM