Skip to content

Commit a555521

Browse files
committed
Mock Animated View to prevent out of memory error when a ref is set
callstack/react-native-testing-library#539
1 parent 3c502ce commit a555521

18 files changed

+1046
-879
lines changed

packages/mobile/jest_setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ afterEach(cleanup)
2020

2121
// Mock LayoutAnimation as it's done not automatically
2222
jest.mock('react-native/Libraries/LayoutAnimation/LayoutAnimation.js')
23+
24+
// Mock Animated Views this way otherwise we get a
25+
// `JavaScript heap out of memory` error when a ref is set (?!)
26+
// See https://github.com/callstack/react-native-testing-library/issues/539
27+
jest.mock('react-native/Libraries/Animated/src/components/AnimatedView.js', () => 'View')
28+
jest.mock(
29+
'react-native/Libraries/Animated/src/components/AnimatedScrollView.js',
30+
() => 'RCTScrollView'
31+
)

packages/mobile/src/account/__snapshots__/FiatExchange.test.tsx.snap

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ exports[`FiatExchange renders correctly 1`] = `
4141
onResponderTerminationRequest={[Function]}
4242
onStartShouldSetResponder={[Function]}
4343
style={
44-
Object {
45-
"left": 0,
46-
"marginBottom": 0,
47-
"marginLeft": 16,
48-
"opacity": 1,
49-
"padding": 0,
50-
"position": "absolute",
51-
}
44+
Array [
45+
Object {
46+
"left": 0,
47+
"marginBottom": 0,
48+
"marginLeft": 16,
49+
"padding": 0,
50+
"position": "absolute",
51+
},
52+
Object {
53+
"opacity": 1,
54+
},
55+
]
5256
}
5357
testID="Hamburguer"
5458
>

packages/mobile/src/account/__snapshots__/GoldEducation.test.tsx.snap

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ exports[`renders correctly 1`] = `
4545
onResponderTerminationRequest={[Function]}
4646
onStartShouldSetResponder={[Function]}
4747
style={
48-
Object {
49-
"left": 0,
50-
"marginBottom": 0,
51-
"marginLeft": 16,
52-
"opacity": 1,
53-
"padding": 0,
54-
"position": "absolute",
55-
}
48+
Array [
49+
Object {
50+
"left": 0,
51+
"marginBottom": 0,
52+
"marginLeft": 16,
53+
"padding": 0,
54+
"position": "absolute",
55+
},
56+
Object {
57+
"opacity": 1,
58+
},
59+
]
5660
}
5761
testID="Hamburguer"
5862
>

packages/mobile/src/account/__snapshots__/Settings.test.tsx.snap

Lines changed: 86 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ exports[`Account renders correctly 1`] = `
4040
onResponderTerminationRequest={[Function]}
4141
onStartShouldSetResponder={[Function]}
4242
style={
43-
Object {
44-
"left": 0,
45-
"marginBottom": 0,
46-
"marginLeft": 16,
47-
"opacity": 1,
48-
"padding": 0,
49-
"position": "absolute",
50-
}
43+
Array [
44+
Object {
45+
"left": 0,
46+
"marginBottom": 0,
47+
"marginLeft": 16,
48+
"padding": 0,
49+
"position": "absolute",
50+
},
51+
Object {
52+
"opacity": 1,
53+
},
54+
]
5155
}
5256
testID="Hamburguer"
5357
>
@@ -2297,14 +2301,18 @@ exports[`Account renders correctly when dev mode active 1`] = `
22972301
onResponderTerminationRequest={[Function]}
22982302
onStartShouldSetResponder={[Function]}
22992303
style={
2300-
Object {
2301-
"left": 0,
2302-
"marginBottom": 0,
2303-
"marginLeft": 16,
2304-
"opacity": 1,
2305-
"padding": 0,
2306-
"position": "absolute",
2307-
}
2304+
Array [
2305+
Object {
2306+
"left": 0,
2307+
"marginBottom": 0,
2308+
"marginLeft": 16,
2309+
"padding": 0,
2310+
"position": "absolute",
2311+
},
2312+
Object {
2313+
"opacity": 1,
2314+
},
2315+
]
23082316
}
23092317
testID="Hamburguer"
23102318
>
@@ -3349,10 +3357,14 @@ exports[`Account renders correctly when dev mode active 1`] = `
33493357
onResponderTerminationRequest={[Function]}
33503358
onStartShouldSetResponder={[Function]}
33513359
style={
3352-
Object {
3353-
"opacity": 1,
3354-
"width": 215,
3355-
}
3360+
Array [
3361+
Object {
3362+
"width": 215,
3363+
},
3364+
Object {
3365+
"opacity": 1,
3366+
},
3367+
]
33563368
}
33573369
>
33583370
<Text
@@ -3388,9 +3400,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
33883400
onResponderTerminationRequest={[Function]}
33893401
onStartShouldSetResponder={[Function]}
33903402
style={
3391-
Object {
3392-
"opacity": 1,
3393-
}
3403+
Array [
3404+
undefined,
3405+
Object {
3406+
"opacity": 1,
3407+
},
3408+
]
33943409
}
33953410
>
33963411
<Text>
@@ -3417,9 +3432,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
34173432
onResponderTerminationRequest={[Function]}
34183433
onStartShouldSetResponder={[Function]}
34193434
style={
3420-
Object {
3421-
"opacity": 1,
3422-
}
3435+
Array [
3436+
undefined,
3437+
Object {
3438+
"opacity": 1,
3439+
},
3440+
]
34233441
}
34243442
>
34253443
<Text>
@@ -3446,9 +3464,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
34463464
onResponderTerminationRequest={[Function]}
34473465
onStartShouldSetResponder={[Function]}
34483466
style={
3449-
Object {
3450-
"opacity": 1,
3451-
}
3467+
Array [
3468+
undefined,
3469+
Object {
3470+
"opacity": 1,
3471+
},
3472+
]
34523473
}
34533474
>
34543475
<Text>
@@ -3475,9 +3496,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
34753496
onResponderTerminationRequest={[Function]}
34763497
onStartShouldSetResponder={[Function]}
34773498
style={
3478-
Object {
3479-
"opacity": 1,
3480-
}
3499+
Array [
3500+
undefined,
3501+
Object {
3502+
"opacity": 1,
3503+
},
3504+
]
34813505
}
34823506
>
34833507
<Text>
@@ -3504,9 +3528,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
35043528
onResponderTerminationRequest={[Function]}
35053529
onStartShouldSetResponder={[Function]}
35063530
style={
3507-
Object {
3508-
"opacity": 1,
3509-
}
3531+
Array [
3532+
undefined,
3533+
Object {
3534+
"opacity": 1,
3535+
},
3536+
]
35103537
}
35113538
>
35123539
<Text>
@@ -3533,9 +3560,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
35333560
onResponderTerminationRequest={[Function]}
35343561
onStartShouldSetResponder={[Function]}
35353562
style={
3536-
Object {
3537-
"opacity": 1,
3538-
}
3563+
Array [
3564+
undefined,
3565+
Object {
3566+
"opacity": 1,
3567+
},
3568+
]
35393569
}
35403570
>
35413571
<Text>
@@ -3562,9 +3592,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
35623592
onResponderTerminationRequest={[Function]}
35633593
onStartShouldSetResponder={[Function]}
35643594
style={
3565-
Object {
3566-
"opacity": 1,
3567-
}
3595+
Array [
3596+
undefined,
3597+
Object {
3598+
"opacity": 1,
3599+
},
3600+
]
35683601
}
35693602
>
35703603
<Text>
@@ -4818,14 +4851,18 @@ exports[`Account renders correctly when verification is not possible 1`] = `
48184851
onResponderTerminationRequest={[Function]}
48194852
onStartShouldSetResponder={[Function]}
48204853
style={
4821-
Object {
4822-
"left": 0,
4823-
"marginBottom": 0,
4824-
"marginLeft": 16,
4825-
"opacity": 1,
4826-
"padding": 0,
4827-
"position": "absolute",
4828-
}
4854+
Array [
4855+
Object {
4856+
"left": 0,
4857+
"marginBottom": 0,
4858+
"marginLeft": 16,
4859+
"padding": 0,
4860+
"position": "absolute",
4861+
},
4862+
Object {
4863+
"opacity": 1,
4864+
},
4865+
]
48294866
}
48304867
testID="Hamburguer"
48314868
>

packages/mobile/src/account/__snapshots__/Support.test.tsx.snap

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ exports[`Support renders correctly 1`] = `
4040
onResponderTerminationRequest={[Function]}
4141
onStartShouldSetResponder={[Function]}
4242
style={
43-
Object {
44-
"left": 0,
45-
"marginBottom": 0,
46-
"marginLeft": 16,
47-
"opacity": 1,
48-
"padding": 0,
49-
"position": "absolute",
50-
}
43+
Array [
44+
Object {
45+
"left": 0,
46+
"marginBottom": 0,
47+
"marginLeft": 16,
48+
"padding": 0,
49+
"position": "absolute",
50+
},
51+
Object {
52+
"opacity": 1,
53+
},
54+
]
5155
}
5256
testID="Hamburguer"
5357
>

0 commit comments

Comments
 (0)