import * as fs from 'fs'; import * as path from 'path'; import { snapshot } from '../src/snapshot'; const htmlFolder = path.join(__dirname, 'html'); const htmls = fs.readdirSync(htmlFolder).map((filePath) => { const raw = fs.readFileSync(path.resolve(htmlFolder, filePath), 'utf-8'); return { filePath, src: raw, }; }); describe('snapshot tests', () => { for (const html of htmls) { const title = '[html file]: ' + html.filePath; it(title, async () => { const doc = new DOMParser().parseFromString(html.src, 'text/html'); const result = snapshot(doc); expect(result).toMatchSnapshot(); }); } });