You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Tests sitemap generation for K12Beast, ensuring only root and public pages are included
3
+
import{readFile,existsSync}from'fs';
8
4
import{parseStringPromise}from'xml2js';
5
+
import{resolve}from'path';
6
+
import{promisify}from'util';
9
7
10
-
describe('Sitemap Generation',()=>{
11
-
constsitemapPath='./public/sitemap.xml';
8
+
constreadFileAsync=promisify(readFile);
12
9
13
-
beforeAll(()=>{
14
-
// Run next-sitemap CLI to generate sitemap.xml
15
-
try{
16
-
execSync('npm run sitemap',{stdio: 'inherit'});
17
-
}catch(error){
18
-
thrownewError(`Failed to generate sitemap: ${error.message}`);
19
-
}
20
-
});
21
-
22
-
afterAll(()=>{
23
-
// Clean up sitemap.xml
24
-
if(existsSync(sitemapPath)){
25
-
unlinkSync(sitemapPath);
26
-
}
27
-
});
10
+
describe('Sitemap Generation',()=>{
11
+
test('includes only root and public pages in sitemap.xml',async()=>{
12
+
// Resolve path to sitemap
13
+
constsitemapPath=resolve('public/sitemap.xml');
14
+
console.log(`[Sitemap Test] Checking for sitemap at: ${sitemapPath}`);
28
15
29
-
it('includes all expected pages in sitemap.xml',async()=>{
30
-
// Check if sitemap.xml exists
16
+
// Check if sitemap file exists
31
17
if(!existsSync(sitemapPath)){
32
-
thrownewError('Sitemap file not found: ./public/sitemap.xml. Ensure `npm run build` is run before `npm run sitemap`.');
18
+
thrownewError(
19
+
'Sitemap file not found at public/sitemap.xml. Ensure `npm run build` and `npm run sitemap` are run before tests. Check `next-sitemap.config.js` and `npm run sitemap` output for errors.'
0 commit comments