Skip to main content

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:

PrincipleDescription
๐Ÿงฉ Strategy PatternRuntime driver resolution allows the same test code to run on Web, API, or Mobile without modification.
๐Ÿ“„ Separation of ConcernsTest logic is completely decoupled from driver implementation and locator definitions.
โš™๏ธ Configuration Over CodeBehavior is controlled through external configuration, not hardcoded values.
๐Ÿงช Fast Feedback LoopHigh-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:

  1. global.json - Common across all modes.
  2. {mode}/common.json - Mode-specific common locators.
  3. {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โ€‹

CategoryTechnologies
Core FrameworkNode.js (ESM), Zod, Dotenv
Web TestingPlaywright, Chromium/Firefox/WebKit
BDD TestingGherkin, playwright-bdd
API TestingPlaywright (Hybrid) ยท Axios (Specialized)
Mobile TestingWebdriverIO, Appium
Unit TestingVitest
Databasepg (Postgres), mysql2 (MySQL)
ReportingAllure, 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.