File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 11import { Injectable } from '@nestjs/common' ;
2- import { PNG } from 'pngjs' ;
2+ import { PNG , PNGWithMetadata } from 'pngjs' ;
33import Pixelmatch from 'pixelmatch' ;
44import { CreateTestRequestDto } from 'src/test/dto/create-test-request.dto' ;
55import { IgnoreAreaDto } from 'src/test/dto/ignore-area.dto' ;
@@ -49,7 +49,7 @@ export class TestRunsService {
4949 // save new baseline
5050 const baseline = this . staticService . getImage ( testRun . imageName )
5151 const imageName = `${ Date . now ( ) } .baseline.png` ;
52- this . staticService . saveImage ( imageName , baseline . data ) ;
52+ this . staticService . saveImage ( imageName , PNG . sync . write ( baseline ) ) ;
5353
5454 return this . prismaService . testRun . update ( {
5555 where : { id } ,
@@ -108,10 +108,18 @@ export class TestRunsService {
108108 status : TestStatus . new ,
109109 } ;
110110
111- // compare with baseline
111+ // get baseline image
112+ let baseline : PNGWithMetadata
112113 if ( testVariation . baselineName ) {
113- const baseline = this . staticService . getImage ( testVariation . baselineName ) ;
114+ try {
115+ baseline = this . staticService . getImage ( testVariation . baselineName )
116+ } catch ( ex ) {
117+ console . log ( `Cannot load baseline image: ${ testVariation . baselineName } . ${ ex } ` )
118+ }
119+ }
114120
121+ // compare with baseline
122+ if ( baseline ) {
115123 const diffImageKey = `${ Date . now ( ) } .diff.png` ;
116124 const diff = new PNG ( {
117125 width : baseline . width ,
You can’t perform that action at this time.
0 commit comments