From 97329b294fdcaf5be7632da4897f1ca493ec3a5e Mon Sep 17 00:00:00 2001 From: Ivan Nikulin Date: Mon, 27 Jun 2016 17:24:33 +0300 Subject: [PATCH] Unify errors rendering (closes #600) (#622) * Implement `t.select` * Unify error messages: test run errors * Fix rebase errors * Unify error messages: runtime errors * Move buildReporterPlugin to embedding utils * Bump version --- package.json | 2 +- src/errors/runtime/message.js | 26 +++--- src/errors/test-run/index.js | 10 +-- src/errors/test-run/templates.js | 54 +++++------- src/errors/test-run/type.js | 1 - src/index.js | 11 +-- src/reporter/plugin-host.js | 2 +- src/test-run/commands/actions.js | 35 ++++---- .../fixtures/api/es-next/click/test.js | 6 +- .../api/es-next/client-function/test.js | 8 +- .../fixtures/api/es-next/double-click/test.js | 6 +- .../fixtures/api/es-next/drag/test.js | 20 ++--- .../fixtures/api/es-next/eval/test.js | 2 +- .../fixtures/api/es-next/hover/test.js | 6 +- .../api/es-next/iframe-switching/test.js | 2 +- .../fixtures/api/es-next/navigate-to/test.js | 2 +- .../fixtures/api/es-next/press-key/test.js | 2 +- .../api/es-next/resize-window/test.js | 4 +- .../fixtures/api/es-next/right-click/test.js | 6 +- .../fixtures/api/es-next/select-text/test.js | 30 +++---- .../fixtures/api/es-next/select/test.js | 3 +- .../select/testcafe-fixtures/select-test.js | 2 +- .../api/es-next/selector/pages/index.html | 2 +- .../fixtures/api/es-next/selector/test.js | 2 +- .../api/es-next/take-screenshot/test.js | 2 +- .../api/es-next/test-controller/test.js | 2 +- .../fixtures/api/es-next/type/test.js | 8 +- .../fixtures/api/es-next/upload/test.js | 10 +-- .../fixtures/api/es-next/wait/test.js | 2 +- .../functional/fixtures/api/raw/click/test.js | 6 +- test/functional/fixtures/api/raw/drag/test.js | 4 +- .../fixtures/api/raw/press-key/test.js | 2 +- .../api/raw/select-editable-content/test.js | 6 +- .../api/raw/select-text-area-content/test.js | 2 +- test/functional/fixtures/api/raw/type/test.js | 4 +- test/server/compiler-test.js | 30 +++---- ...tion-additional-element-is-invisible-error | 2 +- .../action-additional-element-not-found-error | 2 +- .../action-additional-selector-error | 21 ----- .../action-boolean-option-error | 2 +- .../action-element-non-content-editable-error | 6 +- .../action-element-not-iframe-error | 2 +- .../action-element-not-text-area-error | 2 +- .../action-incorrect-keys-error | 2 +- .../action-integer-argument-error | 2 +- ...ion-non-empty-string-array-argument-error} | 2 +- .../action-positive-integer-argument-error | 2 +- .../action-positive-integer-option-error | 2 +- .../action-selector-error | 2 +- .../action-string-argument-error | 2 +- .../action-string-array-element-error | 4 +- .../action-unsupported-device-type-error | 4 +- .../action-unsupported-url-protocol-error | 2 +- .../missing-await-error | 2 +- test/server/test-run-commands-test.js | 86 ++++++++++++------- test/server/test-run-error-formatting-test.js | 11 +-- 56 files changed, 227 insertions(+), 255 deletions(-) delete mode 100644 test/server/data/expected-test-run-errors/action-additional-selector-error rename test/server/data/expected-test-run-errors/{action-string-or-string-array-argument-error => action-non-empty-string-array-argument-error} (84%) diff --git a/package.json b/package.json index 9001b6746f4..ef023e696ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testcafe", - "version": "0.0.17", + "version": "0.0.18", "main": "lib/index", "bin": { "testcafe": "./bin/testcafe" diff --git a/src/errors/runtime/message.js b/src/errors/runtime/message.js index 05fc449a1ce..392be6bcda6 100644 --- a/src/errors/runtime/message.js +++ b/src/errors/runtime/message.js @@ -16,19 +16,19 @@ export default { cantFindSpecifiedTestSource: 'Cannot find a test source file at "{path}".', cannotParseRawFile: 'Cannot parse a test source file in the raw format at "{path}" due to an error.\n\n{errMessage}', cannotPrepareTestsDueToError: 'Cannot prepare tests due to an error.\n\n{errMessage}', - fixtureNameIsNotAString: 'The fixture name is expected to be a string, but it was "{type}".', - fixturePageIsNotAString: 'The page URL is expected to be a string, but it was "{type}".', - testNameIsNotAString: 'The test name is expected to be a string, but it was "{type}".', - testBodyIsNotAFunction: 'The test body is expected to be a function, but it was "{type}".', - beforeEachIsNotAFunction: `Fixture's "beforeEach" method takes a function, but "{type}" was passed.`, - afterEachIsNotAFunction: `Fixture's "afterEach" method takes a function, but "{type}" was passed.`, - clientFunctionCodeIsNotAFunction: '{#instantiationCallsiteName} code is expected to be specified as a function, but "{type}" was passed.', - selectorInitializedWithWrongType: '{#instantiationCallsiteName} is expected to be initialized with a function, CSS selector string, another Selector, node snapshot or a Promise returned by a Selector, but "{type}" was passed.', + fixtureNameIsNotAString: 'The fixture name is expected to be a string, but it was {type}.', + fixturePageIsNotAString: 'The page URL is expected to be a string, but it was {type}.', + testNameIsNotAString: 'The test name is expected to be a string, but it was {type}.', + testBodyIsNotAFunction: 'The test body is expected to be a function, but it was {type}.', + beforeEachIsNotAFunction: `Fixture's "beforeEach" method takes a function, but {type} was passed.`, + afterEachIsNotAFunction: `Fixture's "afterEach" method takes a function, but {type} was passed.`, + clientFunctionCodeIsNotAFunction: '{#instantiationCallsiteName} code is expected to be specified as a function, but {type} was passed.', + selectorInitializedWithWrongType: '{#instantiationCallsiteName} is expected to be initialized with a function, CSS selector string, another Selector, node snapshot or a Promise returned by a Selector, but {type} was passed.', clientFunctionCantResolveTestRun: "{#instantiationCallsiteName} cannot implicitly resolve the test run in context of which it should be executed. If you need to call {#instantiationCallsiteName} from the Node.js API callback, pass the test controller manually via {#instantiationCallsiteName}'s `.with({ boundTestRun: t })` method first. Note that you cannot execute {#instantiationCallsiteName} outside the test code.", - regeneratorInClientFunctionCode: '{#instantiationCallsiteName} code, arguments or scope variables cannot contain generators or `async/await` syntax (use Promises instead).', - clientFunctionScopeVarsIsNotAnObject: `{#instantiationCallsiteName} "scopeVars" argument is expected to be an object, but it was "{type}".`, + regeneratorInClientFunctionCode: '{#instantiationCallsiteName} code, arguments or scope variables cannot contain generators or "async/await" syntax (use Promises instead).', + clientFunctionScopeVarsIsNotAnObject: `{#instantiationCallsiteName} "scopeVars" argument is expected to be an object, but it was {type}.`, invalidClientFunctionTestRunBinding: 'The "boundTestRun" option value is expected to be a test controller.', - optionsArgumentIsNotAnObject: '"options" argument is expected to be an object, but it was "{type}"', - optionValueIsNotABoolean: '"{name}" option is expected to be a boolean, but it was "{type}"', - optionValueIsNotANonNegativeNumber: '"{name}" option is expected to be a non-negative number, but it was "{type}"' + optionsArgumentIsNotAnObject: '"options" argument is expected to be an object, but it was {type}', + optionValueIsNotABoolean: '"{name}" option is expected to be a boolean, but it was {type}', + optionValueIsNotANonNegativeNumber: '"{name}" option is expected to be a non-negative number, but it was {type}' }; diff --git a/src/errors/test-run/index.js b/src/errors/test-run/index.js index 2356eb240c4..89dec95ba8f 100644 --- a/src/errors/test-run/index.js +++ b/src/errors/test-run/index.js @@ -209,16 +209,8 @@ export class ActionUnsupportedDeviceTypeError extends ActionArgumentErrorBase { // Selector errors export class ActionSelectorError extends TestRunErrorBase { - constructor (errMsg) { - super(TYPE.actionSelectorError); - - this.errMsg = errMsg; - } -} - -export class ActionAdditionalSelectorError extends TestRunErrorBase { constructor (selectorName, errMsg) { - super(TYPE.actionAdditionalSelectorError); + super(TYPE.actionSelectorError); this.selectorName = selectorName; this.errMsg = errMsg; diff --git a/src/errors/test-run/templates.js b/src/errors/test-run/templates.js index 375c85c343e..7f6f48deb12 100644 --- a/src/errors/test-run/templates.js +++ b/src/errors/test-run/templates.js @@ -22,13 +22,13 @@ function markup (err, msgMarkup) { export default { [TYPE.actionPositiveIntegerOptionError]: err => markup(err, ` - The ${err.optionName} option is expected to be a positive integer, but it was ${err.actualValue}. + The "${err.optionName}" option is expected to be a positive integer, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), [TYPE.actionBooleanOptionError]: err => markup(err, ` - The ${err.optionName} option is expected to be a boolean value, but it was ${err.actualValue}. + The "${err.optionName}" option is expected to be a boolean value, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), @@ -54,7 +54,7 @@ export default { `), [TYPE.uncaughtErrorInClientFunctionCode]: err => markup(err, ` - An error occurred in ${err.instantiationCallsiteName} code: + An error occurred in ${err.instantiationCallsiteName} code: ${escapeHtml(err.errMsg)} @@ -62,53 +62,53 @@ export default { `), [TYPE.clientFunctionExecutionInterruptionError]: err => markup(err, ` - ${err.instantiationCallsiteName} execution was interrupted by page unload. This problem may appear if you trigger page navigation from ${err.instantiationCallsiteName} code. + ${err.instantiationCallsiteName} execution was interrupted by page unload. This problem may appear if you trigger page navigation from ${err.instantiationCallsiteName} code. ${err.getCallsiteMarkup()} `), [TYPE.uncaughtNonErrorObjectInTestCode]: err => markup(err, ` - Uncaught ${err.objType} "${escapeHtml(err.objStr)}" was thrown. Throw Error instead. + Uncaught ${err.objType} "${escapeHtml(err.objStr)}" was thrown. Throw Error instead. `), [TYPE.actionOptionsTypeError]: err => markup(err, ` - Action options is expected to be an object, null or undefined but it was ${err.actualType}. + Action options is expected to be an object, null or undefined but it was ${err.actualType}. ${err.getCallsiteMarkup()} `), [TYPE.actionUnsupportedUrlProtocolError]: err => markup(err, ` - The ${err.argumentName} argument specifies a URL that uses an unsupported ${err.protocol}:// protocol. Only HTTP and HTTPS are supported, as well as protocol-relative and relative URLs. + The "${err.argumentName}" argument specifies a URL that uses an unsupported ${err.protocol}:// protocol. Only HTTP and HTTPS are supported, as well as protocol-relative and relative URLs. ${err.getCallsiteMarkup()} `), [TYPE.actionStringArgumentError]: err => markup(err, ` - The ${err.argumentName} argument is expected to be a non-empty string, but it was ${err.actualValue}. + The "${err.argumentName}" argument is expected to be a non-empty string, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), [TYPE.actionStringOrStringArrayArgumentError]: err => markup(err, ` - The ${err.argumentName} argument is expected to be a non-empty string or a string array, but it was ${err.actualValue}. + The "${err.argumentName}" argument is expected to be a non-empty string or a string array, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), [TYPE.actionStringArrayElementError]: err => markup(err, ` - Elements of the ${err.argumentName} argument are expected to be non-empty strings, but the element at index ${err.elementIndex} was ${err.actualValue}. + Elements of the "${err.argumentName}" argument are expected to be non-empty strings, but the element at index ${err.elementIndex} was ${err.actualValue}. ${err.getCallsiteMarkup()} `), [TYPE.actionIntegerArgumentError]: err => markup(err, ` - The ${err.argumentName} argument is expected to be an integer, but it was ${err.actualValue}. + The "${err.argumentName}" argument is expected to be an integer, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), [TYPE.actionPositiveIntegerArgumentError]: err => markup(err, ` - The ${err.argumentName} argument is expected to be a positive integer, but it was ${err.actualValue}. + The "${err.argumentName}" argument is expected to be a positive integer, but it was ${err.actualValue}. ${err.getCallsiteMarkup()} `), @@ -126,13 +126,13 @@ export default { `), [TYPE.actionAdditionalElementNotFoundError]: err => markup(err, ` - The specified ${err.argumentName} does not match any element in the DOM tree. + The specified "${err.argumentName}" does not match any element in the DOM tree. ${err.getCallsiteMarkup()} `), [TYPE.actionAdditionalElementIsInvisibleError]: err => markup(err, ` - The element that matches the specified ${err.argumentName} is not visible. + The element that matches the specified "${err.argumentName}" is not visible. ${err.getCallsiteMarkup()} `), @@ -144,7 +144,7 @@ export default { `), [TYPE.actionElementNonContentEditableError]: err => markup(err, ` - The element that matches the specified ${err.argumentName} is expected to have the contentEditable attribute enabled or the entire document should be in design mode. + The element that matches the specified "${err.argumentName}" is expected to have the contentEditable attribute enabled or the entire document should be in design mode. ${err.getCallsiteMarkup()} `), @@ -169,25 +169,25 @@ export default { `), [TYPE.actionElementNotTextAreaError]: err => markup(err, ` - The action element is expected to be a textarea. + The action element is expected to be a <textarea>. ${err.getCallsiteMarkup()} `), [TYPE.actionElementNotIframeError]: err => markup(err, ` - The action element is expected to be an iframe. + The action element is expected to be an <iframe>. ${err.getCallsiteMarkup()} `), [TYPE.actionIncorrectKeysError]: err => markup(err, ` - The ${err.argumentName} argument contains an incorrect key or key combination. + The "${err.argumentName}" argument contains an incorrect key or key combination. ${err.getCallsiteMarkup()} `), [TYPE.actionUnsupportedDeviceTypeError]: err => markup(err, ` - The ${err.argumentName} argument specifies an unsupported ${err.actualValue} device. For a list of supported devices, refer to http://viewportsizes.com + The "${err.argumentName}" argument specifies an unsupported "${err.actualValue}" device. For a list of supported devices, refer to http://viewportsizes.com. ${err.getCallsiteMarkup()} `), @@ -217,7 +217,7 @@ export default { `), [TYPE.missingAwaitError]: err => markup(err, ` - A call to an async function is not awaited. Use the await keyword before actions, assertions or chains of them to ensure that they run in the right sequence. + A call to an async function is not awaited. Use the "await" keyword before actions, assertions or chains of them to ensure that they run in the right sequence. ${err.getCallsiteMarkup()} `), @@ -229,27 +229,19 @@ export default { `), [TYPE.domNodeClientFunctionResultError]: err => markup(err, ` - ${err.instantiationCallsiteName} cannot return DOM elements. Use Selector functions for this purpose. + ${err.instantiationCallsiteName} cannot return DOM elements. Use Selector functions for this purpose. ${err.getCallsiteMarkup()} `), [TYPE.nonDomNodeSelectorResultError]: err => markup(err, ` - ${err.instantiationCallsiteName} can only return a DOM node, null or undefined. Use ClientFunction to return other values. + ${err.instantiationCallsiteName} can only return a DOM node, null or undefined. Use ClientFunction to return other values. ${err.getCallsiteMarkup()} `), [TYPE.actionSelectorError]: err => markup(err, ` - Action selector error: - - ${escapeHtml(err.errMsg)} - - ${err.getCallsiteMarkup()} - `), - - [TYPE.actionAdditionalSelectorError]: err => markup(err, ` - Action ${err.selectorName} error: + Action "${err.selectorName}" argument error: ${escapeHtml(err.errMsg)} diff --git a/src/errors/test-run/type.js b/src/errors/test-run/type.js index a9c7c985bef..10b479788bf 100644 --- a/src/errors/test-run/type.js +++ b/src/errors/test-run/type.js @@ -18,7 +18,6 @@ export default { actionIntegerArgumentError: 'actionIntegerArgumentError', actionPositiveIntegerArgumentError: 'actionPositiveIntegerArgumentError', actionSelectorError: 'actionSelectorError', - actionAdditionalSelectorError: 'actionAdditionalSelectorError', actionUnsupportedUrlProtocolError: 'actionUnsupportedUrlProtocolError', actionElementNotFoundError: 'actionElementNotFoundError', actionElementIsInvisibleError: 'actionElementIsInvisibleError', diff --git a/src/index.js b/src/index.js index f1003c43870..e683dfe713c 100644 --- a/src/index.js +++ b/src/index.js @@ -44,8 +44,10 @@ async function createTestCafe (hostname, port1, port2) { return new TestCafe(hostname, port1, port2); } -// Plugin testing utils -createTestCafe.pluginTestingUtils = { +// Embedding utils +createTestCafe.embeddingUtils = { + TestRunErrorFormattableAdapter: TestRunErrorFormattableAdapter, + buildReporterPlugin (pluginFactory, outStream) { var plugin = pluginFactory(); @@ -53,11 +55,6 @@ createTestCafe.pluginTestingUtils = { } }; -// Embedding utils -createTestCafe.embeddingUtils = { - TestRunErrorFormattableAdapter: TestRunErrorFormattableAdapter -}; - // Common API Object.keys(commonAPI).forEach(key => createTestCafe[key] = commonAPI[key]); diff --git a/src/reporter/plugin-host.js b/src/reporter/plugin-host.js index edc835d5588..7b5f362603d 100644 --- a/src/reporter/plugin-host.js +++ b/src/reporter/plugin-host.js @@ -41,7 +41,7 @@ export default class ReporterPluginHost { createErrorDecorator () { return { 'span step-name': str => `"${str}"`, - 'span user-agent': str => this.chalk.gray(str), + 'span user-agent': str => this.chalk.red(str), 'span subtitle': str => `- ${this.chalk.bold(str)} -\n`, diff --git a/src/test-run/commands/actions.js b/src/test-run/commands/actions.js index 5f4c3c57e2a..169c6c0e866 100644 --- a/src/test-run/commands/actions.js +++ b/src/test-run/commands/actions.js @@ -12,28 +12,23 @@ import { stringOrStringArrayArgument } from './validations/argument'; -import { ActionSelectorError, ActionAdditionalSelectorError } from '../../errors/test-run'; +import { ActionSelectorError } from '../../errors/test-run'; import { APIError } from '../../errors/runtime'; // Initializers -function createSelectorInitializer (createError) { - return (name, val) => { - try { - var factory = new SelectorFactory(val, null, { instantiation: 'Selector' }); - - return factory.getCommand([], { visibilityCheck: true }); - } - catch (err) { - var msg = err.constructor === APIError ? err.rawMessage : err.message; - - throw createError(name, msg); - } - }; -} +function initSelector (name, val) { + try { + var factory = new SelectorFactory(val, null, { instantiation: 'Selector' }); + + return factory.getCommand([], { visibilityCheck: true }); + } + catch (err) { + var msg = err.constructor === APIError ? err.rawMessage : err.message; -var initSelector = createSelectorInitializer((name, msg) => new ActionSelectorError(msg)); -var initAdditionalSelector = createSelectorInitializer((name, msg) => new ActionAdditionalSelectorError(name, msg)); + throw new ActionSelectorError(name, msg); + } +} function initClickOptions (name, val) { return new ClickOptions(val, true); @@ -184,7 +179,7 @@ export class DragToElementCommand extends Assignable { _getAssignableProperties () { return [ { name: 'selector', init: initSelector, required: true }, - { name: 'destinationSelector', init: initAdditionalSelector, required: true }, + { name: 'destinationSelector', init: initSelector, required: true }, { name: 'options', type: actionOptions, init: initMouseOptions, required: true } ]; } @@ -224,8 +219,8 @@ export class SelectEditableContentCommand extends Assignable { _getAssignableProperties () { return [ - { name: 'startSelector', init: initAdditionalSelector, required: true }, - { name: 'endSelector', init: initAdditionalSelector } + { name: 'startSelector', init: initSelector, required: true }, + { name: 'endSelector', init: initSelector } ]; } } diff --git a/test/functional/fixtures/api/es-next/click/test.js b/test/functional/fixtures/api/es-next/click/test.js index 0b147a4aaa7..2ae7eb0d24a 100644 --- a/test/functional/fixtures/api/es-next/click/test.js +++ b/test/functional/fixtures/api/es-next/click/test.js @@ -26,7 +26,7 @@ describe('[API] t.click()', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contains('The offsetX option is expected to be a positive integer, but it was -3.'); + expect(errs[0]).to.contains('The "offsetX" option is expected to be a positive integer, but it was -3.'); expect(errs[0]).to.contains( ' 11 |test(\'Incorrect action selector\', async t => {' + ' 12 | await t.click(123);' + @@ -50,9 +50,9 @@ describe('[API] t.click()', function () { }) .catch(function (errs) { expect(errs[0]).to.contains( - 'Action selector error: Selector is expected to be initialized with a ' + + 'Action "selector" argument error: Selector is expected to be initialized with a ' + 'function, CSS selector string, another Selector, node snapshot or a Promise returned ' + - 'by a Selector, but "number" was passed.' + 'by a Selector, but number was passed.' ); expect(errs[0]).to.contains( '7 | .page `http://localhost:3000/fixtures/api/es-next/click/pages/index.html`;' + diff --git a/test/functional/fixtures/api/es-next/client-function/test.js b/test/functional/fixtures/api/es-next/client-function/test.js index b012549c89c..13daa26eec9 100644 --- a/test/functional/fixtures/api/es-next/client-function/test.js +++ b/test/functional/fixtures/api/es-next/client-function/test.js @@ -82,7 +82,7 @@ describe('[API] ClientFunction', function () { only: 'chrome' }).catch(function (errs) { expect(errs[0].indexOf( - 'ClientFunction code is expected to be specified as a function, but "number" was passed.' + 'ClientFunction code is expected to be specified as a function, but number was passed.' )).eql(0); expect(errs[0]).contains('> 29 | await ClientFunction(123)();'); @@ -108,7 +108,7 @@ describe('[API] ClientFunction', function () { only: 'chrome' }).catch(function (errs) { expect(errs[0].indexOf( - 'ClientFunction code, arguments or scope variables cannot contain generators or `async/await` syntax (use Promises instead).' + 'ClientFunction code, arguments or scope variables cannot contain generators or "async/await" syntax (use Promises instead).' )).eql(0); expect(errs[0]).contains('> 51 | ClientFunction(async () => Promise.resolve());'); @@ -121,7 +121,7 @@ describe('[API] ClientFunction', function () { only: 'chrome' }).catch(function (errs) { expect(errs[0].indexOf( - 'ClientFunction code, arguments or scope variables cannot contain generators or `async/await` syntax (use Promises instead).' + 'ClientFunction code, arguments or scope variables cannot contain generators or "async/await" syntax (use Promises instead).' )).eql(0); expect(errs[0]).contains('> 55 | ClientFunction(function*() { '); @@ -156,7 +156,7 @@ describe('[API] ClientFunction', function () { }) .catch(function (errs) { expect(errs[0]).contains( - 'ClientFunction code, arguments or scope variables cannot contain generators or `async/await` syntax (use Promises instead).' + 'ClientFunction code, arguments or scope variables cannot contain generators or "async/await" syntax (use Promises instead).' ); expect(errs[0]).contains(' > 202 | await hfn(async () => Promise.resolve());'); }); diff --git a/test/functional/fixtures/api/es-next/double-click/test.js b/test/functional/fixtures/api/es-next/double-click/test.js index 0c549f279ea..442c4770f27 100644 --- a/test/functional/fixtures/api/es-next/double-click/test.js +++ b/test/functional/fixtures/api/es-next/double-click/test.js @@ -18,7 +18,7 @@ describe('[API] t.doubleClick()', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contains('The offsetX option is expected to be a positive integer, but it was 3.14.'); + expect(errs[0]).to.contains('The "offsetX" option is expected to be a positive integer, but it was 3.14.'); expect(errs[0]).to.contains(' > 15 | await t.doubleClick(\'#button\', { offsetX: 3.14 });'); }); }); @@ -30,9 +30,9 @@ describe('[API] t.doubleClick()', function () { }) .catch(function (errs) { expect(errs[0]).to.contains( - 'Action selector error: Selector is expected to be initialized with a ' + + 'Action "selector" argument error: Selector is expected to be initialized with a ' + 'function, CSS selector string, another Selector, node snapshot or a Promise ' + - 'returned by a Selector, but "object" was passed.' + 'returned by a Selector, but object was passed.' ); expect(errs[0]).to.contains(' > 11 | await t.doubleClick(null);'); }); diff --git a/test/functional/fixtures/api/es-next/drag/test.js b/test/functional/fixtures/api/es-next/drag/test.js index 0e616f135c8..0b38cb331b4 100644 --- a/test/functional/fixtures/api/es-next/drag/test.js +++ b/test/functional/fixtures/api/es-next/drag/test.js @@ -18,9 +18,9 @@ describe('[API] Drag actions', function () { }) .catch(function (errs) { expect(errs[0]).to.contain( - 'Action selector error: Selector is expected to be initialized with a ' + + 'Action "selector" argument error: Selector is expected to be initialized with a ' + 'function, CSS selector string, another Selector, node snapshot or a Promise returned ' + - 'by a Selector, but "object" was passed.' + 'by a Selector, but object was passed.' ); expect(errs[0]).to.contain('> 14 | await t.drag({}, 10, 20);'); }); @@ -32,7 +32,7 @@ describe('[API] Drag actions', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contain('The dragOffsetX argument is expected to be an integer, but it was NaN.'); + expect(errs[0]).to.contain('The "dragOffsetX" argument is expected to be an integer, but it was NaN.'); expect(errs[0]).to.contain('> 18 | await t.drag(\'#draggable-div-1\', NaN, 20);'); }); }); @@ -43,7 +43,7 @@ describe('[API] Drag actions', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contain('The dragOffsetY argument is expected to be an integer, but it was 3.14.'); + expect(errs[0]).to.contain('The "dragOffsetY" argument is expected to be an integer, but it was 3.14.'); expect(errs[0]).to.contain('> 22 | await t.drag(\'#draggable-div-1\', 10, 3.14);'); }); }); @@ -54,7 +54,7 @@ describe('[API] Drag actions', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contain('The offsetX option is expected to be a positive integer, but it was string.'); + expect(errs[0]).to.contain('The "offsetX" option is expected to be a positive integer, but it was string.'); expect(errs[0]).to.contain('> 26 | await t.drag(\'#draggable-div-1\', 10, 20, { offsetX: \'test\' });'); }); }); @@ -76,9 +76,9 @@ describe('[API] Drag actions', function () { }) .catch(function (errs) { expect(errs[0]).to.contain( - 'Action selector error: Selector is expected to be initialized with a ' + + 'Action "selector" argument error: Selector is expected to be initialized with a ' + 'function, CSS selector string, another Selector, node snapshot or a Promise returned ' + - 'by a Selector, but "undefined" was passed.' + 'by a Selector, but undefined was passed.' ); expect(errs[0]).to.contain('> 37 | await t.dragToElement(void 0, \'#destination-div\');'); }); @@ -91,9 +91,9 @@ describe('[API] Drag actions', function () { }) .catch(function (errs) { expect(errs[0]).to.contain( - 'Action destinationSelector error: Selector is expected to be initialized ' + + 'Action "destinationSelector" argument error: Selector is expected to be initialized ' + 'with a function, CSS selector string, another Selector, node snapshot or a Promise ' + - 'returned by a Selector, but "object" was passed.' + 'returned by a Selector, but object was passed.' ); expect(errs[0]).to.contain('> 41 | await t.dragToElement(\'#draggable-div-2\', null);'); }); @@ -105,7 +105,7 @@ describe('[API] Drag actions', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contain('The modifiers.shift option is expected to be a boolean value, but it was number.'); + expect(errs[0]).to.contain('The "modifiers.shift" option is expected to be a boolean value, but it was number.'); expect(errs[0]).to.contain('> 45 | await t.dragToElement(\'#draggable-div-2\', \'#destination-div\''); }); }); diff --git a/test/functional/fixtures/api/es-next/eval/test.js b/test/functional/fixtures/api/es-next/eval/test.js index c75eb7eacdc..343ea3b5832 100644 --- a/test/functional/fixtures/api/es-next/eval/test.js +++ b/test/functional/fixtures/api/es-next/eval/test.js @@ -24,7 +24,7 @@ describe('[API] t.eval', function () { it('Should have the correct callsite if an error occurs on instantiation', function () { return runTests('./testcafe-fixtures/eval-test.js', 'Error on instantiation', { shouldFail: true }) .catch(function (errs) { - expect(errs[0]).contains('eval code is expected to be specified as a function, but "string" was passed.'); + expect(errs[0]).contains('eval code is expected to be specified as a function, but string was passed.'); expect(errs[0]).contains("> 21 | await t.eval('42');"); }); }); diff --git a/test/functional/fixtures/api/es-next/hover/test.js b/test/functional/fixtures/api/es-next/hover/test.js index d9636847821..48fa770869d 100644 --- a/test/functional/fixtures/api/es-next/hover/test.js +++ b/test/functional/fixtures/api/es-next/hover/test.js @@ -18,7 +18,7 @@ describe('[API] Hover action', function () { only: 'chrome' }) .catch(function (errs) { - expect(errs[0]).to.contains('The offsetX option is expected to be a positive integer, but it was NaN.'); + expect(errs[0]).to.contains('The "offsetX" option is expected to be a positive integer, but it was NaN.'); expect(errs[0]).to.contains(' > 16 | await t.hover(\'#container1\', { offsetX: NaN });'); }); }); @@ -30,9 +30,9 @@ describe('[API] Hover action', function () { }) .catch(function (errs) { expect(errs[0]).to.contains( - 'Action selector error: Selector is expected to be initialized with a ' + + 'Action "selector" argument error: Selector is expected to be initialized with a ' + 'function, CSS selector string, another Selector, node snapshot or a Promise returned ' + - 'by a Selector, but "undefined" was passed.' + 'by a Selector, but undefined was passed.' ); expect(errs[0]).to.contains(' > 12 | await t.hover(void 0);'); }); diff --git a/test/functional/fixtures/api/es-next/iframe-switching/test.js b/test/functional/fixtures/api/es-next/iframe-switching/test.js index 969a773f3ac..3e853a21879 100644 --- a/test/functional/fixtures/api/es-next/iframe-switching/test.js +++ b/test/functional/fixtures/api/es-next/iframe-switching/test.js @@ -62,7 +62,7 @@ describe('[API] t.switchToIframe(), t.switchToMainWindow()', function () { it('Should raise an error is the switchContext argument is not an iframe', function () { return runTests('./testcafe-fixtures/iframe-switching-test.js', 'Try to switch to an incorrect element', { shouldFail: true }) .catch(function (errs) { - expect(errs[0]).to.contains('The action element is expected to be an iframe.'); + expect(errs[0]).to.contains('The action element is expected to be an