@@ -41,20 +41,20 @@ function emptySuite(): ReplaySuiteResult {
4141 } ;
4242}
4343
44- function withCiEnv < T > ( value : string | undefined , run : ( ) => T ) : T {
45- const original = process . env . CI ;
46- if ( value === undefined ) delete process . env . CI ;
47- else process . env . CI = value ;
44+ function withEnv < T > ( name : 'CI' | 'TMUX' , value : string | undefined , run : ( ) => T ) : T {
45+ const original = process . env [ name ] ;
46+ if ( value === undefined ) delete process . env [ name ] ;
47+ else process . env [ name ] = value ;
4848 try {
4949 return run ( ) ;
5050 } finally {
51- if ( original === undefined ) delete process . env . CI ;
52- else process . env . CI = original ;
51+ if ( original === undefined ) delete process . env [ name ] ;
52+ else process . env [ name ] = original ;
5353 }
5454}
5555
5656test ( 'default replay test reporter hides and restores cursor for tty progress' , ( ) => {
57- withCiEnv ( undefined , ( ) => {
57+ withEnv ( 'CI' , undefined , ( ) => {
5858 const reporter = createDefaultReplayTestReporter ( ) ;
5959 const { context, stderr, stdout } = createReporterContext ( { stderrIsTty : true } ) ;
6060
@@ -70,6 +70,53 @@ test('default replay test reporter hides and restores cursor for tty progress',
7070 } ) ;
7171} ) ;
7272
73+ test ( 'default replay test reporter avoids cursor-up cleanup inside tmux' , ( ) => {
74+ withEnv ( 'CI' , undefined , ( ) =>
75+ withEnv ( 'TMUX' , '/tmp/tmux-1000/default,1,0' , ( ) => {
76+ const reporter = createDefaultReplayTestReporter ( ) ;
77+ const { context, stderr } = createReporterContext ( { stderrIsTty : true } ) ;
78+ context . stderr . columns = 200 ;
79+ reporter . onSuiteStart ?.(
80+ { total : 1 , runnable : 1 , skipped : 0 , artifactsDir : '/tmp/replay' } ,
81+ context ,
82+ ) ;
83+ reporter . onTestStep ?.(
84+ {
85+ file : '/tmp/checkout.yaml' ,
86+ title : 'x' . repeat ( 180 ) ,
87+ index : 1 ,
88+ total : 1 ,
89+ stepIndex : 1 ,
90+ stepTotal : 2 ,
91+ stepCommand : 'assertVisible' ,
92+ stepValue : 'Confirmation' ,
93+ } ,
94+ context ,
95+ ) ;
96+
97+ context . stderr . columns = 20 ;
98+ reporter . onTestStep ?.(
99+ {
100+ file : '/tmp/checkout.yaml' ,
101+ title : 'Checkout' ,
102+ index : 1 ,
103+ total : 1 ,
104+ stepIndex : 2 ,
105+ stepTotal : 2 ,
106+ stepCommand : 'tapOn' ,
107+ stepValue : 'Continue' ,
108+ } ,
109+ context ,
110+ ) ;
111+ reporter . onSuiteEnd ?.( emptySuite ( ) , context ) ;
112+
113+ const resizedProgress = stderr [ 2 ] ;
114+ assert . equal ( ( resizedProgress ?. split ( '\u001B[1A' ) . length ?? 1 ) - 1 , 0 ) ;
115+ assert . equal ( ( resizedProgress ?. split ( '\u001B[2K' ) . length ?? 1 ) - 1 , 1 ) ;
116+ } ) ,
117+ ) ;
118+ } ) ;
119+
73120test ( 'default replay test reporter leaves cursor alone for non-tty streams' , ( ) => {
74121 const reporter = createDefaultReplayTestReporter ( ) ;
75122 const { context, stderr } = createReporterContext ( { stderrIsTty : false } ) ;
0 commit comments