diff --git a/src/services/snapshot-formatter.ts b/src/services/snapshot-formatter.ts index ab7eb32..fbc06b5 100644 --- a/src/services/snapshot-formatter.ts +++ b/src/services/snapshot-formatter.ts @@ -827,6 +827,10 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`; throw new AssertionFailureError(`Failed to access ${url}: file too large`); } snapshot.html = await readFile(await file.filePath, encoding); + const innerCharset = snapshot.html.slice(0, 1024).match(/]+text\/html;\s*?charset=([^>"]+)\"/i)?.[1]?.toLowerCase(); + if (innerCharset && innerCharset !== encoding) { + snapshot.html = await readFile(await file.filePath, innerCharset); + } return snapshot; }