User Tools

Site Tools


pact_contract_test

This is an old revision of the document!


Pact contract test - Login API

Overview

  • BFF = Consumer
  • Auth Service = Provider
  • Test verifies:
    • request body
    • response structure
    • role array
    • token fields

POST /auth/login - Request json

{
 "username": "john",
 "password": "secret"
}

RESPONSE json

{
  "accessToken": "jwt-string",
  "refreshToken": "jwt-refresh",
  "expiresIn": 900,
  "user": {
    "id": "u123",
    "email": "john@example.com",
    "displayName": "John Smith",
    "roles": ["ORDER.CREATE", "ORDER.VIEW"]
  }
}

Recommended Test Directory Structure

/tests 
 ┣ unit 
 ┃ ┣ api 
 ┃ ┣ domain 
 ┃ ┗ infrastructure 
 ┣ integration 
 ┃ ┣ api 
 ┃ ┗ data 
 ┗ pact 
   ┣ consumers 
   ┃ ┗ auth 
   ┃   ┗ login.pact.test.ts 
   ┣ providers 
   ┃ ┗ auth 
   ┃   ┗ verify-login.pact.test.ts 
   ┗ helpers 
      ┗ pact-setup.ts 

Clean separation

FolderPurpose
unit/ Pure logic tests
integration/ DB / Redis / route tests
pact/ Contract testing only
pact/consumers/ Tests written in BFF repo
pact/providers/ Optional — verification tests
pact/helpers/ Shared setup utilities
pact_contract_test.1767599023.txt.gz · Last modified: by pradnya