142 lines
23 KiB
JavaScript
142 lines
23 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 indent_string_1 = __importDefault(require("indent-string"));
|
|
const lodash_1 = require("lodash");
|
|
const moment_loader_1 = __importDefault(require("../utils/moment-loader"));
|
|
const string_1 = require("../utils/string");
|
|
const get_viewport_width_1 = __importDefault(require("../utils/get-viewport-width"));
|
|
const colors_1 = require("../utils/diff/colors");
|
|
const symbols_1 = __importDefault(require("../reporter/symbols"));
|
|
// NOTE: we should not expose internal state to
|
|
// the plugin, to avoid accidental rewrites.
|
|
// Therefore we use symbols to store them.
|
|
const stream = Symbol();
|
|
const wordWrapEnabled = Symbol();
|
|
const indent = Symbol();
|
|
const errorDecorator = Symbol();
|
|
class ReporterPluginHost {
|
|
constructor(plugin, outStream, name) {
|
|
this.name = name;
|
|
this.streamController = null;
|
|
this[stream] = outStream || process.stdout;
|
|
this[wordWrapEnabled] = false;
|
|
this[indent] = 0;
|
|
const useColors = this[stream] === process.stdout && chalk_1.default.enabled && !plugin.noColors;
|
|
this.chalk = new chalk_1.default.constructor({ enabled: useColors });
|
|
this.moment = moment_loader_1.default;
|
|
this.viewportWidth = (0, get_viewport_width_1.default)(this[stream]);
|
|
this.symbols = Object.assign({}, symbols_1.default);
|
|
(0, lodash_1.assignIn)(this, plugin);
|
|
this[errorDecorator] = this.createErrorDecorator();
|
|
}
|
|
// Error decorator
|
|
createErrorDecorator() {
|
|
return {
|
|
'span user-agent': (str) => this.chalk.grey(str),
|
|
'span subtitle': (str) => `- ${this.chalk.bold.red(str)} -`,
|
|
'div message': (str) => this.chalk.bold.red(str),
|
|
'div screenshot-info': lodash_1.identity,
|
|
'a screenshot-path': (str) => this.chalk.grey.underline(str),
|
|
'code': lodash_1.identity,
|
|
'span syntax-string': (str) => this.chalk.green(str),
|
|
'span syntax-punctuator': (str) => this.chalk.grey(str),
|
|
'span syntax-keyword': (str) => this.chalk.cyan(str),
|
|
'span syntax-number': (str) => this.chalk.magenta(str),
|
|
'span syntax-regex': (str) => this.chalk.magenta(str),
|
|
'span syntax-comment': (str) => this.chalk.grey.bold(str),
|
|
'span syntax-invalid': (str) => this.chalk.inverse(str),
|
|
[`span ${colors_1.DIFF_COLORS.DIFF_NOT_MODIFIED}`]: (str) => this.chalk.gray(str),
|
|
[`span ${colors_1.DIFF_COLORS.DIFF_ADDED}`]: (str) => this.chalk.green(str),
|
|
[`span ${colors_1.DIFF_COLORS.DIFF_REMOVED}`]: (str) => this.chalk.red(str),
|
|
'div code-frame': lodash_1.identity,
|
|
'div code-line': (str) => str + '\n',
|
|
'div code-line-last': lodash_1.identity,
|
|
'div code-line-num': (str) => ` ${str} |`,
|
|
'div code-line-num-base': (str) => this.chalk.bgRed(` > ${str} `) + '|',
|
|
'div code-line-src': lodash_1.identity,
|
|
'div stack': (str) => '\n\n' + str,
|
|
'div stack-line': (str) => str + '\n',
|
|
'div stack-line-last': lodash_1.identity,
|
|
'div stack-line-name': (str) => ` at ${this.chalk.bold(str)}`,
|
|
'div stack-line-location': (str) => ` (${this.chalk.grey.underline(str)})`,
|
|
'strong': (str) => this.chalk.bold(str),
|
|
'a': (str) => `"${this.chalk.underline(str)}"`,
|
|
};
|
|
}
|
|
// String helpers
|
|
indentString(str, indentVal) {
|
|
return (0, indent_string_1.default)(str, ' ', indentVal);
|
|
}
|
|
wordWrap(str, indentVal, width) {
|
|
return (0, string_1.wordWrap)(str, indentVal, width);
|
|
}
|
|
escapeHtml(str) {
|
|
return (0, lodash_1.escape)(str);
|
|
}
|
|
formatError(err, prefix = '') {
|
|
const prefixLengthWithoutColors = (0, string_1.removeTTYColors)(prefix).length;
|
|
const maxMsgLength = this.viewportWidth - this[indent] - prefixLengthWithoutColors;
|
|
let msg = err.formatMessage(this[errorDecorator], maxMsgLength);
|
|
if (this[wordWrapEnabled])
|
|
msg = this.wordWrap(msg, prefixLengthWithoutColors, maxMsgLength);
|
|
else
|
|
msg = this.indentString(msg, prefixLengthWithoutColors);
|
|
return prefix + msg.substr(prefixLengthWithoutColors);
|
|
}
|
|
// Writing helpers
|
|
newline() {
|
|
this._writeToUniqueStream('\n');
|
|
return this;
|
|
}
|
|
write(text) {
|
|
if (this[wordWrapEnabled])
|
|
text = this.wordWrap(text, this[indent], this.viewportWidth);
|
|
else
|
|
text = this.indentString(text, this[indent]);
|
|
this._writeToUniqueStream(text);
|
|
return this;
|
|
}
|
|
useWordWrap(use) {
|
|
this[wordWrapEnabled] = use;
|
|
return this;
|
|
}
|
|
setIndent(val) {
|
|
this[indent] = val;
|
|
return this;
|
|
}
|
|
_writeToUniqueStream(text) {
|
|
if (!this.streamController || this.streamController.ensureUniqueStream(this[stream], this))
|
|
this[stream].write(text);
|
|
}
|
|
// Abstract methods implemented in plugin
|
|
async reportTaskStart( /* startTime, userAgents, testCount, testStructure, taskProperties */) {
|
|
throw new Error('Not implemented');
|
|
}
|
|
async reportFixtureStart( /* name, path */) {
|
|
throw new Error('Not implemented');
|
|
}
|
|
// NOTE: It's an optional method
|
|
// async reportTestStart (/* name, testMeta */) {
|
|
// throw new Error('Not implemented');
|
|
// }
|
|
async reportTestDone( /* name, testRunInfo */) {
|
|
throw new Error('Not implemented');
|
|
}
|
|
async reportTaskDone( /* endTime, passed, warnings */) {
|
|
throw new Error('Not implemented');
|
|
}
|
|
// NOTE: It's an optional method
|
|
async init() {
|
|
// Optional
|
|
}
|
|
// NOTE: It's an optional method
|
|
async reportWarnings( /* warnings */) {
|
|
}
|
|
}
|
|
exports.default = ReporterPluginHost;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLWhvc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmVwb3J0ZXIvcGx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biAgICAgICAgICAgIFtgc3BhbiAke0RJRkZfQ09MT1JTLkRJRkZfQURERUR9YF06ICAgICAgICAoc3RyOiBzdHJpbmcpID0+IHRoaXMuY2hhbGsuZ3JlZW4oc3RyKSxcbiAgICAgICAgICAgIFtgc3BhbiAke0RJRkZfQ09MT1JTLkRJRkZfUkVNT1ZFRH1gXTogICAgICAoc3RyOiBzdHJpbmcpID0+IHRoaXMuY2hhbGsucmVkKHN0ciksXG5cbiAgICAgICAgICAgICdkaXYgY29kZS1mcmFtZSc6ICAgICAgICAgaWRlbnRpdHksXG4gICAgICAgICAgICAnZGl2IGNvZGUtbGluZSc6ICAgICAgICAgIChzdHI6IHN0cmluZykgPT4gc3RyICsgJ1xcbicsXG4gICAgICAgICAgICAnZGl2IGNvZGUtbGluZS1sYXN0JzogICAgIGlkZW50aXR5LFxuICAgICAgICAgICAgJ2RpdiBjb2RlLWxpbmUtbnVtJzogICAgICAoc3RyOiBzdHJpbmcpID0+IGAgICAke3N0cn0gfGAsXG4gICAgICAgICAgICAnZGl2IGNvZGUtbGluZS1udW0tYmFzZSc6IChzdHI6IHN0cmluZykgPT4gdGhpcy5jaGFsay5iZ1JlZChgID4gJHtzdHJ9IGApICsgJ3wnLFxuICAgICAgICAgICAgJ2RpdiBjb2RlLWxpbmUtc3JjJzogICAgICBpZGVudGl0eSxcblxuICAgICAgICAgICAgJ2RpdiBzdGFjayc6ICAgICAgICAgICAgICAgKHN0cjogc3RyaW5nKSA9PiAnXFxuXFxuJyArIHN0cixcbiAgICAgICAgICAgICdkaXYgc3RhY2stbGluZSc6ICAgICAgICAgIChzdHI6IHN0cmluZykgPT4gc3RyICsgJ1xcbicsXG4gICAgICAgICAgICAnZGl2IHN0YWNrLWxpbmUtbGFzdCc6ICAgICBpZGVudGl0eSxcbiAgICAgICAgICAgICdkaXYgc3RhY2stbGluZS1uYW1lJzogICAgIChzdHI6IHN0cmluZykgPT4gYCAgIGF0ICR7dGhpcy5jaGFsay5ib2xkKHN0cil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