@@ -2,7 +2,7 @@ const chalk = require('chalk')
22const { spawnSync } = require ( 'child_process' )
33const fs = require ( 'fs-extra' )
44const path = require ( 'path' )
5- const pixelmatch = require ( 'pixelmatch ' )
5+ const blazediff = require ( '@blazediff/core ' )
66const { PNG } = require ( 'pngjs' )
77const { Cluster } = require ( 'puppeteer-cluster' )
88const os = require ( 'os' )
@@ -100,7 +100,7 @@ async function processSample(page, sample, command) {
100100
101101 await page . goto ( `file://${ htmlPath } ` )
102102
103- let wait ;
103+ let wait
104104 do {
105105 //Wait for all intervals in the page to have been cleared
106106 await page . waitForFunction ( ( ) => window . activeIntervalCount === 0 )
@@ -117,7 +117,11 @@ async function processSample(page, sample, command) {
117117 //After the network requests, timers, and intervals finish, if another request, timer, or interval is created then we need
118118 //to wait for that to finish before continuing on.
119119 wait = await page . evaluate ( ( ) => {
120- return ! ( window . activeIntervalCount === 0 && window . activeTimerCount === 0 && chart . w . globals . animationEnded )
120+ return ! (
121+ window . activeIntervalCount === 0 &&
122+ window . activeTimerCount === 0 &&
123+ chart . w . globals . animationEnded
124+ )
121125 } )
122126 } while ( wait )
123127
@@ -151,7 +155,7 @@ async function processSample(page, sample, command) {
151155 // Compare screenshot to the original and throw error on differences
152156 const testImg = PNG . sync . read ( testImgBuffer )
153157 // BUG: copy if original image doesn't exist and report in test results?
154- let originalImg ;
158+ let originalImg
155159 try {
156160 originalImg = PNG . sync . read ( fs . readFileSync ( originalImgPath ) )
157161 } catch ( e ) {
@@ -168,7 +172,7 @@ async function processSample(page, sample, command) {
168172 let err
169173
170174 try {
171- numDiffs = pixelmatch (
175+ numDiffs = blazediff (
172176 originalImg . data ,
173177 testImg . data ,
174178 diffImg . data ,
@@ -180,7 +184,7 @@ async function processSample(page, sample, command) {
180184 err = e
181185 }
182186
183- // Save screenshot even if pixelmatch failed (due to image size mismatch)
187+ // Save screenshot even if blazediff failed (due to image size mismatch)
184188 if ( numDiffs !== 0 ) {
185189 await fs . ensureDir ( `${ e2eDir } /diffs/${ sample . dirName } ` )
186190 fs . writeFileSync ( `${ e2eDir } /diffs/${ relPath } .png` , testImgBuffer )
@@ -331,7 +335,11 @@ async function processSamples(command, paths, isCI) {
331335 )
332336
333337 if ( testsMissingSnapshots . length > 0 ) {
334- console . log ( chalk . yellow . bold ( `${ testsMissingSnapshots . length } tests were missing snapshots to compare against. Those tests are:` ) )
338+ console . log (
339+ chalk . yellow . bold (
340+ `${ testsMissingSnapshots . length } tests were missing snapshots to compare against. Those tests are:`
341+ )
342+ )
335343 for ( const testMissingSnapshot of testsMissingSnapshots ) {
336344 console . log ( chalk . yellow . bold ( `${ testMissingSnapshot } \n` ) )
337345 }
0 commit comments