- Guides
- Testing workflows
Guides
Testing workflows
Learn how to test your workflows from app.trigger.dev
While building your workflows, you will most likely need to test them on your local machine before deploying them to production. We currently provide one way to test your workflows locally, using our “Test” page in your app.trigger.dev Dashboard:
We will automatically populate the test editor with valid JSON data for the workflow you are testing, but you are free to edit it to your liking to test out different scenarious.
Testing and environments
When running a test, the test run will be created in the currently selected environment:
For more information on environments, see the Environments & API Keys guide.
Detecting a test in your runs
You can detect if a run is a test run using the context.isTest
property in your workflow code:
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
new Trigger({
id: "basic-starter",
name: "Basic Starter",
apiKey: "trigger_development_qvq1uKLrWT7o",
on: customEvent({
name: "basic.starter",
schema: z.object({ id: z.string() }),
}),
run: async (event, ctx) => {
if (ctx.isTest) {
await ctx.logger.info("This is a test run!");
}
},
}).listen();
Testing in code
We don’t currently provide a way to test your workflows in code, but we are working on it! We’ve tried to make decisions that will make it easy to test your workflows in code in the future, so we hope to be able to support this soon.