fix(web-test): --no-record stubs return proper objects in run.mjs sandbox

The real fix: run.mjs sandbox was stubbing stopRecording/addNarration as
noop (returning undefined). Now returns { file: null, duration: 0 } so
video scripts work transparently with --no-record.
Also: browser.mjs stopRecording/addNarration handle missing state gracefully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-15 17:59:04 +03:00
parent 6667ab38ee
commit 9cffa81bcc
+5 -2
View File
@@ -118,10 +118,13 @@ async function executeScript(code, { noRecord } = {}) {
exports.writeFileSync = writeFileSync;
exports.readFileSync = readFileSync;
// --no-record: stub all recording/narration functions as no-ops
// --no-record: stub recording/narration functions to return safe defaults
if (noRecord) {
const noop = async () => {};
for (const fn of ['startRecording', 'stopRecording', 'addNarration', 'showCaption', 'hideCaption', 'showTitleSlide', 'hideTitleSlide']) {
exports.startRecording = noop;
exports.stopRecording = async () => ({ file: null, duration: 0, size: 0 });
exports.addNarration = async () => ({ file: null, duration: 0, size: 0, captions: 0 });
for (const fn of ['showCaption', 'hideCaption', 'showTitleSlide', 'hideTitleSlide']) {
exports[fn] = noop;
}
exports.isRecording = () => false;