@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
import { useState } from 'react' ;
5
5
6
6
import type { ErrorBoundaryProps } from '../src/errorboundary' ;
7
- import { ErrorBoundary , isAtLeastReact17 , UNKNOWN_COMPONENT , withErrorBoundary } from '../src/errorboundary' ;
7
+ import { ErrorBoundary , isAtLeastReact17 , setCause , UNKNOWN_COMPONENT , withErrorBoundary } from '../src/errorboundary' ;
8
8
9
9
const mockCaptureException = jest . fn ( ) ;
10
10
const mockShowReportDialog = jest . fn ( ) ;
@@ -382,15 +382,14 @@ describe('ErrorBoundary', () => {
382
382
expect ( cause . name ) . not . toContain ( 'React ErrorBoundary' ) ;
383
383
} ) ;
384
384
385
- it ( 'should truncate cause.message to 250 characters ' , ( ) => {
385
+ it ( 'should truncate cause.message to maxLengthValue = 250 ' , ( ) => {
386
386
const mockOnError = jest . fn ( ) ;
387
387
388
388
function CustomBam ( ) : JSX . Element {
389
- const error = new Error ( 'bam ' ) ;
390
- // The cause message with 610 characters
389
+ const error = new Error ( 'Error example ' ) ;
390
+ // The cause message with 620 characters
391
391
const cause = new Error ( 'This is a very long cause message that exceeds 250 characters ' . repeat ( 10 ) ) ;
392
- // @ts -ignore Need to set cause on error
393
- error . cause = cause ;
392
+ setCause ( error , cause ) ;
394
393
throw error ;
395
394
}
396
395
0 commit comments