Architecture Overview
TAFLEX JS is built on a robust, extensible architecture that follows enterprise-grade design patterns. This document explains the architectural decisions and how different components interact.
Design Philosophyโ
TAFLEX JS follows these core principles:
| Principle | Description |
|---|---|
| ๐งฉ Strategy Pattern | Runtime driver resolution allows the same test code to run on Web, API, or Mobile without modification. |
| ๐ Separation of Concerns | Test logic is completely decoupled from driver implementation and locator definitions. |
| โ๏ธ Configuration Over Code | Behavior is controlled through external configuration, not hardcoded values. |
| ๐งช Fast Feedback Loop | High-performance execution using Playwright and Vitest for rapid development. |
High-Level Architectureโ
Component Breakdownโ
1. Driver Layerโ
The Driver Layer implements the Strategy Pattern, allowing runtime selection of the appropriate driver implementation.
Key Benefits:
- โ Single test codebase for all platforms.
- โ Driver changes (e.g., swapping engines) don't affect test specs.
- โ Supports parallel execution with different strategies.
2. Locator Systemโ
All locators are externalized in JSON files using the LocatorManager.
Locator Loading Order:
global.json- Common across all modes.{mode}/common.json- Mode-specific common locators.{mode}/{page}.json- Page/feature-specific locators.
3. Configuration Managementโ
The ConfigManager provides centralized access to validated environment variables:
import { configManager } from './config/config.manager.js';
// Type-safe access with Zod validation
const browser = configManager.get('BROWSER');
const timeout = configManager.get('TIMEOUT');
4. Test Execution Flowโ
Technology Stackโ
| Category | Technologies |
|---|---|
| Core Framework | Node.js (ESM), Zod, Dotenv |
| Web Testing | Playwright, Chromium/Firefox/WebKit |
| BDD Testing | Gherkin, playwright-bdd |
| API Testing | Playwright (Hybrid) ยท Axios (Specialized) |
| Mobile Testing | WebdriverIO, Appium |
| Unit Testing | Vitest |
| Database | pg (Postgres), mysql2 (MySQL) |
| Reporting | Allure, Playwright HTML |
Extensibility Pointsโ
TAFLEX JS is designed for extension at multiple levels:
1. Custom Driver Strategiesโ
Simply extend the AutomationDriver base class and register it in the DriverFactory.
2. Custom Element Wrappersโ
Extend or create new element wrappers to support unique platform interactions while maintaining a consistent API.
3. Fixturesโ
Customize Playwright fixtures in tests/fixtures.js to inject global setup/teardown logic or custom dependencies.