Sveltekit and Cloudflare seem to be a great match. My objective is to deliver well-tested code, that runs smoothly on Cloudflare pages/workers. To do this, I use Cypress.io for e2e testing. The problem is that I can't trust the tests running locally, as using any Node.js API works fine locally (for example Buffer.from
). But this code breaks the site when deploying to Cloudflare.
How can I run the Sveltekit project locally to ensure it will work once deployed?
As a bonus, would it somehow be possible to configure the typescript project so it would throw errors when accessing Node.js API's? According to this Cloudflare page, workers are running a v8 instance. We are using the "official" adapter.
Thanks for your help.
SvelteKit is planning ways to make this easier in the long-term. You can hear Rich talk a bit about this in the most recent Svelte NYC meetup.
In the meantime, your best bet is to include something like a
"postbuild"
hook that pointsminiflare
to the output file that SK produced. This will ensure that the contents are bootable according to a Cloudflare Workers emulated environment. You can run an e2e test suite against thelocalhost
endpoint it spawns for you, too.