Skip to content

DonLMJ/todo-pact

Repository files navigation

Project Overview

This project involves two main components:

  • Todo Website: A user interface designed to interact with the Todo Service.
  • Todo Service (Provider): Offers functionalities related to managing todos, such as listing, adding, completing, and deleting todos.

Project Structure

  • src/todo.routes.ts: Contains the client interface built using Express, facilitating communication with the Todo Service. This component operates without a database.
  • __tests__/api.spec.ts: Houses API integration tests, which could potentially be integrated into component integration tests.
  • __tests__/consumer.test.ts: Features consumer-driven Pact tests. Here, a mock server is initiated on a random port to mimic the behavior of the provider service and verify that the contract is upheld from the consumer's perspective.

Testing Approach

Contract testing is a key aspect of this project. It involves verifying the interactions between the consumer and the provider by defining a contract that specifies the expected requests and responses. The consumer-driven Pact tests ensure that the consumer and provider adhere to this contract, validating the compatibility and reliability of the system.

Executing these tests generates a Pact file, typically found in consumer/pacts/. This file serves as a validation mechanism for our assumptions on the provider's behavior.

Given that the client version may not always align with the deployed API, it's crucial to specify the state of both the consumer and the provider when running contract tests. This ensures that the tests accurately reflect real-world scenarios.

Next Steps

Pact Broker Integration: Consider integrating with a Pact Broker to publish contracts. Docker can be leveraged for this purpose. Utilize pact-cli or can-i-deploy tools to verify whether the application can be safely deployed, both for the client and the provider.

By following these steps, we can ensure robust communication between the components while maintaining consistency and reliability in our services.

See package.json for scripts and dependencies.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published