UNPKG

page-with

Version:

A library for usage example-driven in-browser testing of your own libraries.

31 lines (30 loc) 932 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.debug = void 0; const createLogger_1 = require("../internal/createLogger"); const log = (0, createLogger_1.createLogger)('debug'); function debug(page) { if (!process.env.DEBUG) { throw new Error('Failed to add a debugging breakpoint: no "DEBUG" environmental variable found.'); } log('paused test execution!'); return new Promise((resolve) => { page.evaluate(() => { console.warn(`\ [pageWith] Paused test execution! Call "window.resume()" on this page to continue running the test.\ `); }); return page .evaluate(() => { return new Promise((resolve) => { window.resume = resolve; }); }) .then(() => { log('resumed test execution!'); resolve(); }); }); } exports.debug = debug;