Gathering detailed insights and metrics for @pedro.pires/cypress-slack-reporter
Gathering detailed insights and metrics for @pedro.pires/cypress-slack-reporter
Gathering detailed insights and metrics for @pedro.pires/cypress-slack-reporter
Gathering detailed insights and metrics for @pedro.pires/cypress-slack-reporter
npm install @pedro.pires/cypress-slack-reporter
Typescript
Module System
Node Version
NPM Version
Release v2.0.5
Updated on Jan 27, 2025
Release v2.0.4
Updated on Oct 25, 2024
Release v1.5.4 - cypress-slack-reporter
Updated on Oct 24, 2024
Release v2.0.3 - cypress-multi-reporters
Updated on Oct 24, 2024
Release v1.6.4
Updated on Oct 24, 2023
Release v1.6.3
Updated on Mar 13, 2023
JavaScript (58.45%)
TypeScript (22.32%)
HTML (8.83%)
Shell (4.83%)
Gherkin (1.72%)
Dockerfile (1.59%)
Makefile (1.21%)
MDX (0.69%)
CSS (0.36%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
170 Stars
1,218 Commits
47 Forks
1 Watchers
4 Branches
12 Contributors
Updated on Feb 23, 2025
Latest Version
1.3.1
Package Id
@pedro.pires/cypress-slack-reporter@1.3.1
Unpacked Size
56.32 kB
Size
14.11 kB
File Count
10
NPM Version
9.5.1
Node Version
18.16.0
Published on
Aug 17, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
39
A Slack Reporting tool built for Cypress but should work with any mocha based framework that is using mochawesome
For users who are not using CircleCi, you can get a simple report
--ci-provider none
provider flag to provide a simple slack message based on the mochawesome report status--custom-url
along with --ci-provider custom
to set custom report page url. that will be sent to slack.For jenkins users
--ci-provider jenkins
provider flag.It provides the following distinct message types
It provides the following information
And the following build/test artefacts
Note Please see the pre-requisites folder to current neccessary pre-requisites
Install the app
$ yarn add cypress-slack-reporter --dev
or
$ npm install cypress-slack-reporter --save-dev
Create a Slack app & create an incoming webhook
Set the following environment variables in your localhost or CI configuration.
SLACK_WEBHOOK_URL
- The full URL you created in the last step
eg. export SLACK_WEBHOOK_URL=yourWebhookUrlHere
You can optionally set one or more of the following env vars, to utilise a different slack webhook, dependent on the status of your build or test run.
SLACK_WEBHOOK_ERROR_URL
- For failing CI runsSLACK_WEBHOOK_FAILED_URL
- For failing test runsSLACK_WEBHOOK_PASSED_URL
- For passing test runsAny of the 4 env vars above with accept a comma seperated list of webhooks, if you wish to post your slack message to multiple webhooks (one webhook per channel in slack).
eg. export SLACK_WEBHOOK_URL=your1stWebhookUrlHere,your2ndWebhookUrlHere
$ npx cypress-slack-reporter --help
Usage: index.ts [options]
Options:
-v, --version output the version number
--vcs-provider [type] VCS Provider [github|bitbucket|none] (default: "github")
--ci-provider [type] CI Provider [circleci|jenkins|bitbucket|none|custom] (default: "circleci")
--custom-url [type] On selected --ci-provider=custom this link will be set to Test Report (default: "")
--report-dir [type] mochawesome json & html test report directory, relative to your package.json (default: "mochareports")
--screenshot-dir [type] cypress screenshot directory, relative to your package.json (default: "cypress/screenshots")
--video-dir [type] cypress video directory, relative to your package.json (default: "cypress/videos")
--verbose show log output
--only-failed only send message for failed tests
--custom-text [type] add additional text to message, wrap message in quotes
-h, --help display help for command
Yarn installation Instructions
1 yarn add mochawesome --dev 2 yarn add mochawesome-merge --dev 3 yarn add mochawesome-report-generator --dev 4 yarn add cypress-multi-reporters --dev
NPM installation Instructions
1 npm install mochawesome --save-dev 2 npm install mochawesome-merge --save-dev 3 npm install mochawesome-report-generator --save-dev 4 npm install cypress-multi-reporters --save-dev
cypress.json
1{ 2 ... 3 "reporter": "cypress-multi-reporters", 4 "reporterOptions": { 5 "configFile": "reporterOpts.json" 6 } 7} 8
reporterOpts.json
1{ 2 "reporterEnabled": "mochawesome", 3 "mochawesomeReporterOptions": { 4 "reportDir": "cypress/reports/mocha", 5 "quiet": true, 6 "overwrite": false, 7 "html": false, 8 "json": true 9 } 10}
This project is building in CircleCI and can be viewed at the following link
See the .circleci
folder
config.yml
- Contains the CircleCI build configurationThe following env vars are read for CircleCI users.
CIRCLE_SHA1
- The SHA1 hash of the last commit of the current buildCIRCLE_BRANCH
- The name of the Git branch currently being built.CIRCLE_USERNAME
- The GitHub or Bitbucket username of the user who triggered the build.CIRCLE_BUILD_URL
- The URL for the current build.CIRCLE_BUILD_NUM
- The number of the CircleCI build.CIRCLE_PULL_REQUEST
- Comma-separated list of URLs of the current build’s associated pull requests.CIRCLE_PROJECT_REPONAME
- The name of the repository of the current project.CIRCLE_PROJECT_USERNAME
- The GitHub or Bitbucket username of the current project.CI_URL="https://circleci.com/api/v1.1/project"
CIRCLE_PROJECT_ID
- This project ID used in artefact URLSIf you wish to use another CI provider, you can pass any name other than circleci
into the CLI flag --ci-provider
, which will allow you to enter your own environment variables for CI.
CI_URL
CI_SHA1
,CI_BRANCH
,CI_USERNAME
,CI_BUILD_URL
,CI_BUILD_NUM
,CI_PULL_REQUEST
,CI_PROJECT_REPONAME
CI_PROJECT_USERNAME
CircleCI have recently changed the API for retrieving API's. A URL is generated for artifacts in the format
https://${CI_BUILD_NUM}-${CI_PROJECT_ID}-gh.circle-artifacts.com/0
You can get the CIRCLE_PROJECT_ID
by checking https://circleci.com/docs/api/#artifacts-of-a-build
For example. the ID for this project is 177880476
, you can see it in the following URL
https://circleci.com/api/v1.1/project/github/YOU54F/cypress-slack-reporter/1/artifacts
which will return
1[ { 2 "path" : "root/app/mochareports/.gitignore", 3 "pretty_path" : "root/app/mochareports/.gitignore", 4 "node_index" : 0, 5 "url" : "https://1-177880476-gh.circle-artifacts.com/0/root/app/mochareports/.gitignore" 6}, 7... 8]
In order to correctly construct your artifact URL, you will need to manually retrieve this ID and set it as an env var titled CIRCLE_PROJECT_ID
EXPORT CIRCLE_PROJECT_ID=177880476
in windows
SET CIRCLE_PROJECT_ID=177880476
or in your CircleCI project's environment page.
There is also another workaround by setting a destination option in store_artifacts job in config.yml (CircleCI).
- store_artifacts:
path: ~/path/to/cypress/videos
destination: cypress/videos
will allow you to access artifacts through https://${CI_BUILD_NUM}-${CI_PROJECT_ID}-gh.circle-artifacts.com/0/cypress/videos/some_test_result.mp4
This is what it says on CircleCI Documentation:
Currently, store_artifacts has two keys: path and destination.
path is a path to the file or directory to be uploaded as artifacts.
destination (Optional) is a prefix added to the artifact paths in the artifacts API. The directory of the file specified in path is used as the default.
An example script is here as cli/spec/ts
A example of how you can use this script in your project to:-
mochawesome-merge
Either with the cli
1./node_modules/.bin/cypress-slack-reporter-full
Or with your own script
1rm -rf ./cypress/reports/mocha && npx ts-node script.ts
It can be called with the following options
interface SlackRunnerOptions {
ciProvider: string;
vcsRoot: string;
reportDir: string;
videoDir: string;
screenshotDir: string;
customUrl?: string;
onlyFailed?: boolean;
}
And will return a Slack IncomingWebhookResult.
No vulnerabilities found.
No security vulnerabilities found.