Title: [TRI-1127] Improvement: Add a `@trigger.dev/testing` package that allows for unit testing job runs · Issue #379 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: [TRI-1127] Improvement: Add a `@trigger.dev/testing` package that allows for unit testing job runs · Issue #379 · triggerdotdev/trigger.dev
X Title: [TRI-1127] Improvement: Add a `@trigger.dev/testing` package that allows for unit testing job runs · Issue #379 · triggerdotdev/trigger.dev
Description: Currently, we don't have a clean way of unit testing jobs, it would be nice to have a @trigger.dev/testing package that could be used to do test job runs with mocked io and make assertions: const jobToTest = client.defineJob({ id: "strip...
Open Graph Description: Currently, we don't have a clean way of unit testing jobs, it would be nice to have a @trigger.dev/testing package that could be used to do test job runs with mocked io and make assertions: const j...
X Description: Currently, we don't have a clean way of unit testing jobs, it would be nice to have a @trigger.dev/testing package that could be used to do test job runs with mocked io and make assertions: con...
Mail addresses
hello@trigger.dev
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/379
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[TRI-1127] Improvement: Add a `@trigger.dev/testing` package that allows for unit testing job runs","articleBody":"Currently, we don't have a clean way of unit testing jobs, it would be nice to have a `@trigger.dev/testing` package that could be used to do test job runs with mocked `io` and make assertions:\r\n\r\n```ts\r\nconst jobToTest = client.defineJob({\r\n id: \"stripe-example-1\",\r\n name: \"Stripe Example 1\",\r\n version: \"0.1.0\",\r\n trigger: eventTrigger({\r\n name: \"stripe.example\",\r\n schema: z.object({\r\n customerId: z.string(),\r\n source: z.string(),\r\n }),\r\n }),\r\n integrations: {\r\n stripe,\r\n },\r\n run: async (payload, io, ctx) => {\r\n await io.stripe.createCharge(\"create-charge\", {\r\n amount: 100,\r\n currency: \"usd\",\r\n source: payload.source,\r\n customer: payload.customerId,\r\n });\r\n },\r\n});\r\n\r\nimport { testJob } from \"@trigger.dev/testing\";\r\n\r\n// Inside a test file\r\nconst testRun = testJob(jobToTest, {\r\n payload: {\r\n customerId: \"cus_123\",\r\n source: \"src_123\",\r\n },\r\n});\r\n\r\nexpect(testRun).toHaveSucceeded();\r\n// Test the stripe charge was called with the correct params\r\nexpect(testRun.io.stripe.createCharge).toHaveBeenCalledWith(\"create-charge\", {\r\n amount: 100,\r\n currency: \"usd\",\r\n source: \"src_123\",\r\n});\r\n```\n\n\u003csub>[TRI-1127](https://linear.app/triggerdotdev/issue/TRI-1127/improvement-add-a-triggerdevtesting-package-that-allows-for-unit)\u003c/sub>","author":{"url":"https://github.com/ericallam","@type":"Person","name":"ericallam"},"datePublished":"2023-08-21T20:50:00Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/379"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:38b39fb0-2f47-c9f2-9566-d05f09083f6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B94A:346C31:511E3C:72F636:6AFB06FF |
| html-safe-nonce | 931382101c976cff2132778d99711b20f4d57db85d0cf9ef33fcdc5483522e51 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTRBOjM0NkMzMTo1MTFFM0M6NzJGNjM2OjZBRkIwNkZGIiwidmlzaXRvcl9pZCI6IjQ1MTU1NzI1NzYzNTI0MDUyNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0d441756585ba42bcd79c022d7fdb333c5703a4d83ecfa6112c28d41ec83d5f6 |
| hovercard-subject-tag | issue:1860129504 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/379/issue_layout |
| twitter:image | https://opengraph.githubassets.com/349c72e76703a4b4bdc8c1819ef77c96f06e6573fc2bb6015571011752c67b24/triggerdotdev/trigger.dev/issues/379 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/349c72e76703a4b4bdc8c1819ef77c96f06e6573fc2bb6015571011752c67b24/triggerdotdev/trigger.dev/issues/379 |
| og:image:alt | Currently, we don't have a clean way of unit testing jobs, it would be nice to have a @trigger.dev/testing package that could be used to do test job runs with mocked io and make assertions: const j... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericallam |
| hostname | github.com |
| expected-hostname | github.com |
| None | 76fb13cb43f1834708971f45a9cfcab5df3177a7582086613d7cdc6e98c4bfde |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | afc998826cdd963c8f91a96ae5372809ab5e296b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width