Innovenergy_trunk/frontend/node_modules/testcafe-legacy-api/lib/test-run-error/templates.js

193 lines
9.9 KiB
JavaScript
Raw Permalink 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 dedent_1 = __importDefault(require("dedent"));
const lodash_1 = require("lodash");
const type_1 = __importDefault(require("./type"));
const assertion_diffs_1 = __importDefault(require("./assertion-diffs"));
function escapeNewLines(str) {
return (0, lodash_1.escape)(str).replace(/(\r\n|\n|\r)/gm, '\\n');
}
function getAssertionMsgPrefix(err) {
return err.message ? `"${(0, lodash_1.escape)(err.message)}" assertion` : 'Assertion';
}
function getDiffHeader(err) {
if (err.isArrays)
return `Arrays differ at index <code>${err.key}</code>:`;
if (err.isObjects)
return `Objects differ at the <code>${(0, lodash_1.escape)(err.key)}</code> field:`;
if (err.isStrings)
return `Strings differ at index <code>${err.key}</code>:`;
return '';
}
function markup(err, msgMarkup, opts = {}) {
msgMarkup = (0, dedent_1.default)(`
<div class="message">${(0, dedent_1.default)(msgMarkup)}</div>
<strong>Browser:</strong> <span class="user-agent">${err.userAgent}</span>
`);
if (err.screenshotPath)
msgMarkup += `\n<div class="screenshot-info"><strong>Screenshot:</strong> <a class="screenshot-path">${(0, lodash_1.escape)(err.screenshotPath)}</a></div>`;
if (!opts.withoutCallsite) {
var callsiteMarkup = err.getCallsiteMarkup();
if (callsiteMarkup)
msgMarkup += `\n\n<strong>Code:</strong>\n${callsiteMarkup}`;
}
return msgMarkup;
}
exports.default = {
[type_1.default.okAssertion]: err => markup(err, `
${getAssertionMsgPrefix(err)} failed at step "${(0, lodash_1.escape)(err.stepName)}":
<strong>Expected: </strong>not <code>null</code>, not <code>undefined</code>, not <code>false</code>, not <code>NaN</code> and not <code>''</code>
<strong>Actual: </strong><code>${escapeNewLines(err.actual)}</code>
`),
[type_1.default.notOkAssertion]: err => markup(err, `
${getAssertionMsgPrefix(err)} failed at step "${(0, lodash_1.escape)(err.stepName)}":
<strong>Expected: </strong><code>null</code>, <code>undefined</code>, <code>false</code>, <code>NaN</code> or <code>''</code>
<strong>Actual: </strong><code>${escapeNewLines(err.actual)}</code>
`),
[type_1.default.eqAssertion]: (err, maxStringLength) => {
var diff = (0, assertion_diffs_1.default)(err, maxStringLength);
var diffMarkerStr = diff.marker ? ` ${diff.marker}` : '';
return markup(err, `
${getAssertionMsgPrefix(err)} failed at step "${(0, lodash_1.escape)(err.stepName)}":
${getDiffHeader(err)}
<strong>Expected: </strong><code>${escapeNewLines(diff.expected)}</code>
<strong>Actual: </strong><code>${escapeNewLines(diff.actual)}</code>
<code>${diffMarkerStr}</code>
`);
},
[type_1.default.notEqAssertion]: err => markup(err, `
${getAssertionMsgPrefix(err)} failed at step "${(0, lodash_1.escape)(err.stepName)}":
<strong>Expected: </strong>not <code>${escapeNewLines(err.actual)}</code>
<strong>Actual: </strong><code>${escapeNewLines(err.actual)}</code>
`),
[type_1.default.iframeLoadingTimeout]: err => markup(err, `
IFrame loading timed out.
`),
[type_1.default.inIFrameTargetLoadingTimeout]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
IFrame target loading timed out.
`),
[type_1.default.uncaughtJSError]: err => {
if (err.pageDestUrl) {
return markup(err, `
Uncaught JavaScript error <code>${(0, lodash_1.escape)(err.scriptErr)}</code> on page <a href="${err.pageDestUrl}">${err.pageDestUrl}</a>
`);
}
return markup(err, `
Uncaught JavaScript error <code>${(0, lodash_1.escape)(err.scriptErr)}</code> on page.
`);
},
[type_1.default.uncaughtJSErrorInTestCodeStep]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
Uncaught JavaScript error in test code - <code>${(0, lodash_1.escape)(err.scriptErr)}</code>.
`),
[type_1.default.storeDomNodeOrJqueryObject]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
It is not allowed to share the DOM element, jQuery object or a function between test steps via "this" object.
`),
[type_1.default.emptyFirstArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
A target element of the <code>${err.action}</code> action has not been found in the DOM tree.
If this element should be created after animation or a time-consuming operation is finished, use the <code>waitFor</code> action (available for use in code) to pause test execution until this element appears.
`),
[type_1.default.invisibleActionElement]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
A target element <code>${(0, lodash_1.escape)(err.element)}</code> of the <code>${err.action}</code> action is not visible.
If this element should appear when you are hovering over another element, make sure that you properly recorded the <code>hover</code> action.
`),
[type_1.default.incorrectDraggingSecondArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>drag</code> action drop target is incorrect.
`),
[type_1.default.incorrectPressActionArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>press</code> action parameter contains incorrect key code.
`),
[type_1.default.emptyTypeActionArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The <code>type<code> action's parameter text is empty.
`),
[type_1.default.unexpectedDialog]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
Unexpected system <code>${err.dialog}</code> dialog <code>${(0, lodash_1.escape)(err.message)}</code> appeared.
`),
[type_1.default.expectedDialogDoesntAppear]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The expected system <code>${err.dialog}</code> dialog did not appear.
`),
[type_1.default.incorrectSelectActionArguments]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>select</code> action's parameters contain an incorrect value.
`),
[type_1.default.incorrectWaitActionMillisecondsArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>wait</code> action's "milliseconds" parameter should be a positive number.
`),
[type_1.default.incorrectWaitForActionEventArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>waitFor</code> action's first parameter should be a function, a CSS selector or an array of CSS selectors.
`),
[type_1.default.incorrectWaitForActionTimeoutArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>waitFor</code> action's "timeout" parameter should be a positive number.
`),
[type_1.default.waitForActionTimeoutExceeded]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>waitFor</code> action's timeout exceeded.
`),
[type_1.default.incorrectGlobalWaitForActionEventArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>__waitFor</code> action's first parameter should be a function.
`),
[type_1.default.incorrectGlobalWaitForActionTimeoutArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>__waitFor</code> action's "timeout" parameter should be a positive number.
`),
[type_1.default.globalWaitForActionTimeoutExceeded]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>__waitFor</code> action's timeout exceeded.
`),
[type_1.default.emptyIFrameArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The selector within the <code>inIFrame</code> function returns an empty value.
`),
[type_1.default.iframeArgumentIsNotIFrame]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The selector within the <code>inIFrame</code> function doesnt return an iframe element.
`),
[type_1.default.multipleIFrameArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The selector within the <code>inIFrame</code> function returns more than one iframe element.
`),
[type_1.default.incorrectIFrameArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
The <code>inIFrame</code> function contains an invalid argument.
`),
[type_1.default.uploadCanNotFindFileToUpload]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
Cannot find the following file(s) to upload:
${err.filePaths.map(path => `<code>${(0, lodash_1.escape)(path)}</code>`).join(',\n')}
`),
[type_1.default.uploadElementIsNotFileInput]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>upload</code> action argument does not contain a file input element.
`),
[type_1.default.uploadInvalidFilePathArgument]: err => markup(err, `
Error at step "${(0, lodash_1.escape)(err.stepName)}":
<code>upload</code> action's "path" parameter should be a string or an array of strings.
`),
[type_1.default.pageNotLoaded]: err => markup(err, `
${err.message}
`)
};