How klassijs/klassi-js works
Project type and purpose
• This is an open-source, CLI-driven JavaScript test automation framework (klassi-js).
• It layers on top of Cucumber.js (for BDD) and WebdriverIO (for browser automation), adding AI-powered debugging helpers.
File structure
• Top-level:
• index.js – the CLI entrypoint
• *.rc.js / .env – configuration files for environments and data
• runtime/ – all of the framework’s core modules
• runtime/ contains:
• drivers/ – browser driver abstraction (chromeDriver.js)
• helpers.js – utility functions wrapping WebdriverIO
• reporter/ – custom reporter engine (reporter.js)
• world.js – custom Cucumber “World” context
• cucumber.js – Cucumber configuration
• .dataConfigrc.js, .envConfigrc.js – project & environment variables
Key insights from README
• The framework discovers feature files, step definitions, page objects, shared objects at runtime via CLI flags or defaults
• It spawns Cucumber.js with a customized World containing browser, pageObjects, sharedObjects, helpers, expect/assert, and trace
• On each step, it issues commands to WebdriverIO; on failure, AI-driven debugging assists
• Reports are generated in HTML/JSON via the reporter module
Main components & their interactions
a. CLI Layer (index.js)
• Parses flags (--browser, --tags, --steps, etc.)
• Loads config (.envConfigrc.js, .dataConfigrc.js)
• Invokes Cucumber.js with custom world.js and paths
b. Configuration Loader
• Reads .env, .envConfigrc.js, .dataConfigrc.js
• Exposes environment & test data to the World
c. Cucumber Core
• Loads feature files and step definitions
• Hooks into Before/After events via world.js
d. World Context (runtime/world.js)
• Initializes browser instance from chromeDriver.js or other driver adapters
• Loads pageObjects & sharedObjects from disk into memory
• Binds helpers.js, chai expect/assert, and debug trace
• Integrates AI-assisted debugging at step failure
e. Driver Abstraction (runtime/drivers)
• chromeDriver.js establishes WebdriverIO session based on CLI browser flag
• Exposes standard browser APIs for steps & helpers
f. Helpers Module (runtime/helpers.js)
• Provides extra utility methods (loadPage, clickHiddenElement, sortByDate, etc.)
g. Reporter Module (runtime/reporter/reporter.js)
• Hooks into Cucumber lifecycle to generate HTML/JSON reports
• Emits build-time artifacts under ./reports/<browser>/
h. File System (I/O)
• Feature files, step definitions, pageObjects, sharedObjects, and config live on disk
• Reporter writes results back to disk
Architectural patterns & design principles
• Plugin/Extension: Cucumber.js and WebdriverIO are extended via configurable World
• Separation of Concerns:
• CLI & config parsing
• Test orchestration (Cucumber)
• Domain logic Helpers & PageObjects
• Driver layer isolated under runtime/drivers
• Reporting isolated under runtime/reporter
• Inversion of Control: Cucumber injects the World, which in turn injects all dependencies into step definitions