@@ -198,12 +198,17 @@ describe("compare (commit backend)", () => {
198198 currents : { "firefox/home/desktop_1440px.png" : pngBytes ( BLUE ) } ,
199199 } ) ;
200200 record ( proj ) ;
201- const { exitCode, json } = runJson (
201+ const { exitCode, json, stderr } = runJson (
202202 [ "compare" , "--json" , "--blocking" , "--current-dir" , proj . currentDir , "--host" , "container" ] ,
203203 proj ,
204204 ) ;
205205 expect ( exitCode ) . toBe ( 1 ) ;
206206 expect ( json . blocking ) . toBe ( true ) ;
207+ // visual-diff.js emits a mismatch RATIO; the CLI must report a true percent
208+ // (a fully-different image is 100%, not "1%").
209+ expect ( json . results [ 0 ] . mismatchRatio ) . toBe ( 1 ) ;
210+ expect ( stderr ) . toContain ( "(100.00%)" ) ;
211+ expect ( readFileSync ( proj . reportFile , "utf-8" ) ) . toContain ( "100.00%" ) ;
207212 } ) ;
208213
209214 it ( "exits 1 on failures when config sets blocking: true (Phase B teeth)" , ( ) => {
@@ -228,10 +233,7 @@ describe("compare (commit backend)", () => {
228233 } ) ;
229234 record ( proj ) ;
230235 // Rewrite the baseline after recording provenance → sha mismatch.
231- writeFileSync (
232- join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) ,
233- tampered ,
234- ) ;
236+ writeFileSync ( join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) , tampered ) ;
235237 const { json, exitCode } = runJson (
236238 [ "compare" , "--json" , "--current-dir" , proj . currentDir , "--host" , "container" ] ,
237239 proj ,
@@ -257,10 +259,7 @@ describe("compare (commit backend)", () => {
257259 writeFileSync ( proj . configPath , JSON . stringify ( configRaw , null , 2 ) ) ;
258260
259261 record ( proj ) ;
260- writeFileSync (
261- join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) ,
262- tampered ,
263- ) ;
262+ writeFileSync ( join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) , tampered ) ;
264263 const { json, exitCode } = runJson (
265264 [ "compare" , "--json" , "--current-dir" , proj . currentDir , "--host" , "container" ] ,
266265 proj ,
@@ -327,7 +326,16 @@ describe("compare (commit backend)", () => {
327326 } ) ;
328327 record ( proj ) ;
329328 const { json } = runJson (
330- [ "compare" , "--json" , "--engines" , "firefox" , "--current-dir" , proj . currentDir , "--host" , "container" ] ,
329+ [
330+ "compare" ,
331+ "--json" ,
332+ "--engines" ,
333+ "firefox" ,
334+ "--current-dir" ,
335+ proj . currentDir ,
336+ "--host" ,
337+ "container" ,
338+ ] ,
331339 proj ,
332340 ) ;
333341 expect ( json . results ) . toHaveLength ( 1 ) ;
@@ -409,10 +417,7 @@ describe("verify", () => {
409417 record ( proj ) ;
410418 expect ( run ( [ "verify" , "--json" , "--host" , "container" ] , proj ) . exitCode ) . toBe ( 0 ) ;
411419
412- writeFileSync (
413- join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) ,
414- pngBytes ( BLUE ) ,
415- ) ;
420+ writeFileSync ( join ( proj . baselineDir , "firefox" , "home" , "desktop_1440px.png" ) , pngBytes ( BLUE ) ) ;
416421 const { exitCode, json } = runJson ( [ "verify" , "--json" , "--host" , "container" ] , proj ) ;
417422 expect ( exitCode ) . toBe ( 1 ) ;
418423 expect ( json . statuses [ "firefox/home/desktop_1440px.png" ] ) . toBe ( "modified" ) ;
@@ -424,10 +429,7 @@ describe("capture", () => {
424429 "fails with an install hint when Playwright is not resolvable" ,
425430 ( ) => {
426431 const proj = makeProject ( { } ) ;
427- const { exitCode, stderr } = run (
428- [ "capture" , "http://127.0.0.1:9" , "--local" ] ,
429- proj ,
430- ) ;
432+ const { exitCode, stderr } = run ( [ "capture" , "http://127.0.0.1:9" , "--local" ] , proj ) ;
431433 expect ( exitCode ) . toBe ( 2 ) ;
432434 expect ( stderr ) . toMatch ( / @ p l a y w r i g h t \/ t e s t / ) ;
433435 } ,
@@ -490,23 +492,24 @@ describe("capture — pinned container wrapping (Phase B)", () => {
490492
491493 it . skipIf ( playwrightResolvable ) ( "--local bypasses the container wrapper" , ( ) => {
492494 const proj = makeProject ( { config : containerConfig } ) ;
493- const { exitCode, stderr } = run (
494- [ "capture" , "http://127.0.0.1:9" , "--local" ] ,
495- proj ,
496- ) ;
495+ const { exitCode, stderr } = run ( [ "capture" , "http://127.0.0.1:9" , "--local" ] , proj ) ;
497496 expect ( exitCode ) . toBe ( 2 ) ;
498497 expect ( stderr ) . toMatch ( / @ p l a y w r i g h t \/ t e s t / ) ;
499498 expect ( stderr ) . not . toMatch ( / d o c k e r r u n / i) ;
500499 } ) ;
501500
502501 it ( "rejects an image tag it cannot derive a Playwright version from" , ( ) => {
503502 const proj = makeProject ( {
504- config : { capture : { mode : "container" , image : "mcr.microsoft.com/playwright:latest" , waitAfterLoadMs : 0 , fullPage : true } } ,
503+ config : {
504+ capture : {
505+ mode : "container" ,
506+ image : "mcr.microsoft.com/playwright:latest" ,
507+ waitAfterLoadMs : 0 ,
508+ fullPage : true ,
509+ } ,
510+ } ,
505511 } ) ;
506- const { exitCode, stderr } = run (
507- [ "capture" , "http://localhost:3000" , "--dry-run" ] ,
508- proj ,
509- ) ;
512+ const { exitCode, stderr } = run ( [ "capture" , "http://localhost:3000" , "--dry-run" ] , proj ) ;
510513 expect ( exitCode ) . toBe ( 2 ) ;
511514 expect ( stderr ) . toMatch ( / i m a g e / i) ;
512515 } ) ;
0 commit comments