Skip to main content

Overview

This guide covers testing strategies for both the RSS feed handler and Google Chat webhook integration during local development.

Testing the Healthcheck Endpoint

Verify that your server is running correctly:
curl http://localhost:3000/healthcheck
Expected Response:
Running!

Testing the RSS Feed Handler

The main endpoint processes the Shopify changelog feed and sends updates to Google Chat.

Basic Test

Trigger the RSS feed handler:
curl http://localhost:3000/get-rss-feed
Expected Response:
Done!
This will actually send messages to your configured Google Chat webhook if there are new items.

With Verbose Output

To see detailed console logs during testing:
1

Start the dev server

bun run dev
2

Trigger the endpoint in another terminal

curl http://localhost:3000/get-rss-feed
3

Check the server logs

Look for console output in your dev server terminal:
  • “No new items to process” - No updates found
  • “Successfully sent X update(s) to Google Chat” - Messages sent
  • Error messages if something went wrong

Testing Google Chat Webhook Integration

Prerequisites

Ensure you have:
  1. A valid Google Chat webhook URL in your .env file
  2. The dev server running (bun run dev)

Test Message Sending

1

Trigger the RSS feed endpoint

curl http://localhost:3000/get-rss-feed
2

Check Google Chat

Open your Google Chat space and verify:
  • A card message appears with “Shopify Changelog Updates”
  • The card shows a list of recent updates
  • Each update has a title, date, and clickable link
  • An “View All Changelogs” button is present

Test Webhook URL Validity

Verify your webhook URL works independently:
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Test message from local development"
  }' \
  $WEBHOOK_URL
Replace $WEBHOOK_URL with your actual webhook URL, or use source .env && curl ... to load the variable.

Testing RSS Feed Parsing

Manual Feed Inspection

Test what the RSS parser returns:
1

Create a test script

Create test-rss.ts:
test-rss.ts
import Parser from "rss-parser";

const parser = new Parser();
const RSS_FEED_URL = "https://shopify.dev/changelog/feed.xml";

const feed = await parser.parseURL(RSS_FEED_URL);

console.log("Feed Title:", feed.title);
console.log("Total Items:", feed.items.length);
console.log("\nFirst 5 items:");

feed.items.slice(0, 5).forEach((item, index) => {
  console.log(`${index + 1}. ${item.title}`);
  console.log(`   Date: ${item.isoDate || item.pubDate}`);
  console.log(`   Link: ${item.link}`);
  console.log("");
});
2

Run the test script

bun run test-rss.ts

Test Date Filtering Logic

The handler only processes items newer than yesterday. To test this:
  1. Check the filtering logic in rss-handler.ts:40-64
  2. The getYesterdayDate() function returns yesterday at midnight
  3. Items are filtered based on their isoDate or pubDate
The service uses the following logic:
  • Initial Run: Processes items from yesterday onwards (prevents sending old items)
  • Subsequent Runs: Would process items newer than the last processed date (in production with state persistence)
  • Current Implementation: Always starts from yesterday for each run
To test with different dates, modify the getProcessedState() function in rss-handler.ts:19-22.

Testing Error Handling

Missing Webhook URL

Test behavior when WEBHOOK_URL is not set:
1

Remove or comment out WEBHOOK_URL in .env

.env
# WEBHOOK_URL=...
2

Restart the server

bun run dev
3

Trigger the endpoint

curl http://localhost:3000/get-rss-feed
4

Check for error

Server logs should show:
Error: WEBHOOK_URL environment variable is not set

Invalid Webhook URL

Test with an invalid webhook URL:
WEBHOOK_URL=https://invalid-webhook-url.com bun run dev
Then trigger the endpoint. Server logs should show:
Failed to send updates to Gchat: [error details]

Debugging Tips

Enable Detailed Logging

Add console logs to track the flow:
// In rss-handler.ts
console.log("Feed fetched:", feed.items.length, "items");
console.log("Filtered items:", newItems.length);
console.log("Items to send:", newItems.map(i => i.title));

Inspect Card Message Structure

Before sending to Google Chat, log the card structure:
// In sendToGchat function (rss-handler.ts:115)
console.log("Card message:", JSON.stringify(cardMessage, null, 2));

Check Network Requests

Use curl’s verbose mode to see full request/response:
curl -v http://localhost:3000/get-rss-feed

Test with Different RSS Feeds

Temporarily modify the RSS_FEED_URL in rss-handler.ts:4 to test with other feeds:
const RSS_FEED_URL = "https://example.com/feed.xml";

Using Bun’s Test Runner

While the project doesn’t currently have test files, you can add them:
1

Create a test file

server.test.ts
import { test, expect } from "bun:test";
import app from "./server";

test("healthcheck returns 200", async () => {
  const req = new Request("http://localhost/healthcheck");
  const res = await app.fetch(req);
  
  expect(res.status).toBe(200);
  expect(await res.text()).toBe("Running!");
});
2

Run tests

bun test
Bun’s test runner is built-in and compatible with Jest-style syntax.

Common Testing Scenarios

Scenario: RSS feed has no items newer than yesterday.Expected: Console shows “No new items to process”, no Google Chat message sent.How to Test: Run the endpoint multiple times within the same day.
Scenario: RSS feed has several new items.Expected: Single card message with all items listed, newest first.How to Test: Modify getYesterdayDate() to return a date further in the past.
Scenario: Shopify’s RSS feed is down or unreachable.Expected: Error thrown and logged.How to Test: Temporarily change RSS_FEED_URL to an invalid URL.

Testing in Production-like Environment

To test the cron functionality locally:
Vercel cron jobs run in production. For local testing, manually trigger the endpoint or use a tool like cron on your machine.

Simulating Cron Execution

# Run once (simulates single cron execution)
curl http://localhost:3000/get-rss-feed

# Run on a schedule using watch (every 60 seconds)
watch -n 60 curl -s http://localhost:3000/get-rss-feed

Next Steps

Build docs developers (and LLMs) love