Problem Description
When executing a sequence of plays, .detect() steps can occasionally match stale elements (e.g. a textbox editor that is still in the process of unmounting from the DOM during a page transition). Debugging which selectors matched first, or what the runner saw, currently requires inserting custom console logs or manual screenshots.
Proposed Solution
Introduce a live trace/debugger option that details exactly how state selectors evaluate in real-time.
To ensure maximum flexibility, this configuration should be toggleable at both the global Director setup level and overridden on individual assertions (assertCan, assertCannot, ensureExists).
Example API Usage
// 1. Enable globally for all assertions
const director = new Director({
debugStateDetection: true // Logs all selector matching details to console
});
// 2. Override globally-enabled logging for a specific noisy assertion
await director.assertCan(
userPlaybooks.prompts,
'update',
{ name: 'Prompt 1' },
{ debugStateDetection: false } // Override to disable
);
// 3. Enable only for one targeted assertion
await director.assertCannot(
userPlaybooks.scorers,
'delete',
{ name: 'Scorer 1' },
{ debugStateDetection: true } // Override to enable
);
Expected Output
When enabled, it should print detailed evaluation metrics to standard output:
[Playbook: Prompts] [Play: update] Running detect...
- Checking "tableState" locator... Absent (took 154ms)
- Checking "editorState" locator... MATCHED (found <input name="Name">, took 12ms)
Outcome resolved: "editorState" (isSuccess: false)
Problem Description
When executing a sequence of plays,
.detect()steps can occasionally match stale elements (e.g. a textbox editor that is still in the process of unmounting from the DOM during a page transition). Debugging which selectors matched first, or what the runner saw, currently requires inserting custom console logs or manual screenshots.Proposed Solution
Introduce a live trace/debugger option that details exactly how state selectors evaluate in real-time.
To ensure maximum flexibility, this configuration should be toggleable at both the global
Directorsetup level and overridden on individual assertions (assertCan,assertCannot,ensureExists).Example API Usage
Expected Output
When enabled, it should print detailed evaluation metrics to standard output: