SoftExpectHelper
SoftAssertHelper
Section titled “SoftAssertHelper”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.
Examples
Section titled “Examples”Zero-configuration when paired with other helpers like REST, Playwright:
// inside codecept.conf.js{ helpers: { Playwright: {...}, SoftExpectHelper: {}, }}// in scenarioI.softExpectEqual('a', 'b')I.flushSoftAssertions() // Throws an error if any soft assertions have failed. The error message contains all the accumulated failures.Methods
Section titled “Methods”flushSoftAssertions
Section titled “flushSoftAssertions”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.
softAssert
Section titled “softAssert”Performs a soft assertion by executing the provided assertion function. If the assertion fails, the error is caught and stored without halting the execution.
Parameters
Section titled “Parameters”assertionFnFunction The assertion function to execute.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectAbove
Section titled “softExpectAbove”Softly asserts that the target data is above a specified value.
Parameters
Section titled “Parameters”targetDataany The data to check.aboveThanany The value that the target data should be above.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectBelow
Section titled “softExpectBelow”Softly asserts that the target data is below a specified value.
Parameters
Section titled “Parameters”targetDataany The data to check.belowThanany The value that the target data should be below.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectContain
Section titled “softExpectContain”Softly asserts that a value contains the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToContainany The value that should be contained within the actual value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectDeepEqual
Section titled “softExpectDeepEqual”Softly asserts that two values are deeply equal.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueany The expected value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectDeepEqualExcluding
Section titled “softExpectDeepEqualExcluding”Softly asserts that two objects are deeply equal, excluding specified fields.
Parameters
Section titled “Parameters”actualValueObject The actual object.expectedValueObject The expected object.fieldsToExcludeArray<string> The fields to exclude from the comparison.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectDeepIncludeMembers
Section titled “softExpectDeepIncludeMembers”Softly asserts that an array (superset) deeply includes all members of another array (set).
Parameters
Section titled “Parameters”supersetArray The array that should contain the expected members.setArray The array with members that should be included.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectDeepMembers
Section titled “softExpectDeepMembers”Softly asserts that two arrays have deep equality, considering members in any order.
Parameters
Section titled “Parameters”actualValueArray The actual array.expectedValueArray The expected array.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectEmpty
Section titled “softExpectEmpty”Softly asserts that the target data is empty.
Parameters
Section titled “Parameters”targetDataany The data to check.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectEndsWith
Section titled “softExpectEndsWith”Softly asserts that a value ends with the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToEndWithany The value that the actual value should end with.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectEqual
Section titled “softExpectEqual”Softly asserts that two values are equal.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueany The expected value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectEqualIgnoreCase
Section titled “softExpectEqualIgnoreCase”Softly asserts that two values are equal, ignoring case.
Parameters
Section titled “Parameters”actualValuestring The actual string value.expectedValuestring The expected string value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectFalse
Section titled “softExpectFalse”Softly asserts that the target data is false.
Parameters
Section titled “Parameters”targetDataany The data to check.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectHasAProperty
Section titled “softExpectHasAProperty”Softly asserts that the target data has a property with the specified name.
Parameters
Section titled “Parameters”targetDataany The data to check.propertyNamestring The property name to check for.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectHasProperty
Section titled “softExpectHasProperty”Softly asserts that the target data has the specified property.
Parameters
Section titled “Parameters”targetDataany The data to check.propertyNamestring The property name to check for.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectJsonSchema
Section titled “softExpectJsonSchema”Softly asserts that the target data matches the given JSON schema.
Parameters
Section titled “Parameters”targetDataany The data to validate.jsonSchemaObject The JSON schema to validate against.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectJsonSchemaUsingAJV
Section titled “softExpectJsonSchemaUsingAJV”Softly asserts that the target data matches the given JSON schema using AJV.
Parameters
Section titled “Parameters”targetDataany The data to validate.jsonSchemaObject The JSON schema to validate against.customErrorMsgstring A custom error message to display if the assertion fails.ajvOptionsObject Options to pass to AJV.
softExpectLengthAboveThan
Section titled “softExpectLengthAboveThan”Softly asserts that the length of the target data is above a specified value.
Parameters
Section titled “Parameters”targetDataany The data to check.lengthAboveThannumber The length that the target data should be above.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectLengthBelowThan
Section titled “softExpectLengthBelowThan”Softly asserts that the length of the target data is below a specified value.
Parameters
Section titled “Parameters”targetDataany The data to check.lengthBelowThannumber The length that the target data should be below.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectLengthOf
Section titled “softExpectLengthOf”Softly asserts that the target data has a specified length.
Parameters
Section titled “Parameters”targetDataany The data to check.lengthnumber The expected length.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectMatchesPattern
Section titled “softExpectMatchesPattern”Softly asserts that a value matches the expected pattern.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedPatternany The pattern the value should match.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectNotContain
Section titled “softExpectNotContain”Softly asserts that a value does not contain the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToNotContainany The value that should not be contained within the actual value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectNotDeepEqual
Section titled “softExpectNotDeepEqual”Softly asserts that two values are not deeply equal.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueany The expected value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectNotEndsWith
Section titled “softExpectNotEndsWith”Softly asserts that a value does not end with the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToNotEndWithany The value that the actual value should not end with.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectNotEqual
Section titled “softExpectNotEqual”Softly asserts that two values are not equal.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueany The expected value.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectNotStartsWith
Section titled “softExpectNotStartsWith”Softly asserts that a value does not start with the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToNotStartWithany The value that the actual value should not start with.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectStartsWith
Section titled “softExpectStartsWith”Softly asserts that a value starts with the expected value.
Parameters
Section titled “Parameters”actualValueany The actual value.expectedValueToStartWithany The value that the actual value should start with.customErrorMsgstring A custom error message to display if the assertion fails.
softExpectToBeA
Section titled “softExpectToBeA”Softly asserts that the target data is of a specific type.
Parameters
Section titled “Parameters”targetDataany The data to check.typestring The expected type (e.g., ‘string’, ‘number’).customErrorMsgstring A custom error message to display if the assertion fails.
softExpectToBeAn
Section titled “softExpectToBeAn”Softly asserts that the target data is of a specific type (alternative for articles).
Parameters
Section titled “Parameters”targetDataany The data to check.typestring The expected type (e.g., ‘string’, ‘number’).customErrorMsgstring A custom error message to display if the assertion fails.
softExpectTrue
Section titled “softExpectTrue”Softly asserts that the target data is true.
Parameters
Section titled “Parameters”targetDataany The data to check.customErrorMsgstring A custom error message to display if the assertion fails.