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()' , ( ) => {
@@ -469,6 +470,19 @@ describe('normalize()', () => {
469470 } ) ;
470471 } ) ;
471472
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+
472486 test ( 'normalizes value on every iteration of decycle and takes care of things like Reacts SyntheticEvents' , ( ) => {
473487 const obj = {
474488 foo : {
You can’t perform that action at this time.
0 commit comments