{"id":15552400,"url":"https://github.com/bahmutov/cypress-slack-notify","last_synced_at":"2026-02-14T13:01:08.600Z","repository":{"id":60272945,"uuid":"542052699","full_name":"bahmutov/cypress-slack-notify","owner":"bahmutov","description":"Post messages in Slack channels when specific Cypress tests and specs fail","archived":false,"fork":false,"pushed_at":"2024-12-17T22:22:36.000Z","size":626,"stargazers_count":6,"open_issues_count":13,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-27T20:12:53.868Z","etag":null,"topics":["cypress-plugin","slack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-27T11:37:31.000Z","updated_at":"2024-12-09T04:05:46.000Z","dependencies_parsed_at":"2022-09-27T13:10:17.733Z","dependency_job_id":"c45253f0-914f-4ed3-8690-34db7137c43f","html_url":"https://github.com/bahmutov/cypress-slack-notify","commit_stats":{"total_commits":72,"total_committers":3,"mean_commits":24.0,"dds":"0.38888888888888884","last_synced_commit":"1c68376b9a5b8df2b19f3f603bd51ce63293b15a"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-slack-notify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-slack-notify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-slack-notify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-slack-notify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/cypress-slack-notify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234305848,"owners_count":18811434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypress-plugin","slack"],"created_at":"2024-10-02T14:18:49.551Z","updated_at":"2026-02-14T13:01:08.592Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cypress-slack-notify ![cypress version](https://img.shields.io/badge/cypress-15.10.0-brightgreen) [![cypress-slack-notify](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/avzi1n/main\u0026style=flat\u0026logo=cypress)](https://dashboard.cypress.io/projects/avzi1n/runs) [![ci](https://github.com/bahmutov/cypress-slack-notify/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-slack-notify/actions/workflows/ci.yml)\n\n\u003e Post messages in Slack channels when specific Cypress tests and specs fail\n\n![Notify Slack messages](./images/notify.png)\n\n## Install\n\nAdd this plugin as a dev dependency\n\n```shell\n$ npm i -D cypress-slack-notify\n# or add using Yarn\n$ yarn add -D cypress-slack-notify\n```\n\nRegister this plugin from your `cypress.config.js` file (or from your plugins file is using Cypress v9)\n\n```js\n// cypress.config.js\nconst { defineConfig } = require('cypress')\n\n// describe the notification of each failed spec\n// you want to notify about\nconst notificationConfiguration = {\n  // if this spec fails, post a message to the channel \"e2e-tests\"\n  'spec-a.cy.js': '#e2e-tests',\n  // if this spec fails, post a message and notify Gleb\n  'spec-b.cy.js': '#e2e-tests @gleb',\n  // if this spec fails, notify several users\n  'spec-c.cy.js': '#e2e-tests @gleb @john @mary',\n}\n\n// describe when to notify. We probably want to notify\n// only when running on CI and recording the test runs\n// and using certain run tags\nconst notifyWhen = {\n  whenRecordingOnDashboard: true,\n  whenRecordingDashboardTag: ['notify'],\n}\n\nmodule.exports = defineConfig({\n  projectId: '...',\n  e2e: {\n    setupNodeEvents(on, config) {\n      // https://github.com/bahmutov/cypress-slack-notify\n      require('cypress-slack-notify')(on, notificationConfiguration, notifyWhen)\n    },\n  },\n})\n```\n\n### Slack App\n\nTo use this plugin, you will need to get yourself a `SLACK_TOKEN` by making a new Slack App. This app needs a bot token with the scope [\"chat:write\"](https://api.slack.com/scopes/chat:write) to post messages using [`chat.postMessage`](https://api.slack.com/methods/chat.postMessage) method. If you want to tag specific users in the messages, you will need to give the app the permission scope [\"users:read\"](https://api.slack.com/scopes/users:read) too; it allows the plugin to call [`users.list`](https://api.slack.com/methods/users.list) method to include the user ID in the messages. You will need to invite the registered and installed Slack App to each channel you would like to post messages by this plugin.\n\nYou can confirm the Slack application integration by calling:\n\n```\n$ SLACK_TOKEN=... npx cypress-slack-notify --test-channel #my-channel-name\n```\n\nIf the application has been installed correctly, the message will be posted.\n\n![Testing Slack application](./images/test-message.png)\n\n## whenISaySo\n\nYou can provide your own synchronous predicate function to decide if this plugin should send Slack notifications on failed specs.\n\n```js\nconst notifyWhen = {\n  whenISaySo({ runDashboardUrl, runDashboardTags }) {\n    // look at the provided arguments, or any logic like process.env.CI\n    // etc to determine if you want to send Slack notifications\n    return true | false\n  },\n}\n\n// https://github.com/bahmutov/cypress-slack-notify\nrequire('cypress-slack-notify')(on, notificationConfiguration, notifyWhen)\n```\n\n## Minimatch\n\nYou can list spec files by the filename / end of the filepath. You can also rely on [minimatch](https://github.com/isaacs/minimatch) to find the target Slack channel.\n\n```js\nconst notificationConfiguration = {\n  // equivalents\n  'spec-a.cy.js': '#one',\n  'e2e/spec-a.cy.js': '#one',\n  'cypress/e2e/spec-a.cy.js': '#one',\n  // use minimatch with spec paths\n  // https://github.com/isaacs/minimatch\n  // In this case, any failed specs directly in the \"sub\" folder\n  // will post notification to '#cypress-slack-notify-minimatch'\n  // https://github.com/isaacs/minimatch\n  '**/sub/*.cy.js': '#two',\n}\n```\n\nIn the above situation, any failed test in the spec like `cypress/e2e/sub/home.cy.js` will be posted to `#two`.\n\n## Single channel shortcut\n\nYou can post a message about every failed spec into a single channel by using a config shortcut\n\n```js\n// cypress.config.js\n// https://github.com/bahmutov/cypress-slack-notify\nconst registerSlackNotify = require('cypress-slack-notify')\n...\nsetupNodeEvents(on, config) {\n  // any recorded run tagged \"sanity\" should notify #sanity-tests channel\n  // on each failed spec\n  registerSlackNotify(on, '#sanity-tests', {\n    whenRecordingDashboardTag: ['sanity'],\n  })\n})\n```\n\n## Effective test tags\n\nIf you use [cypress-grep](https://glebbahmutov.com/blog/cypress-grep-filters/) plugin to tag suites or individual tests, you can direct the messages based on the effective test tags.\n\n```js\ndescribe('Login tests', { tags: ['@auth'] }, () =\u003e {\n  // a failing spec with effective tag \"@auth\n  it('fails', () =\u003e ... )\n})\n```\n\n```js\n// cypress.config.js\n// https://github.com/bahmutov/cypress-slack-notify\nconst registerSlackNotify = require('cypress-slack-notify')\n\nsetupNodeEvents(on, config) {\n  // any recorded run tagged \"sanity\" should notify #sanity-tests channel\n  // on each failed spec\n  registerSlackNotify(on,\n    {\n      testTags: {\n        // list each tag and the Slack target\n        '@auth': '#cypress-slack-notify-effective-tags @gleb',\n      },\n      // only send notifications when recording\n      // on Cypress Dashboard with the tag \"user\"\n      {\n        whenRecordingDashboardTag: ['user'],\n      }\n    }\n  )\n}\n```\n\nSee [cypress.effective.config.js](./cypress.effective.config.js)\n\n**Tip:** you can define the test tags to Slack targets in a JSON file and load it using a `require` command. For example, if the JSON file below is used `notify.json` we can do:\n\n```json\n{\n  \"@auth\": \"#auth-tests @gleb\",\n  \"@sell\": \"#sell-tests @gleb\"\n}\n```\n\n```js\nregisterSlackNotify(\n  on,\n  {\n    testTags: require('./notify.json'),\n  },\n  // only send notifications when recording\n  // on Cypress Dashboard with the tag \"nightly\"\n  {\n    whenRecordingDashboardTag: ['nightly'],\n  },\n)\n```\n\n## Multiple registrations\n\nYou can register this plugin multiple times and direct messages based on the recorded Dashboard tags.\n\n```js\n// cypress.config.js\n// https://github.com/bahmutov/cypress-slack-notify\nconst registerSlackNotify = require('cypress-slack-notify')\n...\nsetupNodeEvents(on, config) {\n  // any recorded run tagged \"sanity\" should notify #sanity-tests channel\n  // on each failed spec\n  registerSlackNotify(on, '#sanity-tests', {\n    whenRecordingDashboardTag: ['sanity'],\n  })\n  // any recorded run tagged \"user\" should notify #user-tests channel\n  // on each failed spec\n  registerSlackNotify(on, '#user-tests', {\n    whenRecordingDashboardTag: ['user'],\n  })\n})\n```\n\n## Find Slack user id\n\nTo notify users in the message, this plugin needs to find Slack user ID from the username. You can see the found user by running the `cypress-slack-notify` bin alias\n\n```shell\n$ npx cypress-slack-notify --find-user @gleb\nfound Slack user @gleb ID: U12345678\n# use Yarn to call the \"bin/cypress-slack-notify.js\" script\n# You can also skip the \"@\" at the start of the username\n$ yarn cypress-slack-notify --find-user gleb\n```\n\nWhen searching the users, we consider both the property \"name\" and \"profile.display_name\" fields.\n\nYou can pass multiple usernames separating them with a comma\n\n```shell\n$ npx cypress-slack-notify --find-user @gleb,slackbot\nfound Slack user @gleb ID: U12345678\n...\n```\n\nIf you pass Slack user IDs (they start with `U`), they will simply be returned\n\n```shell\n$ npx cypress-slack-notify --find-user @U12345678\nalready is a Slack user ID U12345678\n...\n```\n\n## Find a single Slack user by its Slack ID\n\n```shell\n$ npx cypress-slack-notify --find-user-by-slack-id U12345678\n```\n\nPrints the user's display and real name if found.\n\n## Debugging\n\nEnable verbose log messages by setting an environment variable `DEBUG=cypress-slack-notify`\n\n## Examples\n\nSee [bahmutov/cypress-slack-example](https://github.com/bahmutov/cypress-slack-example)\n\n## Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2022\n\n- [@bahmutov](https://twitter.com/bahmutov)\n- [glebbahmutov.com](https://glebbahmutov.com)\n- [blog](https://glebbahmutov.com/blog)\n- [videos](https://www.youtube.com/glebbahmutov)\n- [presentations](https://slides.com/bahmutov)\n- [cypress.tips](https://cypress.tips)\n- [Cypress Tips \u0026 Tricks Newsletter](https://cypresstips.substack.com/)\n- [my Cypress courses](https://cypress.tips/courses)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/cypress-slack-notify/issues) on Github\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-slack-notify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fcypress-slack-notify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-slack-notify/lists"}