@@ -18,6 +18,7 @@ import chai from 'chai';
1818import { JSDOM } from 'jsdom' ;
1919import fs from 'fs/promises' ;
2020import { renderToString } from '../../../src/wcc.js' ;
21+ import { parseFragment , serialize } from 'parse5' ;
2122
2223const expect = chai . expect ;
2324
@@ -34,7 +35,10 @@ describe('Run WCC For ', function() {
3435 actualHtml = html ;
3536 dom = new JSDOM ( actualHtml ) ;
3637 pictureFrame = dom . window . document . querySelectorAll ( 'wcc-picture-frame' ) ;
37- expectedHtml = await fs . readFile ( new URL ( './expected.html' , import . meta. url ) , 'utf-8' ) ;
38+
39+ // We want to compare using canonical html (i.e. strip self-closing tags)
40+ const rawExpectedHtml = await fs . readFile ( new URL ( './expected.html' , import . meta. url ) , 'utf-8' ) ;
41+ expectedHtml = serialize ( parseFragment ( rawExpectedHtml ) ) ;
3842 } ) ;
3943
4044 describe ( LABEL , function ( ) {
@@ -79,7 +83,7 @@ describe('Run WCC For ', function() {
7983 } ) ;
8084
8185 it ( 'should have the expected recursively generated HTML' , ( ) => {
82- expect ( expectedHtml . replace ( / / g, '' ) . replace ( / \n / g, '' ) ) . to . equal ( actualHtml . replace ( / / g, '' ) . replace ( / \n / g, '' ) ) ;
86+ expect ( actualHtml . replace ( / / g, '' ) . replace ( / \n / g, '' ) ) . to . equal ( expectedHtml . replace ( / / g, '' ) . replace ( / \n / g, '' ) ) ;
8387 } ) ;
8488 } ) ;
8589} ) ;
0 commit comments