yarn test # Run all 50 unit tests
yarn test:watch # Watch mode
yarn test:coverage # With coverageyarn test:extensionTests the extension on the default Amazon.de product page.
yarn test:dynamicRuns the full test suite with all configured test cases.
yarn node test-dynamic.js "https://www.amazon.de/dp/PRODUCT_ID"Examples:
# Test a specific Amazon.de product
yarn node test-dynamic.js "https://www.amazon.de/dp/B0BNQ66ZN1"
# Test an Amazon.com product
yarn node test-dynamic.js "https://www.amazon.com/dp/B0D1XD1ZV3"
# Test a third-party seller product
yarn node test-dynamic.js "https://www.amazon.de/dp/XXXXXXXXXX"Edit test-dynamic.js and add to the TEST_CASES array:
const TEST_CASES = [
{
name: 'Amazon.de - Product WITHOUT Free Returns',
url: 'https://www.amazon.de/dp/B0XXXXXXXXX',
region: 'de',
expectedBehavior: {
hasWidget: true,
defectiveFree: true,
regularFree: false, // Expects paid shipping
hasCost: true, // Should show €6.50-€13.00
language: 'de'
}
},
// Add more test cases...
];🎉 TEST PASSED
✓ Has defective section: ✅
✓ Has regular section: ✅
✓ Shows free returns: ✅
❌ TEST FAILED
⚠️ Expected widget but none found
📋 Extension logs:
- [Amazon Returns Extension] No return information found
All tests save screenshots to /tmp/:
test-extension-screenshot.jpg- Basic extension testtest-[test-name].jpg- Dynamic test screenshotsdebug-[timestamp].jpg- Debug screenshots on failure
To test paid shipping logic (€6.50-€13.00), find products on Amazon.de that:
- Don't show "FREE Returns" badge
- Still allow returns within 14 days
- Usually lower-priced items or specific categories
Most Amazon Prime-eligible products have this badge.
Look for "Sold by [SellerName]" instead of "Sold by Amazon"
If widget doesn't appear:
- Check console logs in test output
- Look at debug screenshot in
/tmp/ - Verify extension is loaded (check browser during test)
- Check if URL matches content_scripts patterns in manifest.json
- Browser launches in non-headless mode (visible)
- Stays open for 5-10 seconds after test for inspection
- Extension is loaded via
--load-extensionflag - Cookies are accepted automatically
- Network waits for idle before testing
For CI/CD, modify test-dynamic.js:
- Set
headless: truein launch options - Remove the "stay open" delays
- Save screenshots only on failure