@@ -20,7 +20,7 @@ export interface PressOptions {
2020export async function press ( this : UserEventInstance , element : ReactTestInstance ) : Promise < void > {
2121 await basePress ( this . config , element , {
2222 type : 'press' ,
23- duration : DEFAULT_MIN_PRESS_DURATION ,
23+ duration : undefined ,
2424 } ) ;
2525}
2626
@@ -37,7 +37,7 @@ export async function longPress(
3737
3838interface BasePressOptions {
3939 type : 'press' | 'longPress' ;
40- duration : number ;
40+ duration : number | undefined ;
4141}
4242
4343const basePress = async (
@@ -77,16 +77,17 @@ const emitPressablePressEvents = async (
7777
7878 dispatchEvent ( element , 'responderGrant' , EventBuilder . Common . responderGrant ( ) ) ;
7979
80- await wait ( config , options . duration ) ;
80+ const duration = options . duration ?? DEFAULT_MIN_PRESS_DURATION ;
81+ await wait ( config , duration ) ;
8182
8283 dispatchEvent ( element , 'responderRelease' , EventBuilder . Common . responderRelease ( ) ) ;
8384
8485 // React Native will wait for minimal delay of DEFAULT_MIN_PRESS_DURATION
8586 // before emitting the `pressOut` event. We need to wait here, so that
8687 // `press()` function does not return before that.
87- if ( DEFAULT_MIN_PRESS_DURATION - options . duration > 0 ) {
88+ if ( DEFAULT_MIN_PRESS_DURATION - duration > 0 ) {
8889 await act ( async ( ) => {
89- await wait ( config , DEFAULT_MIN_PRESS_DURATION - options . duration ) ;
90+ await wait ( config , DEFAULT_MIN_PRESS_DURATION - duration ) ;
9091 } ) ;
9192 }
9293} ;
0 commit comments