@@ -23,6 +23,7 @@ import * as plots from "./plots/index.js";
2323 svg . setAttributeNS ( "http://www.w3.org/2000/xmlns/" , "xmlns:xlink" , "http://www.w3.org/1999/xlink" ) ;
2424 const actual = beautify . html ( root . outerHTML , { indent_size : 2 } ) ;
2525 const outfile = path . resolve ( "./test/output" , path . basename ( name , ".js" ) + "." + ext ) ;
26+ const diffile = path . resolve ( "./test/output" , path . basename ( name , ".js" ) + "-changed." + ext ) ;
2627 let expected ;
2728
2829 try {
@@ -37,11 +38,22 @@ import * as plots from "./plots/index.js";
3738 }
3839 }
3940
40- if ( actual !== expected ) {
41- const outfile = path . resolve ( "./test/output" , path . basename ( name , ".js" ) + "-changed." + ext ) ;
42- console . warn ( `! generating ${ outfile } ` ) ;
43- await fs . writeFile ( outfile , actual , "utf8" ) ;
41+ if ( actual === expected ) {
42+ if ( process . env . CI !== "true" ) {
43+ try {
44+ await fs . unlink ( diffile ) ;
45+ console . warn ( `! deleted ${ diffile } ` ) ;
46+ } catch ( error ) {
47+ if ( error . code !== "ENOENT" ) {
48+ throw error ;
49+ }
50+ }
51+ }
52+ } else {
53+ console . warn ( `! generating ${ diffile } ` ) ;
54+ await fs . writeFile ( diffile , actual , "utf8" ) ;
4455 }
56+
4557 assert ( actual === expected , `${ name } must match snapshot` ) ;
4658 } finally {
4759 delete global . document ;
0 commit comments