ui-coverage-scenario-tool-js
Version:
**UI Coverage Scenario Tool** is an innovative, no-overhead solution for tracking and visualizing UI test coverage — directly on your actual application, not static snapshots. The tool collects coverage during UI test execution and generates an interactiv
86 lines (84 loc) • 2.3 kB
JavaScript
import {
ActionType,
UICoverageTrackerStorage,
getLogger,
getSettings
} from "./chunk-KWTIKUCY.js";
// src/tools/selector.ts
var SelectorType = /* @__PURE__ */ ((SelectorType2) => {
SelectorType2["CSS"] = "CSS";
SelectorType2["XPath"] = "XPATH";
return SelectorType2;
})(SelectorType || {});
// src/tracker/core.ts
var logger = getLogger("UI_COVERAGE_TRACKER");
var UICoverageTracker = class {
constructor({ app, settings }) {
this.app = app;
this.settings = settings || getSettings();
this.storage = new UICoverageTrackerStorage({ settings: this.settings });
this.scenario = null;
}
startScenario({ url, name }) {
this.scenario = { url, app: this.app, name };
}
async endScenario() {
if (this.scenario) {
await this.storage.saveScenarioResult(this.scenario);
}
this.scenario = null;
}
/**
* @deprecated Method is deprecated, use `trackElement` instead.
*/
async trackCoverage(props) {
logger.warning("Method trackCoverage() is deprecated. Use trackElement() instead.");
await this.trackElement(props);
}
async trackPage({ url, page, priority }) {
if (!this.scenario) {
logger.warning("No active scenario. Did you forget to call startScenario? Calling: trackPage");
return;
}
await this.storage.savePageResult({
app: this.app,
url,
page,
priority,
scenario: this.scenario.name
});
}
async trackElement({ selector, actionType, selectorType }) {
if (!this.scenario) {
logger.warning("No active scenario. Did you forget to call startScenario? Calling: trackElement");
return;
}
await this.storage.saveElementResult({
app: this.app,
scenario: this.scenario.name,
selector,
timestamp: Date.now(),
actionType,
selectorType
});
}
async trackTransition({ toPage, fromPage }) {
if (!this.scenario) {
logger.warning("No active scenario. Did you forget to call startScenario? Calling: trackTransition");
return;
}
await this.storage.saveTransitionResult({
app: this.app,
toPage,
scenario: this.scenario.name,
fromPage
});
}
};
export {
ActionType,
SelectorType,
UICoverageTracker
};
//# sourceMappingURL=index.js.map