Testing
Call the draft with ?test, send requests from the console, and let the assistant test what it builds.
Every change creates a new draft. The live version keeps serving traffic until you publish, so you can test freely.
#Call the draft
Add ?test to any function URL:
curl "https://my-api.fn.wispfn.com/orders?test&id=1042"Without ?test, the request goes to the published version. A project that has never been published only answers with ?test.
In your code, req.mode is "test" for draft requests.
#Test from the console
Open an function and press Test. The URL up to the query string is fixed to that function; edit the query string, add headers and a body, and send. The response shows the status, headers, body (JSON is formatted) and how long it took.
For functions without HTTP, press Run and pass the input as JSON.
#Let the assistant test
After the assistant creates or changes an function, it calls it with a realistic request and fixes what fails. Ask for specific cases too: "test /orders with an empty items list".
#From the command line
wisp invoke orders -q id=1042 # the draft
wisp invoke orders --live -q id=1042 # the live version
wisp invoke create-order -d @order.json # body from a fileSee CLI.
#Things to keep in mind
- Storage is shared. Draft and live read and write the same key-value data, tables and files.
- Config is shared. Variables and secrets apply to both.
- Calls follow the mode. When a draft function calls another function, it calls that function's draft too.
- Test requests use Run credits like live ones.