Error messages should be informative and include the actual values that caused the problem, not just generic descriptions. Use centralized error message utilities and ensure both the message and stack trace are properly updated.
Key practices:
$errUtils.modifyErrMsg
to ensure consistency between message and stack traceExample from the discussions:
// Bad - vague and unhelpful
throw new Error('cy.session optional third argument must be an object')
// Good - includes actual problematic value
throw new Error(`cy.session optional third argument must be an object, you passed: ${typeof options}`)
// Better - uses proper error utilities and centralized messages
$errUtils.throwErrByPath('sessions.invalid_options', {
args: { expectedType: 'object', actualType: typeof options, actualValue: options }
})
This approach helps developers quickly understand what went wrong and how to fix it, reducing debugging time and improving the development experience.
Enter the URL of a public GitHub repository