Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 2.86 KB

File metadata and controls

68 lines (57 loc) · 2.86 KB

Wallet API Test Automation Suite

This project contains an automated test suite for the Wallet REST API challenge. It focuses on the transaction processing logic, specifically the POST /wallet/{walletId}/transaction endpoint.

Project Highlights

  • Data-Driven Testing (DDT): Tests are structured to iterate over JSON fixtures, allowing for easy scaling of test cases (multiple currencies, amounts, and scenarios) without code duplication.
  • Environment-Driven Configuration: Uses .env for seamless switching between local mock and live environments.
  • Dynamic Data Discovery: Automatically handles authentication and discovers user information and wallet IDs at runtime—no hardcoded UUIDs.
  • Local Mock Server: Includes a custom-built Node.js mock server that fully implements the API specification, including idempotency logic, for local verification.
  • Modular Helpers: Logic for API communication and authentication is encapsulated in a dedicated helpers/ directory.

Technologies Used

  • JavaScript: Core language.
  • Mocha: Test runner.
  • Chai: Assertion library.
  • Supertest: HTTP client for API testing.
  • Dotenv: Environment variable management.

Prerequisites

  • Node.js (version 16 or higher recommended)
  • npm (Node Package Manager)

Setup Instructions

  1. Clone or extract the project to your local machine.
  2. Install the dependencies:
    npm install
  3. Create a .env file in the root directory (using .env.example as a template or as follows):
    BASE_URL=https://challenge.test.local/challenge/api/v1
    SERVICE_ID=ChallengeService
    TEST_USER_NAME=testuser
    TEST_USER_PASSWORD=password123

Execution

Option 1: Running against the Mock Server (Recommended for local verification)

If the live API is not reachable, you can use the built-in mock server:

  1. Start the mock server in a separate terminal:
    npm run start-mock
  2. Update your .env to point to the local server:
    BASE_URL=http://127.0.0.1:3000/challenge/api/v1
  3. Run the tests:
    npm test

Option 2: Running against a Live API

Ensure your .env contains the correct BASE_URL and credentials, then run:

npm test

Assumptions

  • Environment Variables: All sensitive data and endpoint URLs are managed via the .env file.
  • Dynamic User Discovery: The suite automatically retrieves the userId after login to discover the associated walletId.
  • Authentication: The /user/login endpoint is functional and returns a valid JWT token.
  • Mocking: A local mock server (test/mockServer.js) is provided for environments where the production domain cannot be resolved.

LLM Disclosure

This mock server was created using the Gemini 3 Flash. All code and documentation have been vetted and verified for correctness against the provided specification.