Title: Document about the ways to write unit tests for Bolt apps · Issue #380 · slackapi/bolt-python · GitHub
Open Graph Title: Document about the ways to write unit tests for Bolt apps · Issue #380 · slackapi/bolt-python
X Title: Document about the ways to write unit tests for Bolt apps · Issue #380 · slackapi/bolt-python
Description: I am looking to write unit tests for my Bolt API, which consists of an app with several handlers for events / messages. The handlers are both decorated using the app.event decorator, and make use of the app object to access things like t...
Open Graph Description: I am looking to write unit tests for my Bolt API, which consists of an app with several handlers for events / messages. The handlers are both decorated using the app.event decorator, and make use o...
X Description: I am looking to write unit tests for my Bolt API, which consists of an app with several handlers for events / messages. The handlers are both decorated using the app.event decorator, and make use o...
Opengraph URL: https://github.com/slackapi/bolt-python/issues/380
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document about the ways to write unit tests for Bolt apps","articleBody":"I am looking to write unit tests for my Bolt API, which consists of an app with several handlers for events / messages. The handlers are both _decorated_ using the `app.event` decorator, _and_ make use of the `app` object to access things like the `db` connection that has been put on it. For example:\r\n\r\n```python\r\n# in main.py\r\napp = App(\r\n token=APP_TOKEN,\r\n signing_secret=SIGNING_SECRET,\r\n process_before_response=True,\r\n token_verification_enabled=token_verification_enabled,\r\n)\r\napp.db = db\r\n\r\n# in api.py:\r\nfrom .main import app\r\n\r\n@app.command(\"/slashcommand\")\r\ndef slash_command(ack, respond):\r\n ack()\r\n results = app.db.do_query()\r\n respond(...)\r\n```\r\n\r\nThe thing is, I cannot find any framework pointers, or documentation, on how I would write reasonable unit tests for this. Presumably ones where the kwargs like `ack` and `respond` are replaced by test doubles. How do I do this?\r\n### The page URLs\r\n\r\n* https://slack.dev/bolt-python/\r\n\r\n## Requirements\r\n\r\nPlease read the [Contributing guidelines](https://github.com/slackapi/bolt-python/blob/main/.github/contributing.md) and [Code of Conduct](https://slackhq.github.io/code-of-conduct) before creating this issue or pull request. By submitting, you are agreeing to those rules.\r\n","author":{"url":"https://github.com/offbyone","@type":"Person","name":"offbyone"},"datePublished":"2021-06-15T21:30:22Z","url":"https://github.com/slackapi/bolt-python/issues/380"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:0d881a7a-7688-0d4c-c101-b452b04e7927 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C7E:27D4D3:6C193:99BC7:6AFEBD29 |
| html-safe-nonce | e0caecea12553041c68fcbb9043f25bf0daaed9bcb930db540e4cfd843df0770 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzdFOjI3RDREMzo2QzE5Mzo5OUJDNzo2QUZFQkQyOSIsInZpc2l0b3JfaWQiOiIxNDQ5MDkzMDQwODYwNzQwOTA1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 607ce34f8f9a99a088a23059b09e9b9a58fb4557ad6dfbf50c50226f251df840 |
| hovercard-subject-tag | issue:921818202 |
| 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/slackapi/bolt-python/380/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9b4fd56506e5f194f9ddd771fdf295bd4ce176868b7a27a499b276e93608e419/slackapi/bolt-python/issues/380 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b4fd56506e5f194f9ddd771fdf295bd4ce176868b7a27a499b276e93608e419/slackapi/bolt-python/issues/380 |
| og:image:alt | I am looking to write unit tests for my Bolt API, which consists of an app with several handlers for events / messages. The handlers are both decorated using the app.event decorator, and make use o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | offbyone |
| hostname | github.com |
| expected-hostname | github.com |
| None | 95b2753c978240785d6cca00783c00a371b2d7d9879bb32e305170a1b19bd28e |
| turbo-cache-control | no-preview |
| go-import | github.com/slackapi/bolt-python git https://github.com/slackapi/bolt-python.git |
| octolytics-dimension-user_id | 6962987 |
| octolytics-dimension-user_login | slackapi |
| octolytics-dimension-repository_id | 268795735 |
| octolytics-dimension-repository_nwo | slackapi/bolt-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 268795735 |
| octolytics-dimension-repository_network_root_nwo | slackapi/bolt-python |
| 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 | e1ce4c46d35aa8463a597a1bbffd4f0a456edb38 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width