permalink | editLink | sidebar | title |
---|---|---|---|
/helpers/SoftExpectHelper |
false |
auto |
SoftExpectHelper |
Extends ExpectHelper
SoftAssertHelper is a utility class for performing soft assertions. Unlike traditional assertions that stop the execution on failure, soft assertions allow the execution to continue and report all failures at the end.
Zero-configuration when paired with other helpers like REST, Playwright:
// inside codecept.conf.js
{
helpers: {
Playwright: {...},
SoftExpectHelper: {},
}
}
// in scenario
I.softExpectEqual('a', 'b')
I.flushSoftAssertions() // Throws an error if any soft assertions have failed. The error message contains all the accumulated failures.
Throws an error if any soft assertions have failed. The error message contains all the accumulated failures.
- Throws Error If there are any soft assertion failures.
Performs a soft assertion by executing the provided assertion function. If the assertion fails, the error is caught and stored without halting the execution.
assertionFn
Function The assertion function to execute.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is above a specified value.
targetData
any The data to check.aboveThan
any The value that the target data should be above.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is below a specified value.
targetData
any The data to check.belowThan
any The value that the target data should be below.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value contains the expected value.
actualValue
any The actual value.expectedValueToContain
any The value that should be contained within the actual value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two values are deeply equal.
actualValue
any The actual value.expectedValue
any The expected value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two objects are deeply equal, excluding specified fields.
actualValue
Object The actual object.expectedValue
Object The expected object.fieldsToExclude
Array<string> The fields to exclude from the comparison.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that an array (superset) deeply includes all members of another array (set).
superset
Array The array that should contain the expected members.set
Array The array with members that should be included.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two arrays have deep equality, considering members in any order.
actualValue
Array The actual array.expectedValue
Array The expected array.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is empty.
targetData
any The data to check.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value ends with the expected value.
actualValue
any The actual value.expectedValueToEndWith
any The value that the actual value should end with.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two values are equal.
actualValue
any The actual value.expectedValue
any The expected value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two values are equal, ignoring case.
actualValue
string The actual string value.expectedValue
string The expected string value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is false.
targetData
any The data to check.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data has a property with the specified name.
targetData
any The data to check.propertyName
string The property name to check for.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data has the specified property.
targetData
any The data to check.propertyName
string The property name to check for.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data matches the given JSON schema.
targetData
any The data to validate.jsonSchema
Object The JSON schema to validate against.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data matches the given JSON schema using AJV.
targetData
any The data to validate.jsonSchema
Object The JSON schema to validate against.customErrorMsg
string A custom error message to display if the assertion fails.ajvOptions
Object Options to pass to AJV.
Softly asserts that the length of the target data is above a specified value.
targetData
any The data to check.lengthAboveThan
number The length that the target data should be above.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the length of the target data is below a specified value.
targetData
any The data to check.lengthBelowThan
number The length that the target data should be below.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data has a specified length.
targetData
any The data to check.length
number The expected length.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value matches the expected pattern.
actualValue
any The actual value.expectedPattern
any The pattern the value should match.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value does not contain the expected value.
actualValue
any The actual value.expectedValueToNotContain
any The value that should not be contained within the actual value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two values are not deeply equal.
actualValue
any The actual value.expectedValue
any The expected value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value does not end with the expected value.
actualValue
any The actual value.expectedValueToNotEndWith
any The value that the actual value should not end with.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that two values are not equal.
actualValue
any The actual value.expectedValue
any The expected value.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value does not start with the expected value.
actualValue
any The actual value.expectedValueToNotStartWith
any The value that the actual value should not start with.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that a value starts with the expected value.
actualValue
any The actual value.expectedValueToStartWith
any The value that the actual value should start with.customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is of a specific type.
targetData
any The data to check.type
string The expected type (e.g., 'string', 'number').customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is of a specific type (alternative for articles).
targetData
any The data to check.type
string The expected type (e.g., 'string', 'number').customErrorMsg
string A custom error message to display if the assertion fails.
Softly asserts that the target data is true.
targetData
any The data to check.customErrorMsg
string A custom error message to display if the assertion fails.