-
Hi there, I'm currently writing a test suite for my zoom library and this one has a lot of callbacks that need to executed within a runOnJS expression, testing with Jest I've noticed passing the mocks to the functions requiring them will not count as an execution, I'm aware of the async nature of runOnJs function, so I guess they're ran after the test is done. How could I test something like this? Code like this would fail by reporting zero executions were made. const pan = Gesture.Pan()
.withTestID('pan')
.onEnd(e => runOnJS(mock)(e))
// Actual test
test("do something", () => {
const onPanEnd = jets.fn(() => {});
// Some component with a pan gesture like the one above
render(<Component onPanEnd={mock} />)
fireGestureHandler<PanGesture>(getByGestureTestId('pan'), [
{ translationX: 10, translationY: 10, state: State.BEGAN },
{ state: State.ACTIVE },
{ translationX: 10, translationY: 10, state: State.END },
]);
expect(onPanEnd.mock.calls).toHaveLength(1);
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Glazzes ! could you test the callbacks with some additional shared Value? These values are accessible from both JS and UI threads so you could use them like that:
|
Beta Was this translation helpful? Give feedback.
Hi @Glazzes ! could you test the callbacks with some additional shared Value? These values are accessible from both JS and UI threads so you could use them like that: