@@ -20,7 +20,7 @@ export interface PressOptions {
20
20
export async function press ( this : UserEventInstance , element : ReactTestInstance ) : Promise < void > {
21
21
await basePress ( this . config , element , {
22
22
type : 'press' ,
23
- duration : DEFAULT_MIN_PRESS_DURATION ,
23
+ duration : undefined ,
24
24
} ) ;
25
25
}
26
26
@@ -37,7 +37,7 @@ export async function longPress(
37
37
38
38
interface BasePressOptions {
39
39
type : 'press' | 'longPress' ;
40
- duration : number ;
40
+ duration : number | undefined ;
41
41
}
42
42
43
43
const basePress = async (
@@ -77,16 +77,17 @@ const emitPressablePressEvents = async (
77
77
78
78
dispatchEvent ( element , 'responderGrant' , EventBuilder . Common . responderGrant ( ) ) ;
79
79
80
- await wait ( config , options . duration ) ;
80
+ const duration = options . duration ?? DEFAULT_MIN_PRESS_DURATION ;
81
+ await wait ( config , duration ) ;
81
82
82
83
dispatchEvent ( element , 'responderRelease' , EventBuilder . Common . responderRelease ( ) ) ;
83
84
84
85
// React Native will wait for minimal delay of DEFAULT_MIN_PRESS_DURATION
85
86
// before emitting the `pressOut` event. We need to wait here, so that
86
87
// `press()` function does not return before that.
87
- if ( DEFAULT_MIN_PRESS_DURATION - options . duration > 0 ) {
88
+ if ( DEFAULT_MIN_PRESS_DURATION - duration > 0 ) {
88
89
await act ( async ( ) => {
89
- await wait ( config , DEFAULT_MIN_PRESS_DURATION - options . duration ) ;
90
+ await wait ( config , DEFAULT_MIN_PRESS_DURATION - duration ) ;
90
91
} ) ;
91
92
}
92
93
} ;
0 commit comments