@@ -128,6 +128,27 @@ describe('screencast', () => {
128128 expect ( test . artifacts . screencast ) . to . match ( / k e e p - o n - f a i l .* \. w e b m $ / )
129129 } )
130130
131+ it ( 'on=fail keeps a screenshot already written onto array-shaped artifacts' , async ( ) => {
132+ const sc = makeFakeScreencast ( )
133+ container . clear ( { Playwright : { options : { } , page : { screencast : sc } } } )
134+
135+ screencast ( { on : 'fail' } )
136+ const test = createTest ( 'keep-screenshot' )
137+ test . artifacts . screenshot = 'failed.png'
138+
139+ event . dispatcher . emit ( event . test . before , test )
140+ event . dispatcher . emit ( event . test . started , test )
141+ event . dispatcher . emit ( event . step . started , aStep ( ) )
142+ await recorder . promise ( )
143+
144+ event . dispatcher . emit ( event . test . failed , test , new Error ( 'boom' ) )
145+ event . dispatcher . emit ( event . test . after , test )
146+ await recorder . promise ( )
147+
148+ expect ( test . artifacts . screenshot ) . to . equal ( 'failed.png' )
149+ expect ( test . artifacts . screencast ) . to . match ( / k e e p - s c r e e n s h o t .* \. w e b m $ / )
150+ } )
151+
131152 it ( 'captions=true triggers showActions; captions=false does not' , async ( ) => {
132153 const sc = makeFakeScreencast ( )
133154 container . clear ( { Playwright : { options : { } , page : { screencast : sc } } } )
0 commit comments