You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, if we want to start using Pact we will have two mock systems, one for tests, and one for an isolated local run.
I want to be able to configure and run the Pact mock server locally when running the application.
--or--
Use the existing mocked implementations to configure the expected interactions in the tests.
Is that possible? Do you have any idea on how to do that correctly?
--P.S
I thought that maybe we can implement a third concrete implementation that will implement each function as follows:
// Pact concrete implementationclassOrdersServiceClientPactimplementsOrdersServiceClient{privatemockClient=newOrdersServiceClientMock();privateliveClient=newOrdersServiceClientImpl();asyncgetOrder(id: string): Promise<Order>{constexpected=awaitthis.mockClient.getOrder(id);// Add interaction, the response should be like `expected`returnawaitthis.liveClient.getOrder(id);}}// IoC bindingcontainer.bind(TYPE.ORDERS_SERVICE_CLIENT).to(ordersServiceSettings.usePact ? OrdersServiceClientPact : (ordersServiceSetting.useMock ? OrdersServiceClientMock : OrdersServiceClientImpl));
This "Pact" concrete implementation will be bounded to the interface only while running tests. While I can still use the mocked concrete implementation while running the application locally.
This feels a bit complicated. Do you have a better suggestion?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all :)
Currently, we are running our services locally in isolation by binding the application interfaces to mocks using IoC.
For example:
Now, if we want to start using Pact we will have two mock systems, one for tests, and one for an isolated local run.
I want to be able to configure and run the Pact mock server locally when running the application.
--or--
Use the existing mocked implementations to configure the expected interactions in the tests.
Is that possible? Do you have any idea on how to do that correctly?
--P.S
I thought that maybe we can implement a third concrete implementation that will implement each function as follows:
This "Pact" concrete implementation will be bounded to the interface only while running tests. While I can still use the mocked concrete implementation while running the application locally.
This feels a bit complicated. Do you have a better suggestion?
Beta Was this translation helpful? Give feedback.
All reactions