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

80 lines
10 KiB
JavaScript
Raw Normal View History

"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVidWctbG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL25vdGlmaWNhdGlvbnMvZGVidWctbG9nZ2VyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsa0RBQTBCO0FBQzFCLG1DQUFtQztBQUNuQyxrRkFBOEM7QUFDOUMseUZBQStEO0FBQy9ELHdGQUE4RDtBQUU5RCxrQkFBZTtJQUNYLFFBQVEsRUFBRSxFQUFFO0lBRVosWUFBWSxFQUFFLEtBQUs7SUFFbkIsaUJBQWlCLEVBQUUsS0FBSztJQUV4QixlQUFlLENBQUUsTUFBTTtRQUNuQixNQUFNLFlBQVksR0FBRyxNQUFNLENBQUMsS0FBSyxDQUFDO1FBRWxDLE1BQU0sQ0FBQyxLQUFLLEdBQUcsQ0FBQyxLQUFLLEVBQUUsUUFBUSxFQUFFLEVBQUUsRUFBRSxFQUFFO1lBQ25DLElBQUksSUFBSSxDQUFDLFlBQVk7Z0JBQ2pCLFlBQVksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLEtBQUssRUFBRSxRQUFRLEVBQUUsRUFBRSxDQUFDLENBQUM7aUJBQzlDO2dCQUNELElBQUksQ0FBQyxZQUFZLEdBQUcsSUFBSSxDQUFDO2dCQUV6QiwrQkFBUyxDQUFDLEtBQUssRUFBRSxDQUFDO2dCQUNsQiwrQkFBUyxDQUFDLElBQUksRUFBRSxDQUFDO2dCQUVqQixZQUFZLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxLQUFLLEVBQUUsUUFBUSxFQUF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