diff --git a/apps/common-app/src/examples/RuntimeTests/tests/advancedAPI/useFrameCallback.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/advancedAPI/useFrameCallback.test.tsx index ebd77257f49..01d38bf7080 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/advancedAPI/useFrameCallback.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/advancedAPI/useFrameCallback.test.tsx @@ -39,7 +39,7 @@ describe('Test *****useFrameCallback*****', () => { await wait(timeToStop + 200); const expectedWidth = timeToStop / 8; - expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(expectedWidth - 1, expectedWidth + 2); + expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(expectedWidth - 5, expectedWidth + 5); }); }); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withDecay/basic.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/animations/withDecay/basic.test.tsx index 3401382081a..de709f69eef 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withDecay/basic.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withDecay/basic.test.tsx @@ -51,7 +51,7 @@ describe('withDecay animation, test various config', () => { { velocity: 900, clamp: [0, 150], rubberBandEffect: true }, { velocity: 2000, clamp: [0, 150], rubberBandEffect: true }, { velocity: 2000, clamp: [0, 150], rubberBandEffect: true, rubberBandFactor: 2 }, - ] as Array)('Config ${0}', async config => { + ] as Array)('Config %p', async config => { const snapshotName = ('decay_' + Object.entries(config) .map(([key, val]) => { diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/arrays.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/arrays.test.tsx index 4b97d6442ad..31bb76c0559 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/arrays.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/arrays.test.tsx @@ -8,9 +8,19 @@ import Animated, { Easing, withDelay, } from 'react-native-reanimated'; -import { describe, test, render, wait, useTestRef, getTestComponent, expect } from '../../../ReJest/RuntimeTestsApi'; +import { + describe, + test, + render, + wait, + useTestRef, + getTestComponent, + expect, + recordAnimationUpdates, + mockAnimationTimer, +} from '../../../ReJest/RuntimeTestsApi'; import { View, StyleSheet } from 'react-native'; -import { ComparisonMode } from '../../../ReJest/types'; +import { ArraySnapshots } from './snapshots.snapshot'; type TestCase = { startValues: [number, number, number]; @@ -91,6 +101,9 @@ describe('withSequence animation of array', () => { ] as Array)( 'Animate ${startValues} → ${finalValues} → ${middleValues} → ${finalValues}, animation nr ${animationNumber}', async ({ startValues, middleValues, finalValues, animationNumber }) => { + await mockAnimationTimer(); + const updatesContainer = await recordAnimationUpdates(); + await render( { animationNumber={animationNumber} />, ); - const componentOne = getTestComponent(COMPONENT_REF.first); - const componentTwo = getTestComponent(COMPONENT_REF.second); - const componentThree = getTestComponent(COMPONENT_REF.third); - const margin = 30; - await wait(200 + DELAY / 2); - expect(await componentOne.getAnimatedStyle('left')).toBe(finalValues[0] + margin, ComparisonMode.PIXEL); - expect(await componentTwo.getAnimatedStyle('left')).toBe(finalValues[1] + margin, ComparisonMode.PIXEL); - expect(await componentThree.getAnimatedStyle('left')).toBe(finalValues[2] + margin, ComparisonMode.PIXEL); - await wait(300 + DELAY / 2); - expect(await componentOne.getAnimatedStyle('left')).toBe(middleValues[0] + margin, ComparisonMode.PIXEL); - expect(await componentTwo.getAnimatedStyle('left')).toBe(middleValues[1] + margin, ComparisonMode.PIXEL); - expect(await componentThree.getAnimatedStyle('left')).toBe(middleValues[2] + margin, ComparisonMode.PIXEL); - await wait(200 + DELAY); - expect(await componentOne.getAnimatedStyle('left')).toBe(finalValues[0] + 20 + margin, ComparisonMode.PIXEL); - expect(await componentTwo.getAnimatedStyle('left')).toBe(finalValues[1] + 20 + margin, ComparisonMode.PIXEL); - expect(await componentThree.getAnimatedStyle('left')).toBe(finalValues[2] + 20 + margin, ComparisonMode.PIXEL); + const snapshotNamePrefix = `from_${startValues.join('_')}_through_${middleValues.join('_')}_to_${finalValues.join( + '_', + )}_animation_${animationNumber}`.replace('-', 'min'); + + await wait(1000); // waitForAnimationUpdates doesn't work with multiple view recordings + + for (const refName of ['first', 'second', 'third'] as const) { + const snapshotName = `${snapshotNamePrefix}_${refName}` as keyof typeof ArraySnapshots; + + expect(updatesContainer.getUpdates(getTestComponent(COMPONENT_REF[refName]))).toMatchSnapshots( + ArraySnapshots[snapshotName], + ); + } }, ); }); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/callbackCascade.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/callbackCascade.test.tsx index 842c0ac7b04..feb135420a8 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/callbackCascade.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/callbackCascade.test.tsx @@ -19,6 +19,8 @@ import { getRegisteredValue, registerValue, waitForAnimationUpdates, + waitForNotify, + notify, } from '../../../ReJest/RuntimeTestsApi'; import { Snapshots } from './snapshots.snapshot'; @@ -183,6 +185,7 @@ describe(`Test all callbacks have been called in valid order`, () => { // finishes at 900 withTiming(200, { duration: 400 }, () => { callbackArray.value = [...callbackArray.value, 'NINE']; + notify('lastCallback'); }), ); }); @@ -202,7 +205,7 @@ describe(`Test all callbacks have been called in valid order`, () => { await mockAnimationTimer(); const updatesContainerActive = await recordAnimationUpdates(); await render(); - await waitForAnimationUpdates(Snapshots.CallbackOrder.length); + await waitForNotify('lastCallback'); const updates = updatesContainerActive.getUpdates(); const nativeUpdates = await updatesContainerActive.getNativeSnapshots(); expect(updates).toMatchSnapshots(Snapshots.CallbackOrder); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/snapshots.snapshot.ts b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/snapshots.snapshot.ts index a32a831d600..29e299b3396 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/snapshots.snapshot.ts +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withSequence/snapshots.snapshot.ts @@ -1,4 +1,30 @@ export const Snapshots = { CallbackCascade: [{"height":20.32,"top":0,"width":20},{"height":21.28,"top":0,"width":20},{"height":22.88,"top":0,"width":20},{"height":25.12,"top":0,"width":20},{"height":28,"top":0,"width":20},{"height":31.52,"top":0,"width":20},{"height":35.68,"top":0,"width":20},{"height":40.480000000000004,"top":0,"width":20},{"height":45.92,"top":0,"width":20},{"height":52.00000000000001,"top":0,"width":20},{"height":58.72,"top":0,"width":20},{"height":66.08,"top":0,"width":20},{"height":73.92,"top":0,"width":20},{"height":81.28,"top":0,"width":20},{"height":88,"top":0,"width":20},{"height":94.08,"top":0,"width":20},{"height":99.52000000000001,"top":0,"width":20},{"height":104.32,"top":0,"width":20},{"height":108.48,"top":0,"width":20},{"height":112,"top":0,"width":20},{"height":114.88,"top":0,"width":20},{"height":117.11999999999999,"top":0,"width":20},{"height":118.72,"top":0,"width":20},{"height":119.68,"top":0,"width":20},{"height":120,"top":0,"width":20},{"height":119.54488888888889,"top":0,"width":20.028444444444446},{"height":118.17955555555555,"top":0,"width":20.113777777777777},{"height":115.904,"top":0,"width":20.256},{"height":112.71822222222222,"top":0,"width":20.455111111111112},{"height":108.62222222222222,"top":0,"width":20.711111111111112},{"height":103.616,"top":0,"width":21.024},{"height":97.69955555555555,"top":0,"width":21.39377777777778},{"height":90.87288888888888,"top":0,"width":21.820444444444444},{"height":83.136,"top":0,"width":22.304},{"height":74.84444444444445,"top":0,"width":22.844444444444445},{"height":67.33511111111112,"top":0,"width":23.44177777777778},{"height":60.736,"top":0,"width":24.096},{"height":55.04711111111111,"top":0,"width":24.807111111111112},{"height":50.26844444444444,"top":0,"width":25.575111111111113},{"height":46.39999999999999,"top":0,"width":26.400000000000002},{"height":43.44177777777777,"top":0,"width":27.28177777777778},{"height":41.393777777777785,"top":0,"width":28.220444444444443},{"height":40.256,"top":0,"width":29.216},{"height":40,"top":0,"width":30.26488888888889},{"height":40.576,"top":8.11355102947627,"width":65.78968999558386},{"height":42.304,"top":25.637413972281905,"width":127.66265235959303},{"height":45.184,"top":45.94949907449062,"width":173.39386881650358},{"height":49.216,"top":65.63156033870584,"width":191.7333034401837},{"height":54.400000000000006,"top":83.1184254598458,"width":190.0070325072947},{"height":60.736000000000004,"top":97.87705282784722,"width":180.33957821769178},{"height":68.224,"top":109.91665760527567,"width":171.53403630546734},{"height":76.864,"top":119.50348550522719,"width":167.02769751854723},{"height":86.656,"top":127.00039429751021,"width":166.3963583104561},{"height":97.60000000000001,"top":132.7812481647999,"width":167.72860081921837},{"height":109.696,"top":137.18914038581056,"width":169.31940520394326},{"height":122.944,"top":140.51948592000025,"width":170.31335735425753},{"height":137.05599999999998,"top":143.01657138088473,"width":170.60516092612443},{"height":150.304,"top":144.87683812149274,"width":170.46208642898188},{"height":162.39999999999998,"top":146.2550516590432,"width":170.19400330604017},{"height":173.344,"top":147.27124979015753,"width":169.9911502240215},{"height":183.13600000000002,"top":148.01739192451524,"width":169.90703504305213},{"height":191.77599999999998,"top":148.56322592499936,"width":169.91195887531606},{"height":199.264,"top":150,"width":169.95334038302818},{"height":205.6,"top":142.88008590592372,"width":169.99210275310344},{"height":210.784,"top":126.8795893968295,"width":170.01244994003898},{"height":214.816,"top":108.13990792374766,"width":170.0157332766819},{"height":217.696,"top":89.86315950081254,"width":170.01014554042317},{"height":219.424,"top":73.53975858870585,"width":170.00319752429016},{"height":220,"top":59.69876710887795,"width":169.9987560561899},{"height":220,"top":48.35849832702202,"width":169.9973824676853},{"height":220,"top":39.29080883214692,"width":169.99795293962688},{"height":220,"top":32.17108147552973,"width":169.99911305581472},{"height":220,"top":26.65922856419261,"width":170.00001202276414},{"height":220,"top":22.439969656980633,"width":170.0003969114859},{"height":220,"top":19.239780156329363,"width":170.00038707239574},{"height":220,"top":16.831056166389086,"width":170},{"height":220,"top":15.02975953569973,"width":170},{"height":220,"top":13.69016208374916,"width":170},{"height":220,"top":12.698697852752636,"width":170},{"height":220,"top":11.967970412620131,"width":170},{"height":220,"top":11.431402205594173,"width":170},{"height":220,"top":10,"width":170}], CallbackOrder: [{"height": 30.240000000000002, "top": 0, "width": 20}, {"height": 60.96, "top": 0, "width": 20}, {"height": 112.16, "top": 0, "width": 20}, {"height": 168.16, "top": 0, "width": 20}, {"height": 204, "top": 0, "width": 20}, {"height": 219.36, "top": 0, "width": 20}, {"height": 220, "top": 0, "width": 20}, {"height": 218.72, "top": 0, "width": 25.12}, {"height": 214.88, "top": 0, "width": 40.480000000000004}, {"height": 208.48, "top": 0, "width": 66.08}, {"height": 199.52, "top": 0, "width": 94.08}, {"height": 188, "top": 0, "width": 112}, {"height": 173.92000000000002, "top": 0, "width": 119.68}, {"height": 158.72, "top": 0, "width": 120}, {"height": 145.92000000000002, "top": 0, "width": 119.92888888888889}, {"height": 135.68, "top": 0, "width": 119.71555555555555}, {"height": 128, "top": 0, "width": 119.36}, {"height": 122.88000000000001, "top": 0, "width": 118.86222222222221}, {"height": 120.32, "top": 0, "width": 118.22222222222223}, {"height": 120, "top": 0, "width": 117.44}, {"height": 121.28, "top": 3.413333333333334, "width": 116.51555555555555}, {"height": 125.12, "top": 13.653333333333336, "width": 115.44888888888889}, {"height": 131.51999999999998, "top": 30.720000000000002, "width": 114.24}, {"height": 140.48000000000002, "top": 54.613333333333344, "width": 112.88888888888889}, {"height": 152, "top": 84.66666666666666, "width": 111.39555555555556}, {"height": 166.07999999999998, "top": 111.12, "width": 109.76}, {"height": 181.28, "top": 130.74666666666667, "width": 107.98222222222222}, {"height": 194.07999999999998, "top": 143.54666666666668, "width": 106.06222222222222}, {"height": 204.32, "top": 149.52, "width": 104}, {"height": 212, "top": 150, "width": 101.79555555555555}, {"height": 217.12, "top": 150, "width": 99.44888888888889}, {"height": 219.68, "top": 150, "width": 96.96000000000001}, {"height": 220, "top": 150, "width": 94.33777777777777}, {"height": 220, "top": 150, "width": 91.77777777777777}, {"height": 220, "top": 150, "width": 89.36}, {"height": 220, "top": 150, "width": 87.08444444444444}, {"height": 220, "top": 150, "width": 84.95111111111112}, {"height": 220, "top": 150, "width": 91.86561422222223}, {"height": 220, "top": 150, "width": 112.60912355555556}, {"height": 220, "top": 150, "width": 147.1816391111111}, {"height": 220, "top": 150, "width": 184.995328}, {"height": 220, "top": 150, "width": 209.19608888888888}, {"height": 220, "top": 150, "width": 219.56784355555556}, {"height": 220, "top": 150, "width": 220}], - } \ No newline at end of file + } + +export const ArraySnapshots = { + from_0_10_20_through_0_100_210_to_20_10_30_animation_0_first: [{"left":0.256},{"left":1.024},{"left":2.304},{"left":4.096},{"left":6.400000000000001},{"left":9.216},{"left":12.256},{"left":14.816},{"left":16.863999999999997},{"left":18.400000000000002},{"left":19.424},{"left":19.936},{"left":20},{"left":19.98046875},{"left":19.971733022706243},{"left":19.95909007332732},{"left":19.940792321620687},{"left":19.91431054846136},{"left":19.875984292814984},{"left":19.820515882031714},{"left":19.74023815745538},{"left":19.62405467622434},{"left":19.45590589793992},{"left":19.212549343815706},{"left":18.860346889302228},{"left":18.35061511153388},{"left":17.612895990223958},{"left":16.545217800080557},{"left":15},{"left":12.763653812798108},{"left":9.527058771793737},{"left":4.842834334896022},{"left":0},{"left":0.512},{"left":2.048},{"left":4.608},{"left":8.192},{"left":12.800000000000002},{"left":18.432},{"left":24.512},{"left":29.632},{"left":33.727999999999994},{"left":36.800000000000004},{"left":38.848},{"left":39.872},{"left":40}], + from_0_10_20_through_0_100_210_to_20_10_30_animation_0_second: [{"left":10.087890625},{"left":10.127201397821908},{"left":10.184094670027063},{"left":10.266434552706906},{"left":10.385602531923892},{"left":10.55807068233257},{"left":10.807678530857292},{"left":11.168928291450795},{"left":11.691753956990478},{"left":12.448423459270348},{"left":13.54352795282933},{"left":15.128438998139972},{"left":17.422231998097534},{"left":20.741968043992188},{"left":25.54651989963748},{"left":32.5},{"left":42.56355784240852},{"left":57.12823552692818},{"left":78.2072454929679},{"left":100},{"left":99.104},{"left":96.416},{"left":91.936},{"left":85.664},{"left":77.6},{"left":67.744},{"left":57.104},{"left":48.144},{"left":40.976000000000006},{"left":35.599999999999994},{"left":32.016000000000005},{"left":30.224000000000004},{"left":30}], + from_0_10_20_through_0_100_210_to_20_10_30_animation_0_third: [{"left":20.128},{"left":20.512},{"left":21.152},{"left":22.048000000000002},{"left":23.2},{"left":24.608},{"left":26.128},{"left":27.408},{"left":28.432},{"left":29.200000000000003},{"left":29.712},{"left":29.968},{"left":30},{"left":30.17578125},{"left":30.254402795643816},{"left":30.368189340054126},{"left":30.532869105413813},{"left":30.771205063847784},{"left":31.11614136466514},{"left":31.615357061714583},{"left":32.33785658290159},{"left":33.38350791398096},{"left":34.896846918540696},{"left":37.08705590565866},{"left":40.25687799627994},{"left":44.84446399619507},{"left":51.483936087984375},{"left":61.09303979927496},{"left":75},{"left":95.12711568481704},{"left":124.25647105385636},{"left":166.4144909859358},{"left":210},{"left":207.952},{"left":201.808},{"left":191.568},{"left":177.232},{"left":158.79999999999998},{"left":136.272},{"left":111.952},{"left":91.472},{"left":75.08800000000002},{"left":62.79999999999998},{"left":54.608000000000004},{"left":50.512},{"left":50}], + + from_0_10_20_through_0_150_160_to_40_10_30_animation_1_first: [{"left":8.559163415515652},{"left":20.589304696953164},{"left":29.217331445031864},{"left":34.35651991293822},{"left":37.157274554828966},{"left":38.60581693903682},{"left":39.32958029245378},{"left":39.682458802677175},{"left":39.85139103680226},{"left":39.93112506005838},{"left":39.96833528085268},{"left":39.98554086111488},{"left":40},{"left":37.617964091901214},{"left":32.567105013971855},{"left":26.831212343777796},{"left":21.387333574710667},{"left":16.65035048002396},{"left":12.735004994322079},{"left":9.607045814072777},{"left":7.167871692658363},{"left":5.299920833705458},{"left":3.8893722661524537},{"left":2.8361062778020028},{"left":2.056803714030677},{"left":1.4845891248183491},{"left":1.0671350822816175},{"left":0.7642643757095621},{"left":0.5455758677868093},{"left":0.38833134142790354},{"left":0.2756840846581654},{"left":0},{"left":17.259227259480397},{"left":38.87018041113208},{"left":51.61327510731403},{"left":57.32704781636066},{"left":59.40827255282417},{"left":59.99754033797124},{"left":60.09141001551934},{"left":60.06578263383605},{"left":60.032668501688455},{"left":60.013013550837144},{"left":60.00416620697964},{"left":60.00093150129856},{"left":60}], + from_0_10_20_through_0_150_160_to_40_10_30_animation_1_second: [{"left":21.85342147990403},{"left":45.09579103891957},{"left":69.29028928533191},{"left":90.31418605374498},{"left":107.05698704143543},{"left":119.7201524649452},{"left":128.97647898512056},{"left":135.58039533409098},{"left":140.20729132316606},{"left":143.40373592550304},{"left":145.58729238784207},{"left":147.06529116112384},{"left":148.05809677911213},{"left":148.7206915160907},{"left":149.1604639080504},{"left":149.450950379921},{"left":149.64202500326408},{"left":149.76724514304414},{"left":150},{"left":109.61387867932542},{"left":64.42140426053996},{"left":41.39143337144321},{"left":32.75354020528267},{"left":30.279000136858507},{"left":29.826948775161302},{"left":29.85722628953613},{"left":29.93296560068202},{"left":29.97627089831389},{"left":29.993676635327702},{"left":29.999053309584134},{"left":30.000207055912053},{"left":30}], + from_0_10_20_through_0_150_160_to_40_10_30_animation_1_third: [{"left":21.35713426253226},{"left":23.67071897136113},{"left":25.73089622590757},{"left":27.259023206327303},{"left":28.29710318016238},{"left":28.96662644905738},{"left":29.383889665967317},{"left":29.63768149044435},{"left":29.78926167229811},{"left":29.878525883809186},{"left":29.93050375515801},{"left":29.960492752681102},{"left":30},{"left":40.801609851538956},{"left":62.08065041794434},{"left":84.34681158786273},{"left":103.79726149552762},{"left":119.36918577881755},{"left":131.20937648910848},{"left":139.9101878278425},{"left":146.15082256317658},{"left":150.54648147960287},{"left":153.59935714266163},{"left":155.695951929435},{"left":157.1226518100982},{"left":158.08610697288623},{"left":158.7325409766657},{"left":159.16387454564693},{"left":159.4503058108953},{"left":159.63971752642345},{"left":159.76450971782356},{"left":160},{"left":123.69873649950695},{"left":82.45650386285129},{"left":61.017587782307906},{"left":52.775032584093864},{"left":50.330210412248164},{"left":49.84938421158118},{"left":49.86167444128908},{"left":49.93183827215577},{"left":49.97472832584356},{"left":49.99281939112328},{"left":49.99872563574945},{"left":50.00012349817555},{"left":50}], + + from_0_10_20_through_0_150_160_to_40_10_30_animation_2_first: [{"left":8.559163415515652},{"left":20.589304696953164},{"left":29.217331445031864},{"left":34.35651991293822},{"left":37.157274554828966},{"left":38.60581693903682},{"left":39.32958029245378},{"left":39.682458802677175},{"left":39.85139103680226},{"left":39.93112506005838},{"left":39.96833528085268},{"left":39.98554086111488},{"left":40},{"left":39.772444444444446},{"left":39.089777777777776},{"left":37.952},{"left":36.35911111111111},{"left":34.31111111111111},{"left":31.808},{"left":28.849777777777774},{"left":25.43644444444444},{"left":21.568},{"left":17.422222222222224},{"left":13.667555555555559},{"left":10.367999999999999},{"left":7.5235555555555536},{"left":5.1342222222222205},{"left":3.1999999999999957},{"left":1.7208888888888865},{"left":0.6968888888888927},{"left":0.1280000000000001},{"left":0},{"left":14.273376002962777},{"left":33.22765246317528},{"left":45.98046191574167},{"left":53.100186525557945},{"left":56.73593937680865},{"left":58.49769577124165},{"left":59.32235994306725},{"left":59.699023904547275},{"left":59.86794286219037},{"left":59.94262880062309},{"left":59.97527865242203},{"left":59.989420561599246},{"left":60}], + from_0_10_20_through_0_150_160_to_40_10_30_animation_2_second: [{"left":10.796444444444445},{"left":13.185777777777778},{"left":17.168},{"left":22.743111111111112},{"left":29.91111111111111},{"left":38.672},{"left":49.02577777777778},{"left":60.972444444444456},{"left":74.512},{"left":89.02222222222221},{"left":102.16355555555555},{"left":113.712},{"left":123.66755555555557},{"left":132.03022222222222},{"left":138.8},{"left":143.9768888888889},{"left":147.56088888888888},{"left":149.552},{"left":150},{"left":116.55491478119613},{"left":76.21551582266247},{"left":51.86416719409756},{"left":39.68485670602883},{"left":34.11573592299131},{"left":31.699844819230268},{"left":30.68757100556647},{"left":30.273728935899122},{"left":30.107617495253965},{"left":30.041883874258648},{"left":30.016165221314477},{"left":30.00619542007149},{"left":30}], + from_0_10_20_through_0_150_160_to_40_10_30_animation_2_third: [{"left":21.35713426253226},{"left":23.67071897136113},{"left":25.73089622590757},{"left":27.259023206327303},{"left":28.29710318016238},{"left":28.96662644905738},{"left":29.383889665967317},{"left":29.63768149044435},{"left":29.78926167229811},{"left":29.878525883809186},{"left":29.93050375515801},{"left":29.960492752681102},{"left":30},{"left":30.739555555555555},{"left":32.958222222222226},{"left":36.656},{"left":41.83288888888889},{"left":48.48888888888889},{"left":56.624},{"left":66.23822222222222},{"left":77.33155555555557},{"left":89.904},{"left":103.37777777777778},{"left":115.58044444444444},{"left":126.304},{"left":135.54844444444444},{"left":143.31377777777777},{"left":149.60000000000002},{"left":154.40711111111113},{"left":157.7351111111111},{"left":159.584},{"left":160},{"left":129.92185331333042},{"left":93.19047496710084},{"left":70.70443215166782},{"left":59.297227034493616},{"left":54.006239351866306},{"left":51.67797070624199},{"left":50.688356826930466},{"left":50.27794650491942},{"left":50.110836864721115},{"left":50.043754322385674},{"left":50.01712921514532},{"left":50.00665909371881},{"left":50}], + + from_30_10_55_through_0_min10_60_to_40_10_30_animation_0_first: [{"left":30.128},{"left":30.512},{"left":31.152},{"left":32.048},{"left":33.2},{"left":34.608},{"left":36.128},{"left":37.408},{"left":38.432},{"left":39.2},{"left":39.712},{"left":39.968},{"left":40},{"left":39.9609375},{"left":39.943466045412485},{"left":39.91818014665464},{"left":39.881584643241375},{"left":39.82862109692272},{"left":39.75196858562997},{"left":39.64103176406343},{"left":39.48047631491076},{"left":39.24810935244868},{"left":38.91181179587984},{"left":38.42509868763141},{"left":37.720693778604456},{"left":36.70123022306776},{"left":35.225791980447916},{"left":33.090435600161115},{"left":30},{"left":25.527307625596215},{"left":19.054117543587473},{"left":9.685668669792044},{"left":0},{"left":0.768},{"left":3.072},{"left":6.912},{"left":12.288},{"left":19.200000000000003},{"left":27.648},{"left":36.768},{"left":44.448},{"left":50.592},{"left":55.2},{"left":58.272},{"left":59.808},{"left":60}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_0_second: [{"left":9.98046875},{"left":9.971733022706243},{"left":9.959090073327319},{"left":9.940792321620687},{"left":9.914310548461357},{"left":9.875984292814984},{"left":9.820515882031714},{"left":9.740238157455378},{"left":9.624054676224338},{"left":9.455905897939923},{"left":9.212549343815704},{"left":8.860346889302228},{"left":8.350615111533882},{"left":7.612895990223958},{"left":6.545217800080559},{"left":4.999999999999999},{"left":2.7636538127981067},{"left":-0.4729412282062633},{"left":-5.157165665103978},{"left":-10},{"left":-9.488},{"left":-7.952},{"left":-5.392},{"left":-1.8079999999999998},{"left":2.8000000000000025},{"left":8.431999999999999},{"left":14.512},{"left":19.632},{"left":23.727999999999994},{"left":26.800000000000004},{"left":28.848},{"left":29.872},{"left":30}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_0_third: [{"left":54.68},{"left":53.72},{"left":52.12},{"left":49.88},{"left":47},{"left":43.480000000000004},{"left":39.68},{"left":36.480000000000004},{"left":33.92},{"left":32},{"left":30.720000000000002},{"left":30.08},{"left":30},{"left":30.029296875},{"left":30.042400465940638},{"left":30.06136489000902},{"left":30.088811517568967},{"left":30.128534177307962},{"left":30.186023560777524},{"left":30.26922617695243},{"left":30.38964276381693},{"left":30.563917985663494},{"left":30.816141153090115},{"left":31.181175984276443},{"left":31.709479666046658},{"left":32.474077332699174},{"left":33.580656014664065},{"left":35.18217329987916},{"left":37.5},{"left":40.85451928080284},{"left":45.70941184230939},{"left":52.73574849765596},{"left":60},{"left":59.872},{"left":59.488},{"left":58.848},{"left":57.952},{"left":56.8},{"left":55.392},{"left":53.872},{"left":52.592},{"left":51.568},{"left":50.8},{"left":50.288},{"left":50.032},{"left":50}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_1_first: [{"left":31.35713426253226},{"left":33.67071897136113},{"left":35.73089622590757},{"left":37.259023206327306},{"left":38.29710318016238},{"left":38.96662644905738},{"left":39.38388966596732},{"left":39.63768149044435},{"left":39.78926167229811},{"left":39.87852588380919},{"left":39.930503755158014},{"left":39.960492752681105},{"left":40},{"left":37.617964091901214},{"left":32.567105013971855},{"left":26.831212343777796},{"left":21.387333574710667},{"left":16.65035048002396},{"left":12.735004994322079},{"left":9.607045814072777},{"left":7.167871692658363},{"left":5.299920833705458},{"left":3.8893722661524537},{"left":2.8361062778020028},{"left":2.056803714030677},{"left":1.4845891248183491},{"left":1.0671350822816175},{"left":0.7642643757095621},{"left":0.5455758677868093},{"left":0.38833134142790354},{"left":0.2756840846581654},{"left":0},{"left":17.259227259480397},{"left":38.87018041113208},{"left":51.61327510731403},{"left":57.32704781636066},{"left":59.40827255282417},{"left":59.99754033797124},{"left":60.09141001551934},{"left":60.06578263383605},{"left":60.032668501688455},{"left":60.013013550837144},{"left":60.00416620697964},{"left":60.00093150129856},{"left":60}], + + from_30_10_55_through_0_min10_60_to_40_10_30_animation_1_second: [{"left":9.059723255004304},{"left":6.97764331855856},{"left":4.496584902016112},{"left":2.0241233771907456},{"left":-0.2353151873705741},{"left":-2.196814466215799},{"left":-3.8427805923501284},{"left":-5.1909913002609205},{"left":-6.275527918553319},{"left":-7.135801396330851},{"left":-7.810578726799025},{"left":-8.335030522422755},{"left":-8.73954848525658},{"left":-9.049553563222995},{"left":-9.285818958048198},{"left":-9.465025017595803},{"left":-9.600384009046083},{"left":-9.702247330459965},{"left":-10},{"left":0.36807579633802234},{"left":14.218393947784467},{"left":23.088479335563317},{"left":27.476034987899215},{"left":29.28423306941238},{"left":29.898150685153972},{"left":30.04946216913706},{"left":30.05658203820182},{"left":30.03496218585239},{"left":30.016937070019583},{"left":30.006850724037626},{"left":30.00226965276012},{"left":30}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_1_third: [{"left":50.329091115756924},{"left":43.32089872469092},{"left":37.91204659789942},{"left":34.44159345211323},{"left":32.40358124360682},{"left":31.26761192112008},{"left":30.655868085027784},{"left":30.334386516489616},{"left":30.168498778420496},{"left":30.084102125833834},{"left":30.04164702199076},{"left":30.020486431940448},{"left":30},{"left":31.626390968692544},{"left":35.137634341942956},{"left":39.20564867790789},{"left":43.145616681801044},{"left":46.64448280602696},{"left":49.59606020898924},{"left":52.00271093350113},{"left":53.91814965454245},{"left":55.415308810615144},{"left":56.56921390050925},{"left":57.44864410654866},{"left":58.112772411448496},{"left":58.61049615749149},{"left":58.98111066796657},{"left":59.255556056207375},{"left":59.45781607097058},{"left":59.60625418076145},{"left":59.714790886238895},{"left":60},{"left":58.35395820367722},{"left":55.62125260563895},{"left":53.32808714983231},{"left":51.78161192247275},{"left":50.864585666211404},{"left":50.37300281372522},{"left":50.1340936807805},{"left":50.030819556767476},{"left":49.99356115271556},{"left":49.9848954906918},{"left":49.98658143365226},{"left":49.99070299438813},{"left":50}], + + from_30_10_55_through_0_min10_60_to_40_10_30_animation_2_first: [{"left":31.35713426253226},{"left":33.67071897136113},{"left":35.73089622590757},{"left":37.259023206327306},{"left":38.29710318016238},{"left":38.96662644905738},{"left":39.38388966596732},{"left":39.63768149044435},{"left":39.78926167229811},{"left":39.87852588380919},{"left":39.930503755158014},{"left":39.960492752681105},{"left":40},{"left":39.772444444444446},{"left":39.089777777777776},{"left":37.952},{"left":36.35911111111111},{"left":34.31111111111111},{"left":31.808},{"left":28.849777777777774},{"left":25.43644444444444},{"left":21.568},{"left":17.422222222222224},{"left":13.667555555555559},{"left":10.367999999999999},{"left":7.5235555555555536},{"left":5.1342222222222205},{"left":3.1999999999999957},{"left":1.7208888888888865},{"left":0.6968888888888927},{"left":0.1280000000000001},{"left":0},{"left":14.273376002962777},{"left":33.22765246317528},{"left":45.98046191574167},{"left":53.100186525557945},{"left":56.73593937680865},{"left":58.49769577124165},{"left":59.32235994306725},{"left":59.699023904547275},{"left":59.86794286219037},{"left":59.94262880062309},{"left":59.97527865242203},{"left":59.989420561599246},{"left":60}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_2_second: [{"left":9.886222222222223},{"left":9.544888888888888},{"left":8.975999999999999},{"left":8.179555555555556},{"left":7.155555555555555},{"left":5.904},{"left":4.424888888888888},{"left":2.718222222222221},{"left":0.7840000000000007},{"left":-1.2888888888888879},{"left":-3.1662222222222205},{"left":-4.816000000000001},{"left":-6.238222222222223},{"left":-7.43288888888889},{"left":-8.400000000000002},{"left":-9.139555555555557},{"left":-9.651555555555554},{"left":-9.936},{"left":-10},{"left":-1.440836584484348},{"left":10.589304696953164},{"left":19.217331445031864},{"left":24.356519912938218},{"left":27.15727455482897},{"left":28.605816939036828},{"left":29.329580292453784},{"left":29.682458802677182},{"left":29.851391036802266},{"left":29.93112506005838},{"left":29.96833528085268},{"left":29.98554086111488},{"left":30}], + from_30_10_55_through_0_min10_60_to_40_10_30_animation_2_third: [{"left":50.329091115756924},{"left":43.32089872469092},{"left":37.91204659789942},{"left":34.44159345211323},{"left":32.40358124360682},{"left":31.26761192112008},{"left":30.655868085027784},{"left":30.334386516489616},{"left":30.168498778420496},{"left":30.084102125833834},{"left":30.04164702199076},{"left":30.020486431940448},{"left":30},{"left":30.170666666666666},{"left":30.682666666666666},{"left":31.536},{"left":32.730666666666664},{"left":34.266666666666666},{"left":36.144},{"left":38.36266666666667},{"left":40.92266666666667},{"left":43.824},{"left":46.93333333333334},{"left":49.74933333333333},{"left":52.224000000000004},{"left":54.35733333333333},{"left":56.14933333333333},{"left":57.6},{"left":58.70933333333333},{"left":59.477333333333334},{"left":59.903999999999996},{"left":60},{"left":58.642865737467744},{"left":56.329281028638874},{"left":54.26910377409243},{"left":52.740976793672694},{"left":51.70289681983762},{"left":51.03337355094262},{"left":50.61611033403268},{"left":50.36231850955565},{"left":50.21073832770189},{"left":50.12147411619081},{"left":50.069496244841986},{"left":50.039507247318895},{"left":50}], +} \ No newline at end of file diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/easing.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/easing.test.tsx index c00ffdc3e75..051a383d25a 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/easing.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/easing.test.tsx @@ -9,8 +9,8 @@ import { mockAnimationTimer, recordAnimationUpdates, render, - wait, unmockAnimationTimer, + waitForAnimationUpdates, } from '../../../ReJest/RuntimeTestsApi'; import { EasingSnapshots } from './withTiming.snapshot'; import { ErrorBoundary } from '../../../ReJest/RuntimeTestsRunner'; @@ -55,11 +55,14 @@ const PassiveAnimatedComponent = ({ easing }: { easing: EasingFunction | EasingF ); }; -async function getSnapshotUpdates(easingFn: EasingFunction | EasingFunctionFactory | undefined) { +async function getSnapshotUpdates( + easingFn: EasingFunction | EasingFunctionFactory | undefined, + snapshotName: keyof typeof EasingSnapshots, +) { await mockAnimationTimer(); const updatesContainerActive = await recordAnimationUpdates(); await render(); - await wait(1200); + await waitForAnimationUpdates(EasingSnapshots[snapshotName].length); const activeUpdates = updatesContainerActive.getUpdates(); const activeNaiveUpdates = await updatesContainerActive.getNativeSnapshots(); @@ -68,7 +71,7 @@ async function getSnapshotUpdates(easingFn: EasingFunction | EasingFunctionFacto const updatesContainerPassive = await recordAnimationUpdates(); await render(); - await wait(1200); + await waitForAnimationUpdates(EasingSnapshots[snapshotName].length); // For passive updates we have the following order of operations: // 1. Slightly increase sharedValue @@ -90,7 +93,7 @@ describe('withTiming snapshots 📸, test EASING', () => { , ); }).toThrow( - 'Error: [Reanimated] The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.', + 'ReanimatedError: [Reanimated] The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.', ); }); @@ -106,13 +109,13 @@ describe('withTiming snapshots 📸, test EASING', () => { , ); }).toThrow( - 'Error: [Reanimated] The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.', + 'ReanimatedError: [Reanimated] The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.', ); }); }); test('No easing function', async () => { - const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(undefined); + const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(undefined, 'noEasing'); expect(activeUpdates).toMatchSnapshots(EasingSnapshots.noEasing); expect(passiveUpdates).toMatchSnapshots(EasingSnapshots.noEasing); @@ -134,18 +137,22 @@ describe('withTiming snapshots 📸, test EASING', () => { ['steps', Easing.steps, [1.5, true]], ['steps', Easing.steps, [1.5, false]], ] as const)('Easing.${0}(${2})', async ([easingName, easing, argumentSet]) => { - const snapshotName = `${easingName}_${argumentSet.join('_').replace(/\./g, '$').replace(/-/g, '$')}`; + const snapshotName = `${easingName}_${argumentSet + .join('_') + .replace(/\./g, '$') + .replace(/-/g, '$')}` as keyof typeof EasingSnapshots; const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates( // @ts-ignore This error is because various easing functions accept different number of arguments easing(...argumentSet), + snapshotName, ); - expect(activeUpdates).toMatchSnapshots(EasingSnapshots[snapshotName as keyof typeof EasingSnapshots]); + expect(activeUpdates).toMatchSnapshots(EasingSnapshots[snapshotName]); expect(activeUpdates).toMatchNativeSnapshots(activeNativeUpdates, true); if (easing !== Easing.steps) { // passiveUpdates of steps don't record duplicated frames, so we execute this test only for constant motion, not for the quantified one - expect(passiveUpdates).toMatchSnapshots(EasingSnapshots[snapshotName as keyof typeof EasingSnapshots]); + expect(passiveUpdates).toMatchSnapshots(EasingSnapshots[snapshotName]); } }); @@ -157,14 +164,14 @@ describe('withTiming snapshots 📸, test EASING', () => { ['linear', Easing.linear], ['quad', Easing.quad], ['sin', Easing.sin], - ] as const)('Easing.%p', async ([easingName, easing]) => { - const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(easing); + ] as const)('Easing.${0}', async ([easingName, easing]) => { + const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(easing, easingName); expect(activeUpdates).toMatchSnapshots(EasingSnapshots[easingName]); expect(passiveUpdates).toMatchSnapshots(EasingSnapshots[easingName]); expect(activeUpdates).toMatchNativeSnapshots(activeNativeUpdates, true); }); test('Easing.exp', async () => { - const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(Easing.exp); + const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(Easing.exp, 'exp'); expect(activeUpdates).toMatchSnapshots(EasingSnapshots.exp); // TODO Investigate why easing.exp works different than other easings expect(passiveUpdates).toMatchSnapshots([{ width: 0 }, ...EasingSnapshots.exp]); @@ -176,7 +183,10 @@ describe('withTiming snapshots 📸, test EASING', () => { ['out', Easing.out], ['inOut', Easing.inOut], ] as const)('Easing.${0}(Easing.elastic(10))', async ([easingName, easing]) => { - const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates(easing(Easing.elastic(10))); + const [activeUpdates, activeNativeUpdates, passiveUpdates] = await getSnapshotUpdates( + easing(Easing.elastic(10)), + easingName, + ); expect(activeUpdates).toMatchSnapshots(EasingSnapshots[easingName]); expect(passiveUpdates).toMatchSnapshots(EasingSnapshots[easingName]); expect(activeUpdates).toMatchNativeSnapshots(activeNativeUpdates, true); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/core/cancelAnimation.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/core/cancelAnimation.test.tsx index 817100ceeac..2e315ffce2d 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/core/cancelAnimation.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/core/cancelAnimation.test.tsx @@ -8,19 +8,8 @@ import Animated, { Easing, useDerivedValue, } from 'react-native-reanimated'; -import { - describe, - test, - expect, - render, - getTestComponent, - wait, - useTestRef, - registerValue, - getRegisteredValue, -} from '../../ReJest/RuntimeTestsApi'; - -const ELAPSED_TIME_REF = 'ElapsedTime'; +import { describe, test, expect, render, getTestComponent, wait, useTestRef } from '../../ReJest/RuntimeTestsApi'; +import { ComparisonMode } from '../../ReJest/types'; describe('Test *****cancelAnimation*****', () => { describe('Test canceling animation _after predefined time_', () => { @@ -33,8 +22,6 @@ describe('Test *****cancelAnimation*****', () => { timeToStop: number; }) => { const width = useSharedValue(0); - const elapsedTime = useSharedValue(0); - registerValue(ELAPSED_TIME_REF, elapsedTime); const ref = useTestRef(CANCEL_AFTER_DELAY_REF); const animatedStyle = useAnimatedStyle(() => { @@ -44,16 +31,12 @@ describe('Test *****cancelAnimation*****', () => { }); useEffect(() => { - const startTime = performance.now(); - width.value = withTiming(300, { duration: animationDuration, easing: Easing.linear }, () => { - const stopTime = performance.now(); - elapsedTime.value = stopTime - startTime; - }); + width.value = withTiming(300, { duration: animationDuration, easing: Easing.linear }, () => {}); setTimeout(() => { cancelAnimation(width); }, timeToStop); - }, [width, timeToStop, animationDuration, elapsedTime]); + }, [width, timeToStop, animationDuration]); return ( @@ -63,7 +46,7 @@ describe('Test *****cancelAnimation*****', () => { }; test.each([ [400, 450], - [500, 200], + [500, 720], [1000, 200], [1000, 400], [10000, 400], @@ -72,11 +55,19 @@ describe('Test *****cancelAnimation*****', () => { await render(); const animatedComponent = getTestComponent(CANCEL_AFTER_DELAY_REF); - await wait(timeToStop + 200); + await wait(timeToStop + 100); - const timeElapsed = (await getRegisteredValue(ELAPSED_TIME_REF)).onJS as number; - const expectedWidth = 300 * (timeElapsed / animationDuration); - expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(expectedWidth - 4, expectedWidth + 4); + if (animationDuration < timeToStop) { + expect(await animatedComponent.getAnimatedStyle('width')).toBe(300, ComparisonMode.PIXEL); + } else { + // Let's approximate the animation duration using the predefined timeout to cancel it + const expectedWidth = 300 * (timeToStop / animationDuration); // ANDROID + // console.log(expectedWidth, await animatedComponent.getAnimatedStyle('width')); + expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange( + expectedWidth - 10, + expectedWidth + 10, + ); + } }); }); @@ -113,7 +104,7 @@ describe('Test *****cancelAnimation*****', () => { await render(); const animatedComponent = getTestComponent(CANCEL_AFTER_CONDITION_REF); - await wait(320); + await wait(400); expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(stopValue, stopValue + 17); }); @@ -170,7 +161,7 @@ describe('Test *****cancelAnimation*****', () => { await wait(timeToStop + 100); const expectedWidth = (timeToStop / animationDuration) * 300; - expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(expectedWidth, expectedWidth + 5); + expect(await animatedComponent.getAnimatedStyle('width')).toBeWithinRange(expectedWidth, expectedWidth + 10); }); }); }); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx index 71e7a247cab..553ee9c58a3 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx @@ -7,7 +7,6 @@ import Animated, { useDerivedValue, withSpring, } from 'react-native-reanimated'; -import { ComparisonMode } from '../../../ReJest/types'; import { describe, test, @@ -122,7 +121,12 @@ describe('Test useDerivedValue changing width', () => { ); const testComponent = getTestComponent(WIDTH_COMPONENT); await waitForAnimationUpdates(snapshotLength); - expect(await testComponent.getAnimatedStyle('width')).toBe(derivedFun(finalWidth), ComparisonMode.PIXEL); + + expect(await testComponent.getAnimatedStyle('width')).toBeWithinRange( + derivedFun(finalWidth) - 2, + derivedFun(finalWidth) + 2, + ); + const updates = updatesContainerActive.getUpdates(); const naiveUpdates = await updatesContainerActive.getNativeSnapshots(); await unmockAnimationTimer(); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/arrays.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/arrays.test.tsx index c76ac2359e2..7e0d6ff6945 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/arrays.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/arrays.test.tsx @@ -9,6 +9,7 @@ import { registerValue, getRegisteredValue, Presets, + wait, } from '../../../ReJest/RuntimeTestsApi'; import { ComparisonMode } from '../../../ReJest/types'; import { MutableAPI, ProgressBar } from './components'; @@ -52,6 +53,9 @@ describe(`_Array operations_ on sharedValue`, () => { await render(); const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); const expected = [...initialArray, ...appendedArray]; + if (expected.length > 100) { + await wait(5000); // operations on big arrays are very slow + } expect(sharedValue.onJS).toBe(expected, ComparisonMode.ARRAY); expect(sharedValue.onUI).toBe(expected, ComparisonMode.ARRAY); await render(); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/utilities/relativeCoords.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/utilities/relativeCoords.test.tsx index 1bce338d8cc..96666ae666c 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/utilities/relativeCoords.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/utilities/relativeCoords.test.tsx @@ -4,6 +4,7 @@ import { StyleSheet } from 'react-native'; import type { ComponentCoords } from 'react-native-reanimated'; import Animated, { runOnUI, measure, getRelativeCoords, useAnimatedRef, useSharedValue } from 'react-native-reanimated'; import { describe, test, expect, render, wait, registerValue, getRegisteredValue } from '../../ReJest/RuntimeTestsApi'; +import { ComparisonMode } from '../../ReJest/types'; const REGISTERED_VALUE_KEY = 'sv'; @@ -61,8 +62,8 @@ describe('getRelativeCoords', () => { const coords = (await getRegisteredValue(REGISTERED_VALUE_KEY)).onUI; expect(coords).not.toBeNullable(); if (coords) { - expect(Math.floor((coords as unknown as ComponentCoords).x)).toBe(expectedValueX); - expect(Math.floor((coords as unknown as ComponentCoords).y)).toBe(expectedValueY); + expect((coords as unknown as ComponentCoords).x).toBe(expectedValueX, ComparisonMode.PIXEL); + expect((coords as unknown as ComponentCoords).y).toBe(expectedValueY, ComparisonMode.PIXEL); } }, );