import { suite } from 'uvu'; import * as assert from 'uvu/assert'; import fs from 'fs'; import path from 'path'; import { execSync } from 'child_process'; import del from 'del'; import { fileURLToPath } from 'url'; const Sitemap = suite('Sitemap Generation'); const snapshot = `https://mysite.dev/episode/fazers/https://mysite.dev/episode/rap-snitch-knishes/https://mysite.dev/episode/rhymes-like-dimes/https://mysite.dev/episodes/`; const cwd = new URL('./fixtures/astro-rss', import.meta.url); const clear = () => del(path.join(fileURLToPath(cwd), 'dist')); // clear dist output Sitemap.before(() => clear()); Sitemap.after(() => clear()); Sitemap('Generates Sitemap correctly', async () => { execSync('node ../../../astro.mjs build', { cwd: fileURLToPath(cwd) }); const rss = await fs.promises.readFile(path.join(fileURLToPath(cwd), 'dist', 'sitemap.xml'), 'utf8'); assert.match(rss, snapshot); }); Sitemap.run();