@qavajs/steps-playwright
Version:
qavajs steps to interact with playwright
39 lines • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
const promises_1 = require("node:fs/promises");
class TracingManager {
isTracingStarted = false;
tracing;
async start(driverConfig, world) {
if (driverConfig.trace) {
if (!driverConfig.reuseSession || (driverConfig.reuseSession && !this.isTracingStarted)) {
this.isTracingStarted = true;
this.tracing = world.playwright.context.tracing;
await this.tracing.start({
screenshots: driverConfig.trace.screenshots ?? true,
snapshots: driverConfig.trace.snapshots ?? true,
sources: false
});
}
await world.playwright.context.tracing.startChunk();
}
}
async stop(driverConfig, world, scenario) {
if ((0, utils_1.saveTrace)(driverConfig, scenario)) {
const path = (0, utils_1.traceArchive)(driverConfig, scenario);
try {
await this.tracing.stopChunk({ path });
if (driverConfig?.trace.attach) {
const zipBuffer = await (0, promises_1.readFile)(path);
world.attach(zipBuffer.toString('base64'), 'base64:application/zip');
}
}
catch (err) {
console.warn(`Trace was not recorded\n${err}`);
}
}
}
}
exports.default = new TracingManager();
//# sourceMappingURL=tracingManager.js.map