Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/driver/cypress/integration/cypress/error_utils_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,18 @@ describe('driver/src/cypress/error_utils', () => {
expect(stack).not.to.include('removeMeAndAbove')
})
})

context('.wrapErr', () => {
[
{ value: undefined, label: 'undefined' },
{ value: null, label: 'null' },
{ value: '', label: 'empty string' },
{ value: true, label: 'boolean' },
{ value: 1, label: 'number' },
].forEach((err) => {
it(`returns undefined if err is ${err.label}`, () => {
expect($errUtils.wrapErr(err.value)).to.be.undefined
})
})
})
})
8 changes: 7 additions & 1 deletion packages/driver/src/cypress/error_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ const prepareErrorForSerialization = (err) => {
return err
}

// some errors, probably from user callbacks, might be boolean, number or falsy values
// which means serializing will not provide any useful context
const isSerializableError = (err) => {
return !!err && (typeof err === 'object' || typeof err === 'string')
}

const wrapErr = (err) => {
if (!err) return
if (!isSerializableError(err)) return

prepareErrorForSerialization(err)

Expand Down