This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Description
Background
Cloudflare has added the support of their worker to be triggered by scheduled event. These workers are triggered on the cron schedule setup on Cloudflare Worker dashboard. They are implemented with an event listener to scheduled event instead of fetch in traditional worker. This causes the test with Cloudworker impossible.
Enhancement
Add the support of scheduled event to Cloudworker, where developers can mock the trigger of the worker. The usage of such worker will become
const Cloudworker = require('@ericxstone/cloudworker')
const simpleScript = `addEventListener('scheduled', event => {
event.waitUntil(() => {});
})`
const cw = new Cloudworker(simpleScript)
cw.triggerCronJob.then((res) => {
console.log("Schedule is triggered")
})