Innovenergy_trunk/frontend/node_modules/testcafe/lib/notifications/debug-logger.js

80 lines
10 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const lodash_1 = require("lodash");
const log_update_async_hook_1 = __importDefault(require("log-update-async-hook"));
const render_callsite_sync_1 = __importDefault(require("../utils/render-callsite-sync"));
const create_stack_filter_1 = __importDefault(require("../errors/create-stack-filter"));
exports.default = {
messages: [],
debugLogging: false,
streamsOverridden: false,
_overrideStream(stream) {
const initialWrite = stream.write;
stream.write = (chunk, encoding, cb) => {
if (this.debugLogging)
initialWrite.call(stream, chunk, encoding, cb);
else {
this.debugLogging = true;
log_update_async_hook_1.default.clear();
log_update_async_hook_1.default.done();
initialWrite.call(stream, chunk, encoding, cb);
setTimeout(() => this._showAllBreakpoints(), 0);
this.debugLogging = false;
}
};
},
_overrideStreams() {
this._overrideStream(process.stdout);
this._overrideStream(process.stderr);
this.streamsOverridden = true;
},
_getMessageAsString() {
let string = '';
for (const message of this.messages)
string += message.frame;
return string;
},
_showAllBreakpoints() {
if (!this.messages.length)
return;
this.debugLogging = true;
(0, log_update_async_hook_1.default)(this._getMessageAsString());
this.debugLogging = false;
},
showBreakpoint(testRunId, userAgent, callsite, testError) {
if (!this.streamsOverridden)
this._overrideStreams();
const callsiteStr = (0, render_callsite_sync_1.default)(callsite, {
frameSize: 1,
stackFilter: (0, create_stack_filter_1.default)(Error.stackTraceLimit),
stack: false,
});
const frame = `\n` +
`----\n` +
`${userAgent}\n` +
chalk_1.default.yellow(testError ? 'DEBUGGER PAUSE ON FAILED TEST:' : 'DEBUGGER PAUSE:') +
`${testError ? `\n${testError}` : ''}` +
`${!testError && callsiteStr ? `\n${callsiteStr}` : ''}` +
'\n' +
`----\n`;
const message = { testRunId, frame };
const index = (0, lodash_1.findIndex)(this.messages, { testRunId });
if (index === -1)
this.messages.push(message);
else
this.messages[index] = message;
this._showAllBreakpoints();
},
hideBreakpoint(testRunId) {
const index = (0, lodash_1.findIndex)(this.messages, { testRunId });
if (index !== -1)
this.messages.splice(index, 1);
this._showAllBreakpoints();
},
};
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVidWctbG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL25vdGlmaWNhdGlvbnMvZGVidWctbG9nZ2VyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsa0RBQTBCO0FBQzFCLG1DQUFtQztBQUNuQyxrRkFBOEM7QUFDOUMseUZBQStEO0FBQy9ELHdGQUE4RDtBQUU5RCxrQkFBZTtJQUNYLFFBQVEsRUFBRSxFQUFFO0lBRVosWUFBWSxFQUFFLEtBQUs7SUFFbkIsaUJBQWlCLEVBQUUsS0FBSztJQUV4QixlQUFlLENBQUUsTUFBTTtRQUNuQixNQUFNLFlBQVksR0FBRyxNQUFNLENBQUMsS0FBSyxDQUFDO1FBRWxDLE1BQU0sQ0FBQyxLQUFLLEdBQUcsQ0FBQyxLQUFLLEVBQUUsUUFBUSxFQUFFLEVBQUUsRUFBRSxFQUFFO1lBQ25DLElBQUksSUFBSSxDQUFDLFlBQVk7Z0JBQ2pCLFlBQVksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLEtBQUssRUFBRSxRQUFRLEVBQUUsRUFBRSxDQUFDLENBQUM7aUJBQzlDO2dCQUNELElBQUksQ0FBQyxZQUFZLEdBQUcsSUFBSSxDQUFDO2dCQUV6QiwrQkFBUyxDQUFDLEtBQUssRUFBRSxDQUFDO2dCQUNsQiwrQkFBUyxDQUFDLElBQUksRUFBRSxDQUFDO2dCQUVqQixZQUFZLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxLQUFLLEVBQUUsUUFBUSxFQUFFLEVBQUUs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