const fs = require('fs'); const http = require('http'); const assert = require('assert'); const { chromium } = require('playwright'); const fixture = ` `; const expected = ` `; const content = ` `; const server = http.createServer((req, res) => { if (req.url === '/') { res.setHeader('Content-Type', 'text/html'); res.end(content); } if (req.url === '/svgo.browser.js') { res.setHeader('Content-Type', 'application/javascript'); res.end(fs.readFileSync('./dist/svgo.browser.js')); } res.end(); }); const runTest = async () => { const browser = await chromium.launch(); const context = await browser.newContext(); const page = await context.newPage(); await page.goto('http://localhost:5000'); const actual = await page.evaluate(() => globalThis.result); assert.equal(actual, expected); await browser.close(); }; server.listen(5000, async () => { try { await runTest(); console.info('Tested successfully'); server.close(); } catch (error) { server.close(); console.error(error.toString()); process.exit(1); } });