File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,7 @@ export class ImagesInfoSaver extends EventEmitter2 {
5252 const testDebug = debug . extend ( testResult . imageDir ) ;
5353 testDebug ( `Saving images of ${ testResult . id } ` ) ;
5454
55- const newImagesInfos : ImageInfoFull [ ] = [ ] ;
56-
57- await Promise . all ( testResult . imagesInfo . map ( async ( imagesInfo , index ) => {
55+ const newImagesInfos = await Promise . all ( testResult . imagesInfo . map ( async ( imagesInfo , index ) => {
5856 const imageDebug = testDebug . extend ( index . toString ( ) ) ;
5957 imageDebug . enabled && imageDebug ( 'Handling %j' , removeBufferFromImagesInfo ( imagesInfo ) ) ;
6058
@@ -79,7 +77,7 @@ export class ImagesInfoSaver extends EventEmitter2 {
7977
8078 await actions . onIdle ( ) ;
8179
82- newImagesInfos . push ( _ . omitBy ( newImagesInfo , _ . isNil ) as ImageInfoFull ) ;
80+ return _ . omitBy ( newImagesInfo , _ . isNil ) as ImageInfoFull ;
8381 } ) ) ;
8482
8583 await this . emitAsync ( PluginEvents . TEST_SCREENSHOTS_SAVED , {
Original file line number Diff line number Diff line change @@ -261,5 +261,27 @@ describe('images-info-saver', () => {
261261 imagesInfo : updatedTestResult . imagesInfo
262262 } ) ) ;
263263 } ) ;
264+
265+ it ( 'should keep images order' , async ( ) => {
266+ const imagesInfo = _ . range ( 20 ) . map ( i => ( { stateName : `state ${ i + 1 } ` } ) ) as ImageInfoNoRef [ ] ;
267+ const testResult = {
268+ imagesInfo,
269+ fullName : 'some-name' ,
270+ browserId : 'some-browser' ,
271+ attempt : 0
272+ } as ReporterTestResult ;
273+
274+ const eventHandler = sinon . stub ( ) ;
275+ imagesInfoSaver . on ( PluginEvents . TEST_SCREENSHOTS_SAVED , eventHandler ) ;
276+
277+ const updatedTestResult = await imagesInfoSaver . save ( testResult ) ;
278+
279+ assert . deepStrictEqual ( updatedTestResult . imagesInfo , imagesInfo ) ;
280+ assert . calledWith ( eventHandler , sinon . match ( {
281+ imagesInfo,
282+ testId : 'some-name.some-browser' ,
283+ attempt : 0
284+ } ) ) ;
285+ } ) ;
264286 } ) ;
265287} ) ;
You can’t perform that action at this time.
0 commit comments