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()' , ( ) => {
@@ -472,6 +473,19 @@ describe('normalize()', () => {
472
473
} ) ;
473
474
} ) ;
474
475
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
+
475
489
test ( 'normalizes value on every iteration of decycle and takes care of things like Reacts SyntheticEvents' , ( ) => {
476
490
const obj = {
477
491
foo : {
You can’t perform that action at this time.
0 commit comments