cypress-telegram-reporter
v0.1.1
Published
Package for generating a report in a telegram chat
Downloads
129
Readme
Cypress Telegram Reporter
Post your test results right into the Telegram channel
Report will be posted by your own Telegram Bot, so you can name it whatever you want and also add to multiple channels if necessary.
Installation
Install the package
npm i cypress-telegram-reporter
Create .env file in your project directory if you don't have one.
Now we need a Telegram Bot and Channel.
- Create a channel that you're going to use for posting a report.
- Search for @BotFather user in Telegram.
- Follow instructions and create a Bot. Name it so you know it's responsible for posting reports. (CompanyNameReportBot)
- Save API key for your bot securely.
- Put the API key into the .env variable - BOT_TOKEN
- Open your channel and copy invite link
- Send this link to any bot that can give you the chat ID (e.g. @username_to_id_bot)
- Store this chat ID in the .env variable - CHAT_ID
Our reporting channel is now all setup.
Also we need to add the reporter configuration for Cypress.
Create report config file in your project directory:
{
"reporterEnabled": "mochawesome",
"mochawesomeReporterOptions": {
"reportDir": "./mocha-reports",
"quiet": true,
"overwrite": false,
"html": false,
"json": true
}
}
Now edit the cypress configuration file (cypress.json) and add this lines.
{
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporter-config.json"
}
}
Install reporter pre-requisites:
npm install cypress-multi-reporters --save-dev
npm install mochawesome --save-dev
npm install mochawesome-merge --save-dev
npm install mochawesome-report-generator --save-dev
Finally let's install the plugin
Add this line to your plugins file:
const telegramReport = require('cypress-telegram-reporter');
And apply the report to the current config:
module.exports = (on, config) => {
telegramReporter(on, config);
}
Usage
Now simply run your tests from the command line:
npx cypress run
Options
In order to customize your report you'll need to edit the cypress config file.
All the configuration should be added to telegram
object in the env
property.includeStats
: If set to true
your report will also contain statistics of each test run.reportsPath
: Pattern for all your stored mochawesome reports. (default - reports/*.json)finalReport
: Name of the file where combined report is stored. (default - merged-report.json)statuses
: Object for modifying the result statuses text/symbols.
passed
: Status for Passed tests. (default - 😋)
failed
: Status for Failed tests. (default - 😡)
pending
: Status for Pending/Skipped tests. (default - 🥶)
Examples
Cypress configuration file: (cypress.json)
{
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporter-config.json"
},
"env": {
"telegram": {
"includeStats": true,
"reportsPath": "./mocha-reports/*.json",
"finalReport": "final-report.json",
"statuses": {
"passed": "PASSED",
"failed": "FAILED",
"pending": "SKIPPED"
}
}
}
}
License
MIT
Let me know in case of any issues!