Fast and tiny JavaScript/TypeScript cron parser with timezone support
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix tests on Bun (different error msg)

+4 -6
+4 -6
test/scheduler.test.ts
··· 1471 1471 it("should throw for invalid timezone in nextRun", () => { 1472 1472 const from = new Date("2026-03-15T14:00:00Z"); 1473 1473 expect(() => nextRun("0 9 * * *", { from, timezone: "Invalid/Timezone" })).toThrow( 1474 - "Invalid time zone specified", 1474 + /time zone/i, 1475 1475 ); 1476 1476 }); 1477 1477 1478 1478 it("should throw for invalid timezone in previousRun", () => { 1479 1479 const from = new Date("2026-03-15T14:00:00Z"); 1480 1480 expect(() => previousRun("0 9 * * *", { from, timezone: "NotATimezone" })).toThrow( 1481 - "Invalid time zone specified", 1481 + /time zone/i, 1482 1482 ); 1483 1483 }); 1484 1484 1485 1485 it("should throw for invalid timezone in isMatch", () => { 1486 1486 const date = new Date("2026-03-15T09:00:00Z"); 1487 - expect(() => isMatch("0 9 * * *", date, { timezone: "Fake/Zone" })).toThrow( 1488 - "Invalid time zone specified", 1489 - ); 1487 + expect(() => isMatch("0 9 * * *", date, { timezone: "Fake/Zone" })).toThrow(/time zone/i); 1490 1488 }); 1491 1489 1492 1490 it("should throw for empty timezone string in nextRun", () => { 1493 1491 const from = new Date("2026-03-15T14:00:00Z"); 1494 - expect(() => nextRun("0 9 * * *", { from, timezone: "" })).toThrow("Invalid time zone"); 1492 + expect(() => nextRun("0 9 * * *", { from, timezone: "" })).toThrow(/time zone/i); 1495 1493 }); 1496 1494 }); 1497 1495 });