Skip to content

Commit

Permalink
[jest] Suppress warning about non-worklet callbacks (#3050)
Browse files Browse the repository at this point in the history
## Description

As mentioned in [this discussion](#3047), while testing Gesture Handler with `jest` you can see the following warning:

```
None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.
```

Since `worklets` do not work in `jest`, I believe it is safe to simply suppress this error.

## Test plan

Run tests in our repository
  • Loading branch information
m-bert authored Aug 20, 2024
1 parent 0ece290 commit b832692
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handlers/gestures/GestureDetector/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';

import { tagMessage } from '../../../utils';
import { isJestEnv, tagMessage } from '../../../utils';
import { GestureRef, BaseGesture, GestureType } from '../gesture';

import { flingGestureHandlerProps } from '../../FlingGestureHandler';
Expand Down Expand Up @@ -100,7 +100,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;
// If none of the callbacks are worklets and the gesture is not explicitly marked with
// `.runOnJS(true)` show a warning
if (areAllNotWorklets) {
if (areAllNotWorklets && !isJestEnv()) {
console.warn(
tagMessage(
`None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`
Expand Down

0 comments on commit b832692

Please sign in to comment.