Implementation:DevExpress Testcafe TestRunErrors
| Knowledge Sources | |
|---|---|
| Domains | Error_Handling, Testing |
| Last Updated | 2026-02-12 12:00 GMT |
Overview
Concrete library of shared error classes that define the complete taxonomy of test run errors used for error identification, formatting, and reporting across both browser and server.
Description
This module defines the shared error class hierarchy for test run errors. All error classes extend TestRunErrorBase which sets an error code (from TEST_RUN_ERRORS), an isTestCafeError flag, and an optional callsite. The hierarchy includes: client function errors (ClientFunctionExecutionInterruptionError, DomNodeClientFunctionResultError), selector errors (SelectorErrorBase, InvalidSelectorResultError, CannotObtainInfoForElementSpecifiedBySelectorError), uncaught errors (UncaughtErrorOnPage, UncaughtErrorInClientFunctionCode), action option validation errors (ActionIntegerOptionError, ActionSpeedOptionError, etc.), action execution errors (ActionElementNotFoundError, ActionElementIsInvisibleError, etc.), iframe/window errors, and native dialog errors.
Usage
These error classes are instantiated when test failures occur. They are used across both the browser client and Node.js server to provide structured error information for reporting.
Code Reference
Source Location
- Repository: DevExpress_Testcafe
- File: src/shared/errors/index.js
- Lines: 1-477
Signature
// Base classes
export class TestRunErrorBase {
constructor (code, callsite);
// Properties: code, isTestCafeError, callsite
}
class ActionOptionErrorBase extends TestRunErrorBase {
constructor (code, optionName, actualValue);
}
export class SelectorErrorBase extends TestRunErrorBase {
constructor (code, { apiFnChain, apiFnIndex, reason }, callsite);
}
// Key error classes (60+ total)
export class ActionElementNotFoundError extends SelectorErrorBase { }
export class ActionElementIsInvisibleError extends SelectorErrorBase { }
export class UncaughtErrorOnPage extends TestRunErrorBase {
constructor (errorInfo, pageUrl);
}
export class UncaughtErrorInClientFunctionCode extends TestRunErrorBase {
constructor (instantiationCallsiteName, err, callsite);
}
export class ActionCannotFindFileToUploadError extends TestRunErrorBase {
constructor (filePaths, scannedFilePaths);
}
// ... 50+ more error classes
Import
import {
TestRunErrorBase,
ActionElementNotFoundError,
UncaughtErrorOnPage,
// ...
} from '../shared/errors';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| code | string (error code) | Yes | Error type identifier from TEST_RUN_ERRORS enum |
| callsite | CallsiteRecord | No | Stack trace callsite for error location |
| (varies) | various | No | Error-specific data (pageUrl, filePaths, optionName, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
| Error instance | TestRunErrorBase | Structured error object with code, callsite, and context data |
| isTestCafeError | boolean | Always true, used to identify framework errors |
Usage Examples
// Creating and throwing test run errors
import { ActionElementNotFoundError, UncaughtErrorOnPage } from '../shared/errors';
// Element not found during a click action
const error = new ActionElementNotFoundError({
apiFnChain: ['Selector(\'#submit\')', 'click'],
apiFnIndex: 0,
});
// Uncaught error detected on the page
const pageError = new UncaughtErrorOnPage(
{ message: 'TypeError: Cannot read property \'x\' of null', stack: '...' },
'https://example.com/page'
);
// Check if an error is a TestCafe error
if (error.isTestCafeError) {
console.log(`TestCafe error: ${error.code}`);
}