Is there a way to test run a job with a command in wasp?
I'd like to test a script that I wrote but as it only runs once a day it's not practical. I could try and use it in a different file but wanted to check if there was an easy way first
3 Replies
Hi @CamBlackwood. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but based on the provided knowledge sources, there isn't a specific Wasp CLI command to test run a job. However, you can submit work to be done in your Operations (https://wasp-lang.dev/docs/data-model/operations/overview) or setupFn (https://wasp-lang.dev/docs/project/server-config#setup-function) (or any other NodeJS code) after successfully defining the job. Here's an example of how to define a job:
The worker function must be an
async
function. The function's return value represents the Job's result. The worker function accepts two arguments: args
(The data passed into the job when it's submitted) and context: { entities }
(The context object containing entities you put in the Job declaration) source (https://wasp-lang.dev/docs/advanced/jobs#job-definition-and-usage).
For more detailed information, you might want to check the official Wasp documentation or their GitHub repository.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @CamBlackwood, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?yeah @CamBlackwood you could import the job into an operation or api endpoint and run it whenver that endpoint is hit
@Vinny (@Wasp) thanks, ended up doing the API approach was super simple 🙂