Skip to content

Commit c422444

Browse files
committed
[js] Add support for emitting an end of test script event for testing in browser
1 parent 3ab85be commit c422444

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/vm/js/nqp-runtime/runtime.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,21 @@ exports.run = /*async*/ function(code, isMain) {
572572
throw e;
573573
}
574574
}
575+
} else if (once && typeof window !== 'undefined' && window.NQP_END_EVENT) {
576+
once = false;
577+
let ret;
578+
try {
579+
ret = /*await*/ doRun()
580+
} catch (e) {
581+
if (e instanceof browser.Exit) {
582+
console.info('exit', e.status);
583+
} else {
584+
throw e;
585+
}
586+
}
587+
588+
console.info('end');
589+
return ret;
575590
} else {
576591
return /*await*/ doRun();
577592
}

0 commit comments

Comments
 (0)