@@ -91,21 +91,6 @@ async function stopODiffServer(server) {
9191 }
9292}
9393
94- /**
95- * @param {string } file
96- * @returns {Promise<number> }
97- */
98- async function readPngWidth ( file ) {
99- const handle = await fs . open ( file ) ;
100- try {
101- const header = Buffer . alloc ( 24 ) ;
102- await handle . read ( header , 0 , header . length , 0 ) ;
103- return header . readUInt32BE ( 16 ) ;
104- } finally {
105- await handle . close ( ) ;
106- }
107- }
108-
10994/**
11095 * @param {ReadonlyArray<string> } list
11196 * @param {{ workerCount?: number }= } options
@@ -181,14 +166,13 @@ export async function renderScreenshots(list, options = {}) {
181166
182167/**
183168 * @param {ReadonlyArray<string> } list
184- * @param {{ ODiffServer?: ODiffServerConstructor, readWidth?: (file: string) => Promise<number> }= } options
169+ * @param {{ ODiffServer?: ODiffServerConstructor }= } options
185170 * @returns {Promise<MatchResult[]> }
186171 */
187172export async function compareScreenshots ( list , options = { } ) {
188173 /** @type {MatchResult[] } */
189174 const results = [ ] ;
190175 const ODiffServerClass = options . ODiffServer ?? ODiffServer ;
191- const readWidth = options . readWidth ?? readPngWidth ;
192176 const server = new ODiffServerClass ( ) ;
193177 try {
194178 for ( const name of list ) {
@@ -215,9 +199,7 @@ export async function compareScreenshots(list, options = {}) {
215199 ) ;
216200 let isMatch = result . match ;
217201 if ( ! result . match && result . reason === 'pixel-diff' ) {
218- const width = await readWidth ( originalPath ) ;
219- const allowance = width <= 16 ? 3 : 4 ;
220- isMatch = result . diffCount <= allowance ;
202+ isMatch = result . diffCount <= 4 ;
221203 if ( isMatch && process . env . NO_DIFF == null ) {
222204 await fs . rm ( diffPath , { force : true } ) ;
223205 }
0 commit comments