File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import * as isModule from '../src/is' ;
6
6
import { normalize } from '../src/normalize' ;
7
+ import * as stacktraceModule from '../src/stacktrace' ;
7
8
import { testOnlyIfNodeVersionAtLeast } from './testutils' ;
8
9
9
10
describe ( 'normalize()' , ( ) => {
@@ -469,6 +470,19 @@ describe('normalize()', () => {
469
470
} ) ;
470
471
} ) ;
471
472
473
+ describe ( 'handles serialization errors' , ( ) => {
474
+ test ( 'restricts effect of error to problematic node' , ( ) => {
475
+ jest . spyOn ( stacktraceModule , 'getFunctionName' ) . mockImplementationOnce ( ( ) => {
476
+ throw new Error ( 'Nope' ) ;
477
+ } ) ;
478
+
479
+ expect ( normalize ( { dogs : 'are great!' , someFunc : ( ) => { } } ) ) . toEqual ( {
480
+ dogs : 'are great!' ,
481
+ someFunc : '**non-serializable** (Error: Nope)' ,
482
+ } ) ;
483
+ } ) ;
484
+ } ) ;
485
+
472
486
test ( 'normalizes value on every iteration of decycle and takes care of things like Reacts SyntheticEvents' , ( ) => {
473
487
const obj = {
474
488
foo : {
You can’t perform that action at this time.
0 commit comments