hello sunshine tests:
parameters & environment vars
- /params/singleParam (source)
- /params/multiple/parameters/in/the/url (source)
- /query?hello=sunshine&goodbye=rain (source)
- environment variable (source)
- ASSETS (index.html seems to be deleted) (source)
FormData
- FormData image converter (source) (FormData polyfish)
KV
- KV (source)
- ServeImages (source)
- Upload images and serve images from KV (source)
BasicAuth
- simple page protected by basic auth (source) (source2)
- logout (source)
Middleware
- errorHandler / middleware (source)
Testing preview and production branches
this page is visible
in production, but
not in preview branch.
this page is visible
not in production, but
in preview branch only.
Wrangler command
setup test KV
- To create a local KV table for testing `TEST => {"hello", "sunshine"}`, you make: 1) a file `.mf/kv/TEST/hello`
with the content `sunshine`. 2) For metadata, the file `.mf/kv/TEST/hello.meta.json` =>
`{"key":"hello","metadata":{"meta":"data"}}`
- If you need to add more complex data, you can write a worker or script that puts that data in the file for you.
- Be aware that when the key has `/` in it, then this will create folder structures. Todo find out how special
characters such as space and percent% and hash# and colon: is handled.
npx wrangler pages dev . --kv TEST --binding COLOR="red" --binding USER_PASS="hello:sunshine"