🤖 AI Summary
This study addresses the limitations of existing testability frameworks in capturing the structural challenges posed by asynchronous, event-driven, and dynamic features prevalent in modern JavaScript systems. It introduces the first formalization of structural testability for JavaScript through a seven-dimensional construct—controllability, observability, branching complexity, asynchronous coordination, event-driven behavior, encapsulation, and side-effect intensity—and proposes a Composite Testability Score (CTS) derived from static AST analysis to enable quantitative comparison across functions, files, and projects. Empirical evaluation on 30 open-source projects reveals that low-testability functions are concentrated in a small subset of files and stem from recurring combinations of structural patterns rather than any single dominant factor, offering both theoretical grounding and practical guidance for targeted test generation and refactoring.
📝 Abstract
Software testability has long been recognized as a software quality attribute that influences testing effort and effectiveness. While prior work has extensively studied testability in object-oriented and concurrent software, comparatively little is known about structural testability in modern JavaScript systems. JavaScript applications rely on asynchronous execution, event-driven control flow, closures, and dynamic interactions that are not explicitly captured by existing testability frameworks. This paper presents a large-scale empirical study of structural testability in JavaScript. We operationalize structural testability as a seven-dimensional construct capturing controllability, observability, branching complexity, asynchronous coordination, event-driven behaviour, encapsulation, and side-effect intensity. These dimensions are derived from AST-based static analysis and aggregated into a Composite Testability Score (CTS) for comparative analysis across functions, files, and projects. We apply this framework to 30 open-source JavaScript projects spanning diverse domains and sizes. Our analysis characterizes the distribution of structural testability, identifies recurring structural archetypes among low-CTS functions, and examines associations between project characteristics and testability. We find that structurally-challenging functions are concentrated within a relatively small subset of files and arise through multiple recurring structural configurations rather than a single dominant pattern. These findings provide new insight into structural testability in JavaScript and establish a foundation for future research on testing effort, automated test generation, testability-aware refactoring, and software quality assessment.