Giter Club home page Giter Club logo

reporter's Introduction

!IMPORTANT - This npm package has been renamed from test-results-reporter to testbeats. test-results-reporter will soon be phased out, and users are encouraged to transition to testbeats.

logo

Publish test results to Microsoft Teams, Google Chat, Slack and many more.


Build Downloads Downloads Size

Stars Downloads


Targets

slack teams chat

Extensions

reportportal quickchart hyperlink mentions

Test Results

testng junit cucumber mocha xunit jmeter


Sample Reports


teams-summary-report

slack-summary-report




Need Help

We use Github Discussions to receive feedback, discuss ideas & answer questions. Head over to it and feel free to start a discussion. We are always happy to help ๐Ÿ˜Š.

Support Us

Like this project! Star it on Github โญ. Your support means a lot to us.

reporter's People

Contributors

asaianudeep avatar leelaprasadv avatar mjeatough avatar sadeesh-sdet avatar salatamartin avatar uduckv avatar yash-pathak-groww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reporter's Issues

Extension - Percy

list of builds

https://percy.io/api/v1/builds?project_id=<id>&page[limit]=1
Payload
{
  "data": [
      {
          "type": "builds",
          "id": "<build-id>",
          "attributes": {
              "branch": "<branch-name>",
              "build-number": 69,
              "partial": false,
              "web-url": "https://percy.io/<org-id>/<project-name>/builds/<build-id>",
              "commit-html-url": null,
              "branch-html-url": null,
              "pull-request-html-url": null,
              "state": "finished",
              "review-state": "approved",
              "review-state-reason": "no_diffs",
              "is-pull-request": false,
              "pull-request-number": null,
              "pull-request-title": null,
              "user-agent": "Percy/v1 @percy/client/1.0.0-beta.76 @percy/cypress/3.1.1 (cypress/9.5.1; node/v14.17.5)",
              "total-snapshots": 1,
              "total-snapshots-requesting-changes": 0,
              "total-snapshots-unreviewed": 0,
              "total-comparisons": 2,
              "total-comparisons-finished": 2,
              "total-comparisons-diff": 0,
              "total-open-comments": 0,
              "failed-snapshots-count": 0,
              "failure-reason": null,
              "failure-details": null,
              "parallel-nonce": null,
              "parallel-total-shards": null,
              "finished-at": "2022-07-01T07:20:15.000Z",
              "approved-at": "2022-07-01T07:20:15.000Z",
              "created-at": "2022-07-01T07:19:16.000Z",
              "updated-at": "2022-07-01T07:20:15.000Z"
          },
          "links": {
              "self": "/api/v1/builds/<build-id>"
          },
          "relationships": {},
          "meta": {
              "finalize-link": "/api/v1/builds/<build-id>/finalize",
              "approve-link": "/api/v1/builds/<build-id>/approve"
          }
      }
  ],
  "included": [
      {
          "type": "projects",
          "id": "<project-id>",
          "attributes": {
              "name": "<project-name>",
              "slug": "<project-name>",
              "full-slug": "<org-id>/<project-name>",
              "is-enabled": true,
              "diff-base": "automatic",
              "auto-approve-branch-filter": "master",
              "default-base-branch": "master",
              "updated-at": "2022-07-01T07:20:15.000Z",
              "publicly-readable": false,
              "is-demo": false,
              "is-auto-browser-upgrade": true,
              "wait-for-base-build": false,
              "diff-sensitivity-level": 2
          },
          "links": {
              "self": "/api/v1/projects/<org-id>/<project-name>"
          },
          "relationships": {}
      },
      {
          "type": "commits",
          "id": "<commit-id>",
          "attributes": {
              "sha": "<id>",
              "message": "<message>",
              "author-name": "<name>"
          },
          "links": {
              "self": "/api/v1/commits/<commit-id>"
          }
      },
      {
          "type": "browsers",
          "id": "23",
          "attributes": {
              "version": "96.0.4664.110"
          },
          "links": {
              "self": "/api/v1/browsers/23"
          },
          "relationships": {
              "operating-system": {},
              "browser-family": {
                  "data": {
                      "type": "browser-families",
                      "id": "2"
                  }
              }
          }
      },
      {
          "type": "browsers",
          "id": "25",
          "attributes": {
              "version": "98.0.1108.43"
          },
          "links": {
              "self": "/api/v1/browsers/25"
          },
          "relationships": {
              "operating-system": {},
              "browser-family": {
                  "data": {
                      "type": "browser-families",
                      "id": "3"
                  }
              }
          }
      },
      {
          "type": "browser-families",
          "id": "2",
          "attributes": {
              "name": "Chrome",
              "slug": "chrome"
          }
      },
      {
          "type": "browser-families",
          "id": "3",
          "attributes": {
              "name": "Edge",
              "slug": "edge"
          }
      },
      {
          "type": "builds",
          "id": "<build-id>",
          "attributes": {
              "branch": "<branch-name>",
              "build-number": 68,
              "partial": false,
              "web-url": "https://percy.io/<org-id>/<project-name>/builds/<build-id>",
              "commit-html-url": null,
              "branch-html-url": null,
              "pull-request-html-url": null,
              "state": "finished",
              "review-state": "approved",
              "review-state-reason": "no_diffs",
              "is-pull-request": false,
              "pull-request-number": null,
              "pull-request-title": null,
              "user-agent": "Percy/v1 @percy/client/1.0.0-beta.76 @percy/cypress/3.1.1 (cypress/9.5.1; node/v14.17.5)",
              "total-snapshots": 1,
              "total-snapshots-requesting-changes": 0,
              "total-snapshots-unreviewed": 0,
              "total-comparisons": 2,
              "total-comparisons-finished": 2,
              "total-comparisons-diff": 0,
              "total-open-comments": 0,
              "failed-snapshots-count": 0,
              "failure-reason": null,
              "failure-details": null,
              "parallel-nonce": null,
              "parallel-total-shards": null,
              "finished-at": "2022-07-01T07:18:27.000Z",
              "approved-at": "2022-07-01T07:18:27.000Z",
              "created-at": "2022-07-01T07:17:18.000Z",
              "updated-at": "2022-07-01T07:18:27.000Z"
          },
          "links": {
              "self": "/api/v1/builds/<build-id>"
          },
          "relationships": {},
          "meta": {
              "finalize-link": "/api/v1/builds/<build-id>/finalize",
              "approve-link": "/api/v1/builds/<build-id>/approve"
          }
      }
  ]
}

Global Extensions

Global extensions will help to share common extensions across targets.

{
  "targets": [],
  "extensions": [],
  "results": []
}
# create a new issue for supporting this
Support new option to either append or override the extension.
- **mode**: "append/override"

Functional hyperlinks

The url can be an asynchronous function.

  • Include the link only if the function returns a non-empty string
const config = {
  "reports": [
    {
      "targets": [
        {
          "name": "teams",
          "inputs": {
            "url": "<teams-incoming-webhook-url>"
          },
          "extensions": [
            {
              "name": "hyperlinks",
              "inputs": {
                "links": [
                  {
                    "text": "Build Logs",
                    "url": async ({ result, target }) => { return "url" }
                  }
                ]
              }   
            }
          ]
        }
      ],
      "results": [
        {
          "type": "testng",
          "files": ["path/to/testng-results.xml"]
        }
      ]
    }
  ]
};

Conditional hyperlinks

hyperlinks should support an additional optional field called condition to determine whether to attach the given hyperlink to the teams or slack message.

Condition could be

  • pass
  • fail
  • passOrFail (default)

Example

{ 
  "name": "hyperlinks", 
  "inputs": { 
    "links": [ 
      { 
        "text": "Build Logs", 
        "url": "<build-logs-url>",
        "condition": "fail"
      }
    ] 
  }
}  

Use Case

  • Attach a application logs hyperlink when test cases have failed.

when milliseconds are 0, the colon notation function fails to parse

const { toColonNotation } = require('colon-notation');
console.log(toColonNotation(0)); 

Expected

00:00

colon-notation library doesn't have a GitHub repository.

Update

Use pretty-ms library in place of colon notation. This gives us more control on how we can display the duration in the messages.

Example verbose duration
"targets": [
   {
      "name": "teams",
      "inputs": {
        "url": "<teams-incoming-webhook-url>",
        "duration": "verbose"
      }
    }
]

Support all formats from the above package.

Add build.yml

Add build.yml file to validate pr's and merges to main branch

Advanced Conditions

"condition": "eq('{GIT_BRANCH}', 'master') and neq('{ENVIRONMENT}', 'dev')"
"condition": "gt('{ENVIRONMENT}', 10)"

or

"condition": "'{GIT_BRANCH}' === 'master' && '{ENVIRONMENT}' !== 'dev'"

Logs

Attach logs to print the progress of the reporting.

Target - Title Links

{
  "reports": [
    {
      "targets": [
        {
          "name": "teams",
          "inputs": {
            "url": "<teams-incoming-webhook-url>",
            "title_link": "<url>"
          }
        }
      ],
      "results": [
        {
          "type": "testng",
          "files": ["path/to/testng-results.xml"]
        }
      ]
    }
  ]
}

Condition - Support Functions

{
    "name": "slack",
    "condition": async function({ target, extension, result }) { return true; },
    "inputs": {
      "url": "<incoming-webhook-url>"
    }
}

Support custom extension

const config = {
  "reports": [
    {
      "targets": [
        {
          "name": "teams",
          "inputs": {
            "url": "<teams-incoming-webhook-url>"
          },
          "extensions": [
            {
              "name": "custom",
              "inputs": {
                "load": "/path/to/file" || async () => {}
              }   
            }
          ]
        }
      ],
      "results": [
        {
          "type": "testng",
          "files": ["path/to/testng-results.xml"]
        }
      ]
    }
  ]
}

Extension - Report Portal History

Request

https://<domain>/api/v1/<project-id>/item/history?historyDepth=5&filter.eq.launchId=16992&filter.%21ex.parentId=true

Response

{
    "content": [
        {
            "groupingField": "401523112",
            "resources": [
                {
                    "id": 4694372,
                    "uuid": "6e0a65b1-fake-fake-fake-74acfc28586c",
                    "name": "Staging - UI Smoke Test Run",
                    "parameters": [],
                    "attributes": [],
                    "type": "SUITE",
                    "startTime": 1652436245101,
                    "endTime": 1652437006339,
                    "status": "FAILED",
                    "statistics": {
                        "executions": {
                            "total": 16,
                            "failed": 8,
                            "skipped": 8
                        },
                        "defects": {
                            "to_investigate": {
                                "total": 8,
                                "ti001": 8
                            }
                        }
                    },
                    "pathNames": {
                        "launchPathName": {
                            "name": "staging-smoke",
                            "number": 49
                        }
                    },
                    "hasChildren": true,
                    "hasStats": true,
                    "launchId": 16566,
                    "uniqueId": "auto:<id>",
                    "testCaseHash": 401523112,
                    "patternTemplates": [],
                    "path": "4694372"
                }
            ]
        }
    ],
    "page": {
        "number": 1,
        "size": 20,
        "totalElements": 1,
        "totalPages": 1
    }
}

Fetch Report Portal Analysis using Launch Name

Request

https://<domain>/api/v1/<project-id>/launch?filter.eq.name=staging-smoke&page.size=1&page.sort=startTime%2Cdesc

Response

{
    "content": [
        {
            "owner": "<username>",
            "share": false,
            "id": 17249,
            "uuid": "0f76cea6-fake-fake-fake-4b018e734994",
            "name": "staging-smoke",
            "number": 60,
            "startTime": 1652787419497,
            "endTime": 1652788009231,
            "lastModified": 1652788009879,
            "status": "PASSED",
            "statistics": {
                "executions": {
                    "total": 8,
                    "passed": 8
                },
                "defects": {}
            },
            "attributes": [],
            "mode": "DEFAULT",
            "analysing": [],
            "approximateDuration": 623.4104,
            "hasRetries": false,
            "rerun": false
        }
    ],
    "page": {
        "number": 1,
        "size": 1,
        "totalElements": 60,
        "totalPages": 60
    }
}

Extension - Test Context

It's always helpful to get additional context about the test results like browser name, resolution or even some custom tags. This extension will help to attach this additional context in slack and teams message.

  • key/value pairs
  • labels

Support extensions for targets - Teams & Slack

{
  "name": "teams",
  "url": "<teams-incoming-webhook-url>",
  "publish": "test-summary",
  "extensions": [
    {
      "name": "report-portal-analysis",
      "location": "post-main",
      "options": {
        "url": "<report-portal-base-url>",
        "api_key": "<api-key>",
        "project": "<project-id>",
        "launch_id": "<launch-id>"
      }
    }
  ]
  "links": [{ "text": "Build Logs", "url": "<url>" }]
}

Duration - Update format to human friendly by default

Functional Tests

{
  "reports": [
    {
      "targets": [
        {
          "name": "teams",
          "inputs": {
            "url": "<teams-incoming-webhook-url>",
            "duration": "compact"
          }
        }
      ],
      "results": [
        {
          "type": "testng",
          "files": ["path/to/testng-results.xml"]
        }
      ]
    }
  ]
}

Supported formats:

  • compact
  • verbose
  • colonNotation

Performance Tests

  • disable secondsDecimalDigits

Common

  • Update the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.