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 44
55import * as isModule from '../src/is' ;
66import { normalize } from '../src/normalize' ;
7+ import * as stacktraceModule from '../src/stacktrace' ;
78import { testOnlyIfNodeVersionAtLeast } from './testutils' ;
89
910describe ( 'normalize()' , ( ) => {
@@ -472,6 +473,19 @@ describe('normalize()', () => {
472473 } ) ;
473474 } ) ;
474475
476+ describe ( 'handles serialization errors' , ( ) => {
477+ test ( 'restricts effect of error to problematic node' , ( ) => {
478+ jest . spyOn ( stacktraceModule , 'getFunctionName' ) . mockImplementationOnce ( ( ) => {
479+ throw new Error ( 'Nope' ) ;
480+ } ) ;
481+
482+ expect ( normalize ( { dogs : 'are great!' , someFunc : ( ) => { } } ) ) . toEqual ( {
483+ dogs : 'are great!' ,
484+ someFunc : '**non-serializable** (Error: Nope)' ,
485+ } ) ;
486+ } ) ;
487+ } ) ;
488+
475489 test ( 'normalizes value on every iteration of decycle and takes care of things like Reacts SyntheticEvents' , ( ) => {
476490 const obj = {
477491 foo : {
You can’t perform that action at this time.
0 commit comments