{"id":27351897,"url":"https://github.com/reportportal/agent-js-jest","last_synced_at":"2025-04-12T20:54:05.769Z","repository":{"id":39627953,"uuid":"159350824","full_name":"reportportal/agent-js-jest","owner":"reportportal","description":"Agent to integrate Jest with ReportPortal.","archived":false,"fork":false,"pushed_at":"2025-04-11T17:08:45.000Z","size":946,"stargazers_count":21,"open_issues_count":15,"forks_count":38,"subscribers_count":24,"default_branch":"develop","last_synced_at":"2025-04-11T17:49:10.269Z","etag":null,"topics":["javascript","jest","jest-reporter","js","reporter","reportportal"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@reportportal/agent-js-jest","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reportportal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-27T14:46:37.000Z","updated_at":"2025-04-11T17:08:40.000Z","dependencies_parsed_at":"2024-01-19T18:45:28.520Z","dependency_job_id":"d7cec6be-2454-42fc-9fb3-9352133e8859","html_url":"https://github.com/reportportal/agent-js-jest","commit_stats":{"total_commits":119,"total_committers":23,"mean_commits":5.173913043478261,"dds":0.7983193277310925,"last_synced_commit":"ddc1ee7c253df7182a880d5f1fc445aeae734561"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-js-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-js-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-js-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-js-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reportportal","download_url":"https://codeload.github.com/reportportal/agent-js-jest/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456293,"owners_count":21106601,"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":["javascript","jest","jest-reporter","js","reporter","reportportal"],"created_at":"2025-04-12T20:54:05.173Z","updated_at":"2025-04-12T20:54:05.759Z","avatar_url":"https://github.com/reportportal.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @reportportal/agent-js-jest\n\nAgent to integrate Jest with ReportPortal.\n* More about [Jest](https://jestjs.io/)\n* More about [ReportPortal](http://reportportal.io/)\n\n## Installation\n\n```shell\nnpm install --save-dev @reportportal/agent-js-jest\n```\n\n## Configuration\n\n**1.** Create `jest.config.js` file with reportportal configuration:\n```javascript\nmodule.exports = {\n    testRunner: 'jest-circus/runner',\n    testRegex: ['/__tests__/.*.spec.js?$'],\n    reporters: [\n        'default',\n        [\n            '@reportportal/agent-js-jest',\n            {\n                apiKey: 'reportportalApiKey',\n                endpoint: 'https://your.reportportal.server/api/v1',\n                project: 'Your reportportal project name',\n                launch: 'Your launch name',\n                attributes: [\n                    {\n                        key: 'key',\n                        value: 'value',\n                    },\n                    {\n                        value: 'value',\n                    },\n                ],\n                description: 'Your launch description',\n            }\n        ]\n    ],\n    ...\n};\n```\n\nIn case you use the jest config section of `package.json`, add the following entry:\n\n```JSON\n{\n    \"jest\": {\n        ...\n        \"reporters\": [\n            \"default\",\n            [\"@reportportal/agent-js-jest\",\n            {\n                \"token\": \"reportportalApiKey\",\n                \"endpoint\": \"https://your.reportportal.server/api/v1\",\n                \"project\": \"Your reportportal project name\",\n                \"launch\": \"Your launch name\",\n                \"attributes\": [\n                    {\n                        \"key\": \"key\",\n                        \"value\": \"value\"\n                    },\n                    {\n                        \"value\": \"value\"\n                    }\n                ],\n                \"description\": \"Your launch description\"\n            }]\n        ],\n        ...\n    }\n}\n```\n\nThe full list of available options presented below.\n\n| Option                             | Necessity  | Default   | Description                                                                                                                                                                                                                                                                                                                                                                              |\n|------------------------------------|------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| apiKey                             | Required   |           | User's reportportal token from which you want to send requests. It can be found on the profile page of this user.                                                                                                                                                                                                                                                                        |\n| endpoint                           | Required   |           | URL of your server. For example 'https://server:8080/api/v1'. Use `api/v2` for asynchronous reporting.                                                                                                                                                                                                                                                                                                                            |\n| launch                             | Required   |           | Name of launch at creation.                                                                                                                                                                                                                                                                                                                                                              |\n| project                            | Required   |           | The name of the project in which the launches will be created.                                                                                                                                                                                                                                                                                                                           |\n| attributes                         | Optional   | []        | Launch attributes.                                                                                                                                                                                                                                                                                                                                                                       |\n| description                        | Optional   | ''        | Launch description.                                                                                                                                                                                                                                                                                                                                                                      |\n| rerun                              | Optional   | false     | Enable [rerun](https://reportportal.io/docs/dev-guides/RerunDevelopersGuide)                                                                                                                                                                                                                                                                                                             |\n| rerunOf                            | Optional   | Not set   | UUID of launch you want to rerun. If not specified, reportportal will update the latest launch with the same name. Works only if `rerun` set to `true`.                                                                                                                                                                                                                                                                         |\n| mode                               | Optional   | 'DEFAULT' | Results will be submitted to Launches page \u003cbr/\u003e *'DEBUG'* - Results will be submitted to Debug page.                                                                                                                                                                                                                                                                                    |\n| skippedIssue                       | Optional   | true      | reportportal provides feature to mark skipped tests as not 'To Investigate'. \u003cbr/\u003e Option could be equal boolean values: \u003cbr/\u003e *true* - skipped tests considered as issues and will be marked as 'To Investigate' on reportportal. \u003cbr/\u003e *false* - skipped tests will not be marked as 'To Investigate' on application.                                                                  |\n| debug                              | Optional   | false     | This flag allows seeing the logs of the client-javascript. Useful for debugging.                                                                                                                                                                                                                                                                                                         |\n| launchId                           | Optional   | Not set   | The _ID_ of an already existing launch. The launch must be in 'IN_PROGRESS' status while the tests are running. Please note that if this _ID_ is provided, the launch will not be finished at the end of the run and must be finished separately.                                                                                                                                        |\n| restClientConfig                   | Optional   | Not set   | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests). \u003cbr/\u003e Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. |\n| isLaunchMergeRequired              | Optional   | false     | This flag determines whether to create temp files with the UUIDs of started launches and allow them to be merged using [`client-javascript`'s `mergeLaunches` method](https://github.com/reportportal/client-javascript#mergelaunches). Temp file format: `rplaunch-${launch_uuid}.tmp`.                                                                                                 |\n| launchUuidPrint                    | Optional   | false     | Whether to print the current launch UUID.                                                                                                                                                                                                                                                                                                                                                |\n| launchUuidPrintOutput              | Optional   | 'STDOUT'  | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`.                                                                                                                                                                                                                                                                         |\n| extendTestDescriptionWithLastError | Optional   | true      | If set to `true` the latest error log will be attached to the test case description.                                                                                                                                                                                                                                                                                                     |\n| token                              | Deprecated | Not set   | Use `apiKey` instead.                                                                                                                                                                                                                                                                                                                                                                    |\n\nThe following options can be overridden using ENVIRONMENT variables:\n\n| Option      | ENV variable    | Note                                   |\n|-------------|-----------------|----------------------------------------|\n| apiKey      | RP_API_KEY      ||\n| project     | RP_PROJECT_NAME ||\n| endpoint    | RP_ENDPOINT     ||\n| launch      | RP_LAUNCH       |                                        |\n| attributes  | RP_ATTRIBUTES   | *Format:* key:value,key:value,value    |\n| description | RP_DESCRIPTION  ||\n| launchId    | RP_LAUNCH_ID    |                                        |\n| mode        | RP_MODE         ||\n| token       | RP_TOKEN        | *deprecated* Use `RP_API_KEY` instead. |\n\nThis is for your convenience if you have a continuous job that runs your tests and may report results that point to a different reportportal project definition, launch name, or attributes.\n\n**2.** Add script to `package.json` file:\n```json\n{\n  \"scripts\": {\n    \"test\": \"jest --no-colors --detectOpenHandles --config ./jest.config.js\"\n  }\n}\n```\n\n## Features\n\n### Retries\n\nThe agent has support of retries.\nRead more about [retries in jest](https://jestjs.io/ru/docs/jest-object#jestretrytimesnumretries-options).\n\n## Reporting API\n\nThis reporter provides `ReportingApi` in global variables to use it directly in tests to send some additional data to the report.\n\n*Note:* Run with the default test files concurrency may lead to inconsistent files attaching. `ReportingApi` also does not support tests running in [`concurrent` mode](https://jestjs.io/docs/api#testconcurrentname-fn-timeout) at the moment.\n\nWe are going to fix this behavior in the future.\n\n### Reporting API methods\n\n#### attachment\nSend file to ReportPortal for the current test. Should be called inside of corresponding test.\u003cbr/\u003e\n`ReportingApi.attachment(file: {name: string; type: string; content: string | Buffer;}, description?: string);`\u003cbr/\u003e\n**required**: `file`\u003cbr/\u003e\n**optional**: `description`\u003cbr/\u003e\nExample:\n```javascript\ntest('should be passed with attachment', () =\u003e {\n    const fileName = 'test.png';\n    const fileContent = fs.readFileSync(path.resolve(__dirname, './attachments', fileName));\n\n    ReportingApi.attachment({\n        name: fileName,\n        type: 'image/png',\n        content: fileContent.toString('base64'),\n    }, 'Description');\n\n    expect(true).toBe(true);\n});\n```\n\n# Copyright Notice\n\nLicensed under the [Apache License v2.0](LICENSE)\n\n# Contribution\n\nThis code was based on the [jest-junit](https://github.com/jest-community/jest-junit)\nand adapted by team members of [Ontoforce](https://www.ontoforce.com) for the\nReportPortal upload. Ontoforce contributed this effort as Open Source to the\nReportPortal project team.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freportportal%2Fagent-js-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freportportal%2Fagent-js-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freportportal%2Fagent-js-jest/lists"}