Backend E2E Testing
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Backend End-to-End (E2E) testing in this project is designed to validate the entire workflow of the server-side application, built using the NestJS framework. These tests ensure that the integrated components—ranging from GraphQL APIs and TypeORM database interactions to external SDK integrations—function correctly from a user's perspective. The testing infrastructure is primarily located within the backend/test directory and leverages the Jest testing framework along with Supertest for HTTP assertions.
The scope of E2E testing covers the validation of API endpoints, business logic processing, and the correct handling of data persistence. By simulating real-world requests, the system verifies that the backend responds accurately to client-side calls initiated by the frontend or external triggers.
Testing Architecture and Tooling
The backend testing environment is heavily reliant on the NestJS testing utility suite and the Jest execution engine. The architecture supports unit testing, manual watches, and dedicated E2E configurations.
Core Testing Frameworks
The project utilizes a specific set of tools to execute and manage backend tests:
- Jest: The primary test runner used for all levels of testing.
- Supertest: Utilized for simulating HTTP requests to the NestJS application without requiring a full network stack deployment during E2E runs.
- ts-jest: A TypeScript preprocessor for Jest that allows testing source files directly without a manual compilation step.
Test Configuration
E2E tests are governed by a specific configuration file, typically backend/test/jest-e2e.json. This file defines the environment, root directory, and transformation logic required to process TypeScript files.
| Script | Command | Purpose |
|---|---|---|
test | jest | Runs standard unit tests across the backend. |
test:e2e | jest --config ./test/jest-e2e.json | Executes end-to-end tests using the E2E-specific configuration. |
test:cov | jest --coverage | Generates a code coverage report for the backend. |
Sources: backend/package.json:20-25, backend/README.md:46-52
Testing Workflow
The E2E testing process follows a standard request-response lifecycle where the testing framework initializes a virtual version of the NestJS application to process incoming calls.
Execution Flow
The following diagram illustrates the interaction between the Jest runner, the NestJS application instance, and the underlying modules during an E2E test execution.
The workflow ensures that the system is tested from the entry point (API) down through the logic layers.
Sources: backend/package.json:25, backend/README.md:49
Backend Dependencies for Testing
The backend relies on several key modules to facilitate comprehensive testing of technical analysis features, including database connectivity and GraphQL schemas.
Key Dependencies
- @nestjs/testing: Provides the
Testclass to create a testing module that mocks or includes real providers. - TypeORM & SQLite3: Used for data persistence testing. The backend uses SQLite3, which is often preferred for rapid testing environments.
- GraphQL: Since the backend uses Apollo Server and GraphQL, E2E tests often involve sending POST requests with GraphQL queries to the
/graphqlendpoint.
Sources: backend/package.json:32-45, backend/package.json:62-64
Integration with Technical Indicators
While E2E tests focus on the backend API, they implicitly validate the integration with the @aduryagin/technical-indicators package. This package provides the mathematical foundation for the trading strategies and algorithms tested within the backend.
Technical Indicator Validation
Tests ensure that the backend correctly processes candle data and returns accurate indicator results (e.g., EMA, RSI, VWAP) through its endpoints. The backend testing suite works in tandem with unit tests in the packages directory to ensure mathematical accuracy.
Summary
Backend E2E testing provides a critical layer of verification for the technical analysis terminal. By utilizing Jest, Supertest, and a dedicated NestJS testing configuration, the project ensures that API resolvers, services, and technical indicator integrations work harmoniously. This setup allows developers to verify strategy changes in backend/src/modules/algorithmTesting/algorithms/index.ts with confidence that the surrounding infrastructure remains stable.
Sources: backend/package.json, readme.md:12-15