diff --git a/scripts/build-rss.js b/scripts/build-rss.js index 17bb4380d2a..933ec63d69d 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.js @@ -30,7 +30,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { }); if (missingDatePosts.length > 0) { - throw new Error('Missing date in post data'); + throw new Error(`Missing date in posts: ${missingDatePosts.map(p => p.title || p.slug).join(', ')}`); } const base = 'https://www.asyncapi.com' @@ -55,10 +55,10 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { rss.channel.generator = 'next.js' rss.channel.item = [] - const invalidPosts = posts.filter(post => + const invalidPosts = posts.filter(post => !post.title || !post.slug || !post.excerpt || !post.date ); - + if (invalidPosts.length > 0) { throw new Error('Missing required fields in post data'); } diff --git a/tests/build-rss.test.js b/tests/build-rss.test.js index 91d1de40935..6f07c966afa 100644 --- a/tests/build-rss.test.js +++ b/tests/build-rss.test.js @@ -128,7 +128,7 @@ describe('rssFeed', () => { jest.doMock('../config/posts.json', () => missingDateMockData, { virtual: true }); - await expect(rssFeed(type, title, desc, outputPath)).rejects.toThrow('Missing date in post data'); + await expect(rssFeed(type, title, desc, outputPath)).rejects.toThrow('Failed to generate RSS feed: Missing date in posts: Post without Date'); }); });