├── .editorconfig ├── .github ├── CODEOWNERS └── workflows │ └── CI-pipeline.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── example-cucumber ├── README.md ├── cucumber.js ├── features │ ├── attachments │ │ ├── attachments.feature │ │ ├── files │ │ │ ├── test.css │ │ │ ├── test.html │ │ │ ├── test.jpg │ │ │ ├── test.json │ │ │ ├── test.mp4 │ │ │ └── test.png │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── attributes │ │ ├── attributes.feature │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── descriptions │ │ ├── descriptions.feature │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── logs │ │ ├── logs.feature │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── simpleFeature │ │ ├── is_it_friday_yet.feature │ │ ├── is_it_holiday.feature │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── statuses │ │ ├── statuses.feature │ │ └── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ └── world.js │ ├── testCaseId │ │ ├── step_definitions │ │ │ ├── stepdefs.js │ │ │ └── support │ │ │ │ └── world.js │ │ └── testCaseId.feature │ └── webdriverIntegrationFeature │ │ ├── step_definitions │ │ ├── stepdefs.js │ │ └── support │ │ │ ├── hooks.js │ │ │ └── world.js │ │ └── webdriver_integration.feature ├── package.json └── report-portal-formatter.js ├── example-cypress ├── basic │ ├── README.md │ ├── cypress.config.js │ ├── cypress │ │ ├── e2e │ │ │ ├── basic │ │ │ │ ├── another-feature.cy.js │ │ │ │ └── feature.cy.js │ │ │ └── rp-features │ │ │ │ ├── logTest.cy.js │ │ │ │ ├── pageVerification.cy.js │ │ │ │ ├── statusesTest.cy.js │ │ │ │ └── testCaseIdTest.cy.js │ │ ├── fixtures │ │ │ └── test.png │ │ ├── plugins │ │ │ └── index.js │ │ └── support │ │ │ ├── commands.js │ │ │ └── e2e.js │ └── package.json └── cucumber-preprocessor │ ├── README.md │ ├── cypress.config.js │ ├── cypress │ ├── e2e │ │ ├── google │ │ │ ├── google.feature │ │ │ └── step_definitions │ │ │ │ └── openingGoogle.js │ │ └── simpleFeature │ │ │ ├── simple.feature │ │ │ └── step_definitions │ │ │ ├── basic.js │ │ │ ├── dataTable.js │ │ │ ├── docString.js │ │ │ ├── scenario_outline_integer.js │ │ │ └── scenario_outline_word.js │ └── support │ │ ├── commands.js │ │ ├── e2e.js │ │ └── step_definitions.js │ └── package.json ├── example-jasmine ├── README.md ├── package.json ├── protractor-multiTread │ ├── multiThreadConf.js │ └── protractorLaunchFile.js ├── protractor │ └── simpleConfig.js ├── reportportalConf.js └── tests │ ├── attachments │ ├── test.css │ ├── test.html │ ├── test.jpg │ ├── test.json │ ├── test.mp4 │ └── test.png │ ├── attributesTest.spec.js │ ├── descriptionsTest.spec.js │ ├── logTest.spec.js │ ├── statusesTest.spec.js │ └── testCaseIdTest.spec.js ├── example-jest ├── README.md ├── __tests__ │ ├── attachments.spec.js │ ├── attachments │ │ └── test.png │ ├── differentStatuses.spec.js │ ├── parametrized.spec.js │ └── retries.spec.js ├── jest.config.js ├── package.json └── src │ └── calculator.js ├── example-mocha ├── README.md ├── main.js ├── package.json └── spec │ ├── attachments │ ├── test.css │ ├── test.html │ ├── test.jpg │ ├── test.json │ ├── test.mp4 │ └── test.png │ ├── attributesTest.spec.js │ ├── descriptionsTest.spec.js │ ├── logTest.spec.js │ ├── statusesTest.spec.js │ └── testCaseIdTest.spec.js ├── example-nightwatch ├── PFR-exampleChromeDriver │ ├── nightwatch.conf.js │ ├── params.js │ ├── reporter.js │ └── tests │ │ ├── suite1 │ │ ├── home.js │ │ └── search.js │ │ └── suite2 │ │ ├── google.js │ │ └── others.js ├── PFR-exampleUnitTests │ ├── nightwatch.json │ ├── params.js │ ├── reporter.js │ └── tests │ │ ├── suite1 │ │ ├── test1.js │ │ └── test2.js │ │ └── suite2 │ │ └── test1.js ├── README.md ├── RTR-exampleChromeDriver │ ├── data │ │ └── cities.json │ ├── nightwatch.conf.js │ └── tests │ │ ├── attributes.js │ │ ├── home.js │ │ ├── logs.js │ │ ├── search.js │ │ ├── statuses.js │ │ └── testCaseId.js ├── RTR-exampleChromeDriverParallelRun │ ├── data │ │ └── cities.json │ ├── nightwatch.conf.js │ └── tests │ │ ├── home.js │ │ └── search.js ├── package.json └── rp.json ├── example-playwright ├── .sauce │ └── config.yml ├── .sauceignore ├── README.md ├── global-setup.ts ├── package.json ├── playwright.config.ts ├── rpConfigCi.js ├── scripts │ ├── finishLaunch.js │ └── startLaunch.js └── tests │ ├── basic │ ├── another-feature.spec.ts │ └── feature.spec.ts │ └── rp-features │ ├── attachments.spec.ts │ ├── attachments │ ├── test.css │ ├── test.html │ ├── test.jpg │ ├── test.json │ ├── test.mp4 │ └── test.png │ ├── attributes-and-description.spec.ts │ ├── logs.spec.ts │ ├── retries.spec.ts │ ├── statuses.spec.ts │ └── test-case-id.spec.ts ├── example-postman ├── README.md ├── collections │ └── Example.postman_collection.json ├── index.js └── package.json ├── example-testcafe ├── .testcaferc.js ├── README.md ├── package.json ├── rp.json ├── testcafeManualSetup.js └── tests │ ├── attachments │ ├── test.css │ ├── test.html │ ├── test.jpg │ ├── test.json │ ├── test.mp4 │ └── test.png │ ├── attributesTest.spec.js │ ├── descriptionWithError.spec.js │ ├── foo.spec.js │ ├── logTest.spec.js │ └── testCaseIdTest.spec.js ├── example-vitest ├── basic │ ├── package.json │ ├── src │ │ └── basic.ts │ ├── test │ │ ├── basic.spec.ts │ │ ├── files │ │ │ └── test.png │ │ ├── reportingApi.spec.ts │ │ └── suite.spec.ts │ └── vitest.config.ts └── playwright │ ├── index.html │ ├── package.json │ ├── src │ └── index.ts │ ├── test │ └── basic.test.ts │ ├── tsconfig.json │ └── vitest.config.ts └── example-webdriverio ├── README.md ├── example-webdriverio-cucumber ├── package.json ├── tests │ ├── features │ │ ├── attributes.feature │ │ ├── description.feature │ │ ├── logs.feature │ │ └── statuses.feature │ └── stepDefinitions │ │ ├── attributes │ │ ├── given.js │ │ └── then.js │ │ ├── description │ │ ├── given.js │ │ └── then.js │ │ ├── logs │ │ ├── given.js │ │ └── then.js │ │ └── statuses │ │ ├── given.js │ │ └── then.js └── wdio.conf.js ├── example-webdriverio-jasmine ├── package.json ├── tests │ ├── attachments │ │ ├── test.css │ │ ├── test.html │ │ ├── test.jpg │ │ ├── test.json │ │ ├── test.mp4 │ │ └── test.png │ ├── attributes.spec.js │ ├── description.spec.js │ ├── foo.spec.js │ ├── logs.spec.js │ └── statuses.spec.js └── wdio.conf.js └── examples-webdriverio-mocha ├── jsconfig.json ├── package.json ├── tests ├── attachments │ ├── test.css │ ├── test.html │ ├── test.jpg │ ├── test.json │ ├── test.mp4 │ └── test.png ├── attributesTest.spec.js ├── descriptionsTest.spec.js ├── logTest.spec.js ├── statusesTest.spec.js └── testCaseIdTest.spec.js └── wdio.conf.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | end_of_line = lf 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @AmsterGet 2 | -------------------------------------------------------------------------------- /.github/workflows/CI-pipeline.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 EPAM Systems 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | 14 | name: CI-pipeline 15 | 16 | on: 17 | workflow_dispatch: 18 | 19 | env: 20 | WORKING_DIR : 'example-playwright' 21 | 22 | jobs: 23 | start-rp-launch: 24 | runs-on: ubuntu-latest 25 | defaults: 26 | run: 27 | working-directory: ${{ env.WORKING_DIR }} 28 | outputs: 29 | rp_launch_id: ${{ steps.rp_launch.outputs.rp_launch_id }} 30 | steps: 31 | - name: Checkout 32 | uses: actions/checkout@v4 33 | 34 | - name: Set up Node.js 35 | uses: actions/setup-node@v4 36 | with: 37 | node-version: 20 38 | 39 | - name: Install dependencies 40 | run: npm install 41 | 42 | - name: Start launch and set it to output 43 | id: rp_launch 44 | uses: actions/github-script@v6 45 | with: 46 | script: | 47 | const startLaunch = require('./${{ env.WORKING_DIR }}/scripts/startLaunch.js'); 48 | const launchId = await startLaunch(); 49 | 50 | core.setOutput('rp_launch_id', launchId); 51 | env: 52 | RP_API_KEY: ${{ secrets.RP_API_KEY }} 53 | RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }} 54 | RP_PROJECT: ${{ secrets.RP_PROJECT }} 55 | 56 | 57 | playwright-tests-with-shards: 58 | needs: [start-rp-launch] 59 | timeout-minutes: 60 60 | runs-on: ubuntu-latest 61 | defaults: 62 | run: 63 | working-directory: ${{ env.WORKING_DIR }} 64 | strategy: 65 | fail-fast: false 66 | matrix: 67 | shardIndex: [1, 2, 3, 4] 68 | shardTotal: [4] 69 | steps: 70 | - name: Checkout repository 71 | uses: actions/checkout@v4 72 | 73 | - name: Set up Node.js 74 | uses: actions/setup-node@v4 75 | with: 76 | node-version: 20 77 | 78 | - name: Install dependencies 79 | run: npm install 80 | 81 | - name: Install Playwright browsers 82 | run: npx playwright install --with-deps 83 | 84 | - name: Run Playwright tests 85 | run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} 86 | env: 87 | RP_LAUNCH_ID: ${{ needs.start-rp-launch.outputs.rp_launch_id }} 88 | RP_API_KEY: ${{ secrets.RP_API_KEY }} 89 | RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }} 90 | RP_PROJECT: ${{ secrets.RP_PROJECT }} 91 | 92 | finish-rp-launch: 93 | runs-on: ubuntu-latest 94 | defaults: 95 | run: 96 | working-directory: ${{ env.WORKING_DIR }} 97 | # Finish RP launch after playwright-tests, even if some shards have failed 98 | if: ${{ !cancelled() }} 99 | needs: [start-rp-launch, playwright-tests-with-shards] 100 | steps: 101 | - name: Checkout 102 | uses: actions/checkout@v4 103 | 104 | - name: Set up Node.js 105 | uses: actions/setup-node@v4 106 | with: 107 | node-version: 20 108 | 109 | - name: Install dependencies 110 | run: npm install 111 | 112 | - name: Finish RP launch 113 | uses: actions/github-script@v6 114 | with: 115 | script: | 116 | const finishLaunch = require('./${{ env.WORKING_DIR }}/scripts/finishLaunch.js'); 117 | await finishLaunch(); 118 | env: 119 | RP_LAUNCH_ID: ${{ needs.start-rp-launch.outputs.rp_launch_id }} 120 | RP_API_KEY: ${{ secrets.RP_API_KEY }} 121 | RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }} 122 | RP_PROJECT: ${{ secrets.RP_PROJECT }} 123 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE 2 | .idea/ 3 | 4 | # Dependencies 5 | node_modules/ 6 | package-lock.json 7 | 8 | # Compiled 9 | dist 10 | __snapshots__ 11 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "printWidth": 100 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # examples-js 2 | Examples for JS integrations with ReportPortal. 3 | ## Here are examples for the following agents: 4 | 5 | * example-playwright for [agent-js-playwright](https://github.com/reportportal/agent-js-playwright) 6 | * example-cypress for [agent-js-cypress](https://github.com/reportportal/agent-js-cypress) 7 | * example-jest for [agent-js-jest](https://github.com/reportportal/agent-js-jest) 8 | * example-mocha for [agent-js-mocha](https://github.com/reportportal/agent-js-mocha) 9 | * example-webdriverio for [agent-js-webdriverio](https://github.com/reportportal/agent-js-webdriverio) 10 | * example-postman for [agent-js-postman](https://github.com/reportportal/agent-js-postman) 11 | * example-cucumber for [agent-js-cucumber](https://github.com/reportportal/agent-js-cucumber) 12 | * example-vitest for [agent-js-vitest](https://github.com/reportportal/agent-js-vitest) 13 | * example-jasmine for [agent-js-jasmine](https://github.com/reportportal/agent-js-jasmine) 14 | * example-testcafe for [agent-js-testcafe](https://github.com/reportportal/agent-js-testcafe) 15 | * example-nightwatch for [agent-js-nightwatch](https://github.com/reportportal/agent-js-nightwatch) 16 | -------------------------------------------------------------------------------- /example-cucumber/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-cucumber](https://www.npmjs.com/package/@reportportal/agent-js-cucumber) 2 | 3 | ## Preparation: 4 | Inside of `report-portal-formatter.js` fill in the `rpConfig` with the data from your ReportPortal instance. 5 | 6 | Do not forget to install all the necessary dependencies: 7 | ```cmd 8 | npm install 9 | ``` 10 | ## Run the example 11 | 12 | Then run npm tasks with `example:` prefix. For example, `example:simpleTest`. 13 | 14 | --- 15 | > Pay attention: you may change reporting behavior to report steps to the log level.\ 16 | > You need to pass an additional parameter to the agent config: "scenarioBasedStatistics": true\ 17 | > For more information check the link: [Step reporting configuration](https://github.com/reportportal/agent-js-cucumber#step-reporting-configuration) 18 | -------------------------------------------------------------------------------- /example-cucumber/cucumber.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | default: `--format-options '{"snippetInterface": "synchronous"}' -f ./report-portal-formatter.js`, 3 | }; 4 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/attachments.feature: -------------------------------------------------------------------------------- 1 | Feature: attachments 2 | 3 | Scenario Outline: Attachment reporting 4 | When I report attachment with type "" and "" 5 | 6 | Examples: 7 | | type | file | 8 | | text/html | test.html | 9 | | application/json | test.json | 10 | | application/css | test.css | 11 | | image/jpeg | test.jpg | 12 | | image/png | test.png | 13 | | video/mp4 | test.mp4 | 14 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } 4 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | 6 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-cucumber/features/attachments/files/test.jpg -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } 4 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-cucumber/features/attachments/files/test.mp4 -------------------------------------------------------------------------------- /example-cucumber/features/attachments/files/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-cucumber/features/attachments/files/test.png -------------------------------------------------------------------------------- /example-cucumber/features/attachments/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const { When } = require('@cucumber/cucumber'); 4 | 5 | When('I report attachment with type {string} and {string}', function(type, filePath, callback) { 6 | fs.readFile(path.resolve(__dirname, '../files', filePath), (err, data) => { 7 | if (err) { 8 | throw err; 9 | } 10 | // add attachment for step 11 | this.attach( 12 | JSON.stringify({ 13 | message: `Attachment with ${type}`, 14 | level: 'INFO', 15 | data: data.toString('base64'), 16 | }), 17 | type, 18 | ); 19 | // add attachment for launch 20 | this.attach( 21 | JSON.stringify({ 22 | message: `Attachment with ${type}`, 23 | level: 'INFO', 24 | data: data.toString('base64'), 25 | entity: 'launch', 26 | }), 27 | type, 28 | ); 29 | // add attachment for scenario 30 | this.attach( 31 | JSON.stringify({ 32 | message: `Attachment with ${type}`, 33 | level: 'INFO', 34 | data: data.toString('base64'), 35 | entity: 'scenario', 36 | }), 37 | type, 38 | ); 39 | callback(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /example-cucumber/features/attachments/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/attributes/attributes.feature: -------------------------------------------------------------------------------- 1 | @attributeKey:attributeValue @attributeValue_2 2 | Feature: attributes 3 | example: how to set custom **attributes** for `suite` and `steps` 4 | 5 | Scenario Outline: Given and expected value are equal 6 | This test contain `steps` with **attributes** 7 | 8 | When I put "" 9 | Then I should compare it with "" 10 | 11 | Examples: 12 | | value | answer | 13 | | true | true | 14 | -------------------------------------------------------------------------------- /example-cucumber/features/attributes/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { When, Then } = require('@cucumber/cucumber'); 3 | 4 | When('I put {string}', function (givenValue) { 5 | this.addAttributes([ { key: 'feature', value: 'attributes' }, { value: 'cucumberStep' }]); 6 | this.addDescription('This step contain **attributes**'); 7 | 8 | this.addScenarioAttributes([{ key: 'feature', value: 'attributes' }, { value: 'cucumberScenario' }]); 9 | this.addScenarioDescription('Additional description for **scenario**'); 10 | 11 | this.value = givenValue; 12 | }); 13 | 14 | Then('I should compare it with {string}', function (expectedValue) { 15 | this.addAttributes([{ key: 'feature', value: 'attributes' }, { value: 'cucumberStep' }]); 16 | this.addDescription('This step contain **attributes**'); 17 | 18 | assert.strictEqual(this.value, expectedValue); 19 | }); 20 | -------------------------------------------------------------------------------- /example-cucumber/features/attributes/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/descriptions/descriptions.feature: -------------------------------------------------------------------------------- 1 | @attributeKey:attributeValue @attributeValue_2 2 | Feature: descriptions 3 | example: how to provide **description** 4 | 5 | Scenario Outline: Given and expected value are equal 6 | This test contain `steps` with **description** 7 | 8 | When I put "" 9 | Then I should compare it with "" 10 | 11 | Examples: 12 | | value | answer | 13 | | true | true | 14 | | true | false | 15 | -------------------------------------------------------------------------------- /example-cucumber/features/descriptions/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { After, Before, When, Then } = require('@cucumber/cucumber'); 3 | 4 | Before(function () { 5 | this.addDescription('This is a **description** for `before step`'); 6 | }); 7 | 8 | After(function () { 9 | this.addDescription('This is a **description** for `after step`'); 10 | }); 11 | 12 | When('I put {string}', function (givenValue) { 13 | this.addAttributes([{ 14 | key: 'key', 15 | value: 'value' 16 | }]) 17 | this.value = givenValue; 18 | this.addDescription('This is a **description** for `when step`'); 19 | this.addScenarioDescription('Additional description for **scenario**'); 20 | }); 21 | 22 | Then('I should compare it with {string}', function (expectedValue) { 23 | this.addDescription('This is a **description** for `then step`'); 24 | assert.strictEqual(this.value, expectedValue); 25 | }); 26 | 27 | -------------------------------------------------------------------------------- /example-cucumber/features/descriptions/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/logs/logs.feature: -------------------------------------------------------------------------------- 1 | @attributeKey:attributeValue @attributeValue_2 2 | Feature: logs 3 | example: how to provide **logs** for `launch` and `steps` 4 | 5 | Scenario Outline: Given and expected value are equal 6 | This test contain `steps` with **logs** 7 | 8 | Given I am preparing scenario 9 | When I put "" 10 | Then I should compare it with "" 11 | 12 | Examples: 13 | | value | answer | 14 | | true | true | 15 | -------------------------------------------------------------------------------- /example-cucumber/features/logs/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { After, Before, Given, When, Then } = require('@cucumber/cucumber'); 3 | 4 | Before(function() { 5 | this.fatal('Before fatal log'); 6 | this.error('Before error log'); 7 | this.warn('Before warn log'); 8 | this.info('Before info log'); 9 | this.debug('Before debug log'); 10 | this.trace('Before trace log'); 11 | 12 | this.launchFatal('This is a fatal launch log'); 13 | this.launchError('This is a error launch log'); 14 | this.launchWarn('This is a warn launch log'); 15 | this.launchInfo('This is a info launch log'); 16 | this.launchDebug('This is a debug launch log'); 17 | this.launchTrace('This is a trace launch log'); 18 | 19 | this.addDescription('This step contains **logs**'); 20 | }); 21 | 22 | After(function() { 23 | this.fatal('After fatal log'); 24 | this.error('After error log'); 25 | this.warn('After warn log'); 26 | this.info('After info log'); 27 | this.debug('After debug log'); 28 | this.trace('After trace log'); 29 | 30 | this.addDescription('This step contains **logs**'); 31 | }); 32 | 33 | Given('I am preparing scenario', function() { 34 | this.scenarioInfo('This is Info Level log'); 35 | this.scenarioDebug('This is Debug Level log'); 36 | this.scenarioError('This is Error Level log'); 37 | this.scenarioWarn('This is Warn Level log'); 38 | this.scenarioTrace('This is Trace Level log'); 39 | this.scenarioFatal('This is Fatal Level log'); 40 | 41 | this.addScenarioDescription('This scenario contains **logs**'); 42 | }); 43 | 44 | When('I put {string}', function(givenValue) { 45 | this.fatal('Step fatal log'); 46 | this.error('Step error log'); 47 | this.warn('Step warn log'); 48 | this.info('Step info log'); 49 | this.debug('Step debug log'); 50 | this.trace('Step trace log'); 51 | 52 | this.addDescription('This step contains **logs**'); 53 | 54 | this.value = givenValue; 55 | }); 56 | 57 | Then('I should compare it with {string}', function (expectedValue) { 58 | this.fatal('Step fatal log'); 59 | this.error('Step error log'); 60 | this.warn('Step warn log'); 61 | this.info('Step info log'); 62 | this.debug('Step debug log'); 63 | this.trace('Step trace log'); 64 | 65 | this.addDescription('This step contains **logs**'); 66 | 67 | assert.strictEqual(this.value, expectedValue); 68 | }); 69 | 70 | -------------------------------------------------------------------------------- /example-cucumber/features/logs/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/simpleFeature/is_it_friday_yet.feature: -------------------------------------------------------------------------------- 1 | @feature:friday @when 2 | Feature: Is it Friday yet? 3 | Everybody wants to know when it's Friday 4 | 5 | @scenario:checkToday 6 | Scenario Outline: Today is or is not Friday 7 | Description of scenario 8 | 9 | Given today is "" 10 | When I ask whether it's Friday yet 11 | Then I should be told "" 12 | 13 | Examples: 14 | | day | answer | 15 | | Friday | TGIF | 16 | | Sunday | Nope | 17 | | anything else! | Nope | 18 | 19 | Scenario: Today is or is not Monday (but it's failing) 20 | Given today is Monday 21 | When I ask whether it's Monday yet 22 | Then I should be told Yes 23 | -------------------------------------------------------------------------------- /example-cucumber/features/simpleFeature/is_it_holiday.feature: -------------------------------------------------------------------------------- 1 | Feature: Is it Holiday yet? 2 | Everybody wants to know when Saturday is 3 | 4 | Background: Load Holidays 5 | Given list of holidays 6 | 7 | Scenario Outline: Today is or is not Holiday 8 | Description of scenario 9 | 10 | Given today is "" 11 | When I ask wheter it's Holiday 12 | Then I should be told "" 13 | 14 | Examples: 15 | | day | answer | 16 | | Presidents | Yes | 17 | | Valentines | Nope | 18 | | Independence | Yes | 19 | | St.Patrick's | Nope | 20 | 21 | Scenario: April Fool's is not Holiday 22 | Description of scenario 23 | 24 | Given today is "Apirl Fool's" 25 | When I ask wheter it's Holiday 26 | Then I should be told "Nope" -------------------------------------------------------------------------------- /example-cucumber/features/simpleFeature/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { Given, When, Then, Before, After } = require('@cucumber/cucumber'); 3 | 4 | function isItFriday(today) { 5 | if (today === 'Friday') { 6 | return 'TGIF'; 7 | } 8 | return 'Nope'; 9 | } 10 | 11 | Before(function() { 12 | this.info('Before info log'); 13 | this.launchWarn('This is a warn launch log'); 14 | }); 15 | 16 | After(function() { 17 | this.info('After info log'); 18 | }); 19 | 20 | Given('list of holidays', function() { 21 | this.holidays = [ 22 | 'New Years', 23 | 'Martin Luther King, Jr.', 24 | 'Presidents', 25 | 'Memorial', 26 | 'Independence', 27 | 'Labor', 28 | 'Veterans', 29 | 'Thanksgiving', 30 | 'Christmas', 31 | ]; 32 | }); 33 | 34 | Given('today is {string}', function(givenDay) { 35 | this.today = givenDay; 36 | }); 37 | 38 | When("I ask whether it's Friday yet", function() { 39 | this.actualAnswer = isItFriday(this.today); 40 | }); 41 | 42 | Then('I should be told {string}', function(expectedAnswer) { 43 | if (this.actualAnswer !== expectedAnswer) { 44 | this.error(`Test error: ${this.actualAnswer} !== ${expectedAnswer}`); 45 | } 46 | assert.equal(this.actualAnswer, expectedAnswer); 47 | }); 48 | 49 | Given('today is Monday', function() { 50 | this.today = 'Monday'; 51 | }); 52 | 53 | When(/^I ask whether it's Monday yet$/, function() { 54 | this.actualAnswer = 'Nope'; 55 | }); 56 | 57 | Then('I should be told Yes', function() { 58 | const expectedAnswer = 'Yes'; 59 | if (this.actualAnswer !== expectedAnswer) { 60 | this.error(`Test error: ${this.actualAnswer} !== ${expectedAnswer}`); 61 | } 62 | assert.equal(this.actualAnswer, expectedAnswer); 63 | }); 64 | 65 | When("I ask wheter it's Holiday", function() { 66 | this.actualAnswer = 'Nope'; 67 | if (this.holidays.includes(this.today)) { 68 | this.actualAnswer = 'Yes'; 69 | } 70 | }); 71 | -------------------------------------------------------------------------------- /example-cucumber/features/simpleFeature/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/statuses/statuses.feature: -------------------------------------------------------------------------------- 1 | @attributeKey:attributeValue @attributeValue_2 2 | Feature: statuses 3 | example: how to set custom **status** for `launch` and `steps` 4 | 5 | Scenario Outline: Given and expected value are equal 6 | This test contain `launch` and `steps` with different **statuses** 7 | 8 | When I put "" 9 | Then I should compare it with "" 10 | 11 | Examples: 12 | | value | answer | 13 | | true | true | 14 | -------------------------------------------------------------------------------- /example-cucumber/features/statuses/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | 2 | const assert = require('assert'); 3 | const { Before, When, Then } = require('@cucumber/cucumber'); 4 | 5 | Before('', function () { 6 | this.setLaunchStatusStopped(); 7 | 8 | this.addDescription('Provide **STOPPED** status for launch'); 9 | }) 10 | 11 | When('I put {string}', function(givenValue) { 12 | this.setStatusFailed(); 13 | this.addDescription('This step had a **PASSED** status, but was overwritten with an **FAILED** status'); 14 | 15 | this.value = givenValue; 16 | }); 17 | 18 | Then('I should compare it with {string}', function (expectedValue) { 19 | this.setStatusInterrupted(); 20 | this.addDescription('This step had a **PASSED** status, but was overwritten with an **INTERRUPTED** status'); 21 | 22 | this.setScenarioStatusPassed(); 23 | this.addScenarioDescription('This scenario had a **FAILED** status, but was overwritten with an **PASSED** status'); 24 | 25 | assert.strictEqual(this.value, expectedValue); 26 | }); 27 | 28 | -------------------------------------------------------------------------------- /example-cucumber/features/statuses/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/testCaseId/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { When, Then } = require('@cucumber/cucumber'); 3 | 4 | When('I put {string}', function(givenValue) { 5 | this.setTestCaseId('testCaseId'); 6 | this.addDescription('This step with **testCaseID=testCaseId**'); 7 | 8 | this.value = givenValue; 9 | }); 10 | 11 | Then('I should compare it with {string}', function (expectedValue) { 12 | this.setTestCaseId('testCaseId_2'); 13 | this.addDescription('This step with **testCaseID=testCaseId_2**'); 14 | 15 | this.setScenarioTestCaseId('testCaseId_scenario'); 16 | this.addScenarioDescription('This scenario with **testCaseID=testCaseId_scenario**'); 17 | 18 | assert.strictEqual(this.value, expectedValue); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /example-cucumber/features/testCaseId/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | const cucumber = require('@cucumber/cucumber'); 2 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 3 | 4 | cucumber.setWorldConstructor(RPWorld); 5 | -------------------------------------------------------------------------------- /example-cucumber/features/testCaseId/testCaseId.feature: -------------------------------------------------------------------------------- 1 | @attributeKey:attributeValue @attributeValue_2 2 | Feature: testCaseId 3 | example: how to set custom **testCaseId** for `steps` 4 | 5 | Scenario Outline: Given and expected value are equal 6 | This test contain `steps` with **testCaseId** 7 | 8 | When I put "" 9 | Then I should compare it with "" 10 | 11 | Examples: 12 | | value | answer | 13 | | true | true | 14 | -------------------------------------------------------------------------------- /example-cucumber/features/webdriverIntegrationFeature/step_definitions/stepdefs.js: -------------------------------------------------------------------------------- 1 | const { Given, When, Then } = require('@cucumber/cucumber'); 2 | const { until } = require('selenium-webdriver'); 3 | 4 | Given(/^I am on the Cucumber.js GitHub repository/, function(callback) { 5 | this.addScenarioDescription('This test should load GitHub cucumber-js page and take the screenshot!'); 6 | this.addScenarioAttributes([{ key: 'feature', value: 'demo' }]); 7 | this.addDescription('This test should load GitHub cucumber-js page and take the screenshot!'); 8 | this.info('Going to the GitHub'); 9 | global.browser 10 | .get('https://github.com/cucumber/cucumber-js/tree/master') 11 | .then(() => { 12 | this.setTestCaseId('itemTestCaseId'); 13 | return this.screenshot('Test screen'); 14 | }) 15 | .then(() => { 16 | this.addDescription('Screenshot taken!'); 17 | callback(); 18 | }) 19 | .catch((err) => { 20 | this.addDescription('Error occurred!'); 21 | callback(err); 22 | }); 23 | }); 24 | 25 | When(/^I click on '(.*)'/, function(text, callback) { 26 | this.info('Click at the element'); 27 | this.addAttributes([{ key: 'browser', value: 'chrome' }]); 28 | global.browser 29 | .findElement({ linkText: text }) 30 | .then((element) => { 31 | return element.click(); 32 | }) 33 | .then(() => { 34 | return this.launchScreenshot('Test screen for launch'); 35 | }) 36 | .then(() => { 37 | this.addDescription('Screenshot for launch taken!'); 38 | this.setStatusPassed(); 39 | callback(); 40 | }) 41 | .catch((err) => callback(err)); 42 | }); 43 | 44 | Then(/^I should see '(.*)'/, function(text, callback) { 45 | const xpath = `//*[contains(text(),'${text}')]`; 46 | const condition = until.elementLocated({ xpath }); 47 | this.info('Waiting for the elements'); 48 | this.scenarioScreenshot('This is screenshot for scenario').then(() => { 49 | this.addScenarioDescription('Screenshot for scenario taken!'); 50 | return global.browser.wait(condition, 5000); 51 | }).then(() => { 52 | callback(); 53 | }).catch((err) => callback(err)); 54 | }); 55 | -------------------------------------------------------------------------------- /example-cucumber/features/webdriverIntegrationFeature/step_definitions/support/hooks.js: -------------------------------------------------------------------------------- 1 | const { setDefaultTimeout } = require('@cucumber/cucumber'); 2 | 3 | setDefaultTimeout(20000); 4 | -------------------------------------------------------------------------------- /example-cucumber/features/webdriverIntegrationFeature/step_definitions/support/world.js: -------------------------------------------------------------------------------- 1 | require('chromedriver'); 2 | const cucumber = require('@cucumber/cucumber'); 3 | const { Builder } = require('selenium-webdriver'); 4 | const { Options } = require('selenium-webdriver/chrome'); 5 | const { RPWorld } = require('@reportportal/agent-js-cucumber'); 6 | 7 | class CustomWorld extends RPWorld { 8 | constructor(...args) { 9 | super(...args); 10 | 11 | global.browser = new Builder() 12 | .forBrowser('chrome') 13 | .setChromeOptions(new Options().headless()) 14 | .build(); 15 | } 16 | } 17 | 18 | cucumber.setWorldConstructor(CustomWorld); 19 | -------------------------------------------------------------------------------- /example-cucumber/features/webdriverIntegrationFeature/webdriver_integration.feature: -------------------------------------------------------------------------------- 1 | Feature: Webdriver integration 2 | Description of the feature 3 | 4 | Scenario: Open cucumber-js GitHub page 5 | Given I am on the Cucumber.js GitHub repository 6 | When I click on 'CLI' 7 | # just for the test fail 8 | Then I should see 'TEST FAIL' 9 | -------------------------------------------------------------------------------- /example-cucumber/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "example:simpleTest": "cucumber-js features/simpleFeature/ --require=features/simpleFeature/**/*.js", 4 | "example:simpleTestWithRetries": "cucumber-js features/simpleFeature/ --require=features/simpleFeature/**/*.js --retry 2", 5 | "example:simpleTestParallel": "cucumber-js features/simpleFeature/ --require=features/simpleFeature/**/*.js --retry 2 --parallel 3", 6 | "example:seleniumWebdriverTest": "cucumber-js features/webdriverIntegrationFeature/ --require=features/webdriverIntegrationFeature/**/*.js", 7 | "example:attachmentTest": "cucumber-js features/attachments/ --require=features/attachments/**/*.js", 8 | "example:descriptionsTest": "cucumber-js features/descriptions/ --require=features/descriptions/**/*.js", 9 | "example:logsTest": "cucumber-js features/logs --require=features/logs/**/*.js", 10 | "example:testCaseIdTest": "cucumber-js features/testCaseId --require=features/testCaseId/**/*.js", 11 | "example:attributesTest": "cucumber-js features/attributes --require=features/attributes/**/*.js", 12 | "example:statusesTest": "cucumber-js features/statuses --require=features/statuses/**/*.js" 13 | }, 14 | "dependencies": { 15 | "@reportportal/agent-js-cucumber": "^5.4.0", 16 | "chromedriver": "*", 17 | "selenium-webdriver": "^3.6.0", 18 | "@cucumber/cucumber": "^10.8.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example-cucumber/report-portal-formatter.js: -------------------------------------------------------------------------------- 1 | const { createRPFormatterClass } = require('@reportportal/agent-js-cucumber'); 2 | 3 | const rpConfig = { 4 | endpoint: 'http://your-instance.com:8080/api/v1', 5 | apiKey: '', 6 | launch: 'Your launch name', 7 | project: 'Your reportportal project name', 8 | attributes: [ 9 | { 10 | key: 'launchK', 11 | value: 'launchV' 12 | } 13 | ], 14 | description: 'Your launch name description', 15 | }; 16 | 17 | module.exports = createRPFormatterClass(rpConfig); 18 | -------------------------------------------------------------------------------- /example-cypress/basic/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-cypress](https://www.npmjs.com/package/@reportportal/agent-js-cypress) 2 | 3 | The examples are written with Cypress >=9 compatibility in mind, but the agent also works with Cypress <9. 4 | 5 | ## Installation: 6 | 7 | Install the packages: 8 | 9 | ```cmd 10 | npm install 11 | ``` 12 | 13 | ## Configuration: 14 | 15 | Specify the options in the cypress.config.js: 16 | 17 | ```javascript 18 | module.exports = defineConfig({ 19 | reporter: '@reportportal/agent-js-cypress', 20 | reporterOptions: { 21 | endpoint: 'http://your-instance.com:8080/api/v1', 22 | apiKey: 'reportportalApiKey', 23 | launch: 'LAUNCH_NAME', 24 | project: 'PROJECT_NAME', 25 | description: 'LAUNCH_DESCRIPTION', 26 | }, 27 | e2e: { 28 | setupNodeEvents(on, config) { 29 | return registerReportPortalPlugin(on, config) 30 | }, 31 | }, 32 | }); 33 | ``` 34 | 35 | Using `cypress-multi-reporters` package: 36 | 37 | ```javascript 38 | module.exports = defineConfig({ 39 | reporter: 'cypress-multi-reporters', 40 | reporterOptions: { 41 | reporterEnabled: ['@reportportal/agent-js-cypress', 'mochawesome'], 42 | mochawesomeReporterOptions: { 43 | reportDir: 'cypress/reports/mocha', 44 | quite: true, 45 | overwrite: false, 46 | html: false, 47 | json: true, 48 | }, 49 | reportportalAgentJsCypressReporterOptions: { 50 | endpoint: 'http://your-instance.com:8080/api/v1', 51 | apiKey: 'reportportalApiKey', 52 | launch: 'LAUNCH_NAME', 53 | project: 'PROJECT_NAME', 54 | description: 'LAUNCH_DESCRIPTION', 55 | }, 56 | }, 57 | e2e: { 58 | setupNodeEvents(on, config) { 59 | return registerReportPortalPlugin(on, config) 60 | }, 61 | }, 62 | }); 63 | ``` 64 | 65 | ## Run tests 66 | 67 | To run the tests, use the following command: 68 | 69 | ```cmd 70 | npm test 71 | ``` 72 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('cypress'); 2 | const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 3 | 4 | module.exports = defineConfig({ 5 | reporter: '@reportportal/agent-js-cypress', 6 | reporterOptions: { 7 | endpoint: 'http://your-instance.com:8080/api/v1', 8 | apiKey: 'reportportalApiKey', 9 | launch: 'LAUNCH_NAME', 10 | project: 'PROJECT_NAME', 11 | description: 'LAUNCH_DESCRIPTION', 12 | reportHooks: false, 13 | autoMerge: true, 14 | attributes: [ 15 | { 16 | key: 'attributeKey', 17 | value: 'attrbiuteValue', 18 | }, 19 | { 20 | value: 'secondAttrbiuteValue', 21 | }, 22 | ], 23 | restClientConfig: { 24 | timeout: 0, 25 | }, 26 | }, 27 | e2e: { 28 | setupNodeEvents(on, config) { 29 | return registerReportPortalPlugin(on, config) 30 | }, 31 | }, 32 | }); 33 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/basic/another-feature.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | context('Google page verification', () => { 18 | beforeEach('Visit Google page', () => { 19 | return cy.visit('https://www.google.com/'); 20 | }); 21 | 22 | it('Check that Google page contains `Google` word', () => { 23 | cy.info('Visit Google example page: https://www.google.com/'); 24 | cy.setTestDescription('This test case checks the *Google* word on the Google example page.'); 25 | cy.addTestAttributes([ 26 | { 27 | key: 'page', 28 | value: 'Google', 29 | }, 30 | ]); 31 | cy.wait(500); 32 | cy.info('Check if the `Google` word presented on the page #1'); 33 | cy.contains('Google'); 34 | cy.info('Check if the `Google` word presented on the page #2'); 35 | cy.wait(1000); 36 | cy.contains('Google'); 37 | cy.info('Some checks performed!'); 38 | }); 39 | 40 | it('Check that Google page contains `Google123` word', () => { 41 | cy.info('Visit Google example page: https://www.google.com/'); 42 | cy.info('Add attributes to the test using `addTestAttributes` command'); 43 | cy.setTestDescription('This test case checks the `Google123` word on the Google example page, but it fails.'); 44 | cy.wait(1000); 45 | cy.info('Add attributes to the test using `addTestAttributes` command'); 46 | cy.addTestAttributes([ 47 | { 48 | key: 'check', 49 | value: 'should-fail', 50 | }, 51 | ]); 52 | cy.warn('This test checks `Google123` word!'); 53 | cy.wait(1000); 54 | cy.info('Check if the `Google123` word presented on the page'); 55 | cy.contains('Google123'); 56 | }); 57 | 58 | it('Check that Google page contains `Abrakadabra` word', () => { 59 | cy.setTestDescription('This test case checks the `Abrakadabra` word on the Google example page, but it fails.'); 60 | cy.info('Visit Google example page: https://www.google.com/'); 61 | cy.wait(500); 62 | cy.info('Add attributes to the test using `addTestAttributes` command'); 63 | cy.addTestAttributes([ 64 | { 65 | key: 'check', 66 | value: 'should-fail', 67 | }, 68 | ]); 69 | 70 | cy.warn('This test fails!'); 71 | cy.wait(1000); 72 | cy.info('Check if the `Abrakadabra` word presented on the page'); 73 | cy.contains('Abrakadabra'); 74 | }); 75 | }); 76 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/basic/feature.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | describe('Cypress example page verification', () => { 18 | beforeEach('Visit Cypress website', () => { 19 | return cy.visit('https://example.cypress.io'); 20 | }); 21 | 22 | describe('URL checks', () => { 23 | it('Check the URL on the Cypress website', () => { 24 | cy.info('Add **ReportPortal** related *metadata* before starting main test actions.'); 25 | cy.addTestAttributes([ 26 | { 27 | key: 'feature', 28 | value: 'clickable-area', 29 | }, 30 | { 31 | value: 'demo', 32 | }, 33 | ]); 34 | cy.setTestDescription('This test simply checks that *URL* contains `/commands/actions` on the **Cypress** website'); 35 | 36 | cy.fixture('test.png').then((file) => { 37 | cy.info('info log with attachment', { 38 | name: 'test.png', 39 | type: 'image/png', 40 | content: file, 41 | }); 42 | }); 43 | 44 | cy.contains('type').click(); 45 | cy.url().should('include', '/commands/actions'); 46 | }); 47 | }); 48 | 49 | describe('Actions page', () => { 50 | it('Type fake email on actions page', () => { 51 | cy.log('Add **ReportPortal** related *metadata* before starting main test actions.'); 52 | cy.addTestAttributes([ 53 | { 54 | key: 'feature', 55 | value: 'action-email', 56 | }, 57 | { 58 | value: 'demo', 59 | }, 60 | ]); 61 | cy.setTestDescription('This test simply checks some `elements` on the **Cypress** website'); 62 | 63 | cy.contains('type') 64 | .click(); 65 | cy.get('.action-email') 66 | .type('fake@email.com'); 67 | cy.screenshot('type-fake-email'); 68 | cy.get('.action-email') 69 | .should('have.value', 'fake@email.com'); 70 | }); 71 | 72 | it('Check description on actions page', () => { 73 | cy.log('Add **ReportPortal** related *metadata* before starting main test actions.'); 74 | cy.addTestAttributes([ 75 | { 76 | key: 'feature', 77 | value: 'check-description', 78 | }, 79 | { 80 | value: 'demo', 81 | }, 82 | ]); 83 | cy.setTestDescription('This test simply checks actions page *description* on the **Cypress** website'); 84 | 85 | cy.contains('type') 86 | .click(); 87 | cy.screenshot('check-description'); 88 | cy.wait(1000); 89 | 90 | cy.contains('Examples of actions being performed on DOM elements in Cypress'); 91 | }); 92 | }); 93 | }) 94 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/rp-features/logTest.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | context('Logs for tests and launch', () => { 18 | beforeEach('Visit Google page', () => { 19 | return cy.visit('https://www.google.com/'); 20 | }); 21 | it('should send logs to the launch', () => { 22 | cy.setTestDescription('This test sends logs with different levels to the launch'); 23 | cy.addTestAttributes([ 24 | { 25 | key: 'feature', 26 | value: 'launchLogs', 27 | }, 28 | ]); 29 | cy.launchTrace('trace launch log'); 30 | cy.launchDebug('debug launch log'); 31 | cy.launchInfo('info launch log'); 32 | cy.launchWarn('warn launch log'); 33 | cy.launchError('error launch log'); 34 | cy.launchFatal('fatal launch log'); 35 | 36 | cy.contains('Google'); 37 | }); 38 | 39 | it('should send logs to the test item', () => { 40 | cy.setTestDescription('This test sends logs with different levels to the test item'); 41 | cy.addTestAttributes([ 42 | { 43 | key: 'feature', 44 | value: 'testItemLogs', 45 | }, 46 | ]); 47 | cy.log('Cypress log message'); 48 | cy.trace('trace message'); 49 | cy.debug('debug message'); 50 | cy.info('info message'); 51 | cy.warn('warning message'); 52 | cy.error('error message'); 53 | cy.fatal('fatal message'); 54 | 55 | cy.fixture('test.png').then((file) => { 56 | cy.info('info log with attachment', { 57 | name: 'test.png', 58 | type: 'image/png', 59 | content: file, 60 | }); 61 | }); 62 | 63 | cy.contains('Google'); 64 | }); 65 | 66 | it('should contain the description', () => { 67 | cy.setTestDescription('Test description'); 68 | cy.setTestDescription('This description overwrites previous'); 69 | cy.addTestAttributes([ 70 | { 71 | key: 'feature', 72 | value: 'overwriteDescription', 73 | }, 74 | ]); 75 | 76 | cy.contains('Google'); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/rp-features/pageVerification.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | context('Google example page verification', () => { 18 | beforeEach('Visit Google page', () => { 19 | return cy.visit('https://www.google.com/'); 20 | }); 21 | 22 | it('Check that Google page contains `Google` word', () => { 23 | cy.info('Сypress example page: https://www.google.com/'); 24 | cy.setTestDescription('This test case checks the *Google* word on the Google example page.'); 25 | cy.addTestAttributes([ 26 | { 27 | key: 'page', 28 | value: 'Google', 29 | }, 30 | ]); 31 | cy.wait(500); 32 | cy.info('Check if the `Google` word presented on the page #1'); 33 | cy.contains('Google'); 34 | cy.info('Check if the `Google` word presented on the page #2'); 35 | cy.wait(500); 36 | cy.contains('Google'); 37 | cy.info('Some checks performed!'); 38 | }); 39 | 40 | it('Check that Google page contains `Google123` word', () => { 41 | cy.info('Сypress example page: https://www.google.com/'); 42 | cy.info('Add attributes to the test using `addTestAttributes` command'); 43 | cy.setTestDescription('This test case checks the `Google123` word on the Google example page, but it fails.'); 44 | cy.wait(500); 45 | cy.info('Add attributes to the test using `addTestAttributes` command'); 46 | cy.addTestAttributes([ 47 | { 48 | key: 'check', 49 | value: 'shouldFail', 50 | }, 51 | ]); 52 | cy.warn('This test checks `Google123` word!'); 53 | cy.wait(500); 54 | cy.info('Check if the `Google123` word presented on the page'); 55 | cy.contains('Google123'); 56 | }); 57 | 58 | it('Check that Google page contains `Abrakadabra` word', () => { 59 | cy.setTestDescription('This test case checks the `Abrakadabra` word on the Google example page, but it fails.'); 60 | cy.info('Visit Google example page: https://www.google.com/'); 61 | cy.wait(500); 62 | cy.info('Add attributes to the test using `addTestAttributes` command'); 63 | cy.addTestAttributes([ 64 | { 65 | key: 'check', 66 | value: 'shouldFail', 67 | }, 68 | ]); 69 | 70 | cy.warn('This test fails!'); 71 | cy.wait(500); 72 | cy.info('Check if the `Abrakadabra` word presented on the page'); 73 | cy.contains('Google123'); 74 | }); 75 | }); 76 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/rp-features/statusesTest.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | context('populated statuses for launch/test', () => { 18 | beforeEach('Visit Google page', () => { 19 | return cy.visit('https://www.google.com/'); 20 | }); 21 | it('should have status failed', () => { 22 | cy.setTestDescription('This test should have manually provided `Failed` status'); 23 | cy.addTestAttributes([ 24 | { 25 | key: 'feature', 26 | value: 'manualStatusFailed', 27 | }, 28 | ]); 29 | cy.setStatusFailed(); 30 | cy.contains('Google'); 31 | }); 32 | 33 | it('should have status passed', () => { 34 | cy.setTestDescription('This test should have manually provided `Passed` status'); 35 | cy.addTestAttributes([ 36 | { 37 | key: 'feature', 38 | value: 'manualStatusPassed', 39 | }, 40 | ]); 41 | cy.setStatusPassed(); 42 | cy.contains('gfkjdgkjdfgl'); 43 | }); 44 | 45 | it('should have status skipped', () => { 46 | cy.setTestDescription('This test should have manually provided `Skipped` status'); 47 | cy.addTestAttributes([ 48 | { 49 | key: 'feature', 50 | value: 'manualStatusSkipped', 51 | }, 52 | ]); 53 | cy.setStatusSkipped(); 54 | cy.contains('Google'); 55 | }); 56 | 57 | it('should have status stopped', () => { 58 | cy.setTestDescription('This test should have manually provided `Stopped` status'); 59 | cy.addTestAttributes([ 60 | { 61 | key: 'feature', 62 | value: 'manualStatusStopped', 63 | }, 64 | ]); 65 | cy.setStatusStopped(); 66 | cy.contains('Google'); 67 | }); 68 | 69 | it('should have status interrupted', () => { 70 | cy.setTestDescription('This test should have manually provided `Interrupted` status'); 71 | cy.addTestAttributes([ 72 | { 73 | key: 'feature', 74 | value: 'manualStatusInterrupted', 75 | }, 76 | ]); 77 | cy.setStatusInterrupted(); 78 | cy.contains('Google'); 79 | }); 80 | 81 | it('should have status cancelled', () => { 82 | cy.setTestDescription('This test should have manually provided `Cancelled` status'); 83 | cy.addTestAttributes([ 84 | { 85 | key: 'feature', 86 | value: 'manualStatusCancelled', 87 | }, 88 | ]); 89 | cy.setStatusCancelled(); 90 | cy.contains('Google'); 91 | }); 92 | }); 93 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/e2e/rp-features/testCaseIdTest.cy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | context('Awesome suite', () => { 18 | beforeEach('Visit Google page', () => { 19 | return cy.visit('https://www.google.com/'); 20 | }); 21 | it('should check the `Google123` word', () => { 22 | cy.info('Visit Google example page: https://www.google.com/'); 23 | cy.setTestDescription('This test case contains explicit test case id'); 24 | 25 | cy.contains('Google'); 26 | cy.info('Use timeout 1000ms'); 27 | cy.wait(1000); 28 | cy.addTestAttributes([ 29 | { 30 | key: 'feature', 31 | value: 'ExplicitTestCaseId', 32 | }, 33 | ]); 34 | cy.info('Use timeout 1000ms'); 35 | cy.wait(1000); 36 | cy.info('Set testCaseId to the test using `setTestCaseId` command'); 37 | cy.setTestCaseId('testCaseIDForTheTest'); 38 | cy.info('Use timeout 1000ms'); 39 | cy.wait(1000); 40 | cy.contains('Google123'); 41 | }); 42 | 43 | it('Gets, types and asserts', () => { 44 | cy.info('Visit Google example page: https://www.google.com/'); 45 | cy.visit('https://www.google.com/'); 46 | cy.info('Add attributes to the test using `addTestAttributes` command'); 47 | cy.setTestDescription('This test case contains automatically generated test case id'); 48 | cy.addTestAttributes([ 49 | { 50 | key: 'feature', 51 | value: 'AutoGeneratedTestCaseId', 52 | }, 53 | ]); 54 | 55 | cy.wait(500); 56 | cy.info('Use timeout 500ms'); 57 | 58 | cy.info('Get an input, type into it and verify that the value has been updated'); 59 | cy.get('input[type=text]') 60 | .type('fake@email.com') 61 | .should('have.value', 'fake@email.com'); 62 | cy.info('Some checks performed!'); 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/fixtures/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-cypress/basic/cypress/fixtures/test.png -------------------------------------------------------------------------------- /example-cypress/basic/cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 18 | 19 | module.exports = (on, config) => registerReportPortalPlugin(on, config); 20 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | require('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands'); 18 | -------------------------------------------------------------------------------- /example-cypress/basic/cypress/support/e2e.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import './commands'; 18 | -------------------------------------------------------------------------------- /example-cypress/basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "cypress run --headless" 4 | }, 5 | "license": "Apache-2.0", 6 | "devDependencies": { 7 | "@reportportal/agent-js-cypress": "^5.3.2", 8 | "cypress": "^13.13.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-cypress](https://www.npmjs.com/package/@reportportal/agent-js-cypress) 2 | 3 | The examples are written with Cypress >=9 compatibility in mind, but the agent also works with Cypress <9. 4 | 5 | ## Installation: 6 | 7 | Install the packages: 8 | 9 | ```cmd 10 | npm install 11 | ``` 12 | 13 | ## Configuration: 14 | 15 | Specify the options in the cypress.config.js: 16 | 17 | ```javascript 18 | module.exports = defineConfig({ 19 | reporter: '@reportportal/agent-js-cypress', 20 | reporterOptions: { 21 | endpoint: 'http://your-instance.com:8080/api/v1', 22 | apiKey: 'reportportalApiKey', 23 | launch: 'LAUNCH_NAME', 24 | project: 'PROJECT_NAME', 25 | description: 'LAUNCH_DESCRIPTION', 26 | }, 27 | e2e: { 28 | async setupNodeEvents(on, config) { 29 | await preprocessor.addCucumberPreprocessorPlugin(on, config); 30 | on( 31 | 'file:preprocessor', 32 | createBundler({ 33 | plugins: [createEsbuildPlugin(config)], 34 | }), 35 | ); 36 | registerReportPortalPlugin(on, config); 37 | 38 | return config; 39 | }, 40 | specPattern: 'cypress/e2e/**/*.feature', 41 | supportFile: 'cypress/support/e2e.js', 42 | }, 43 | }); 44 | ``` 45 | 46 | ## Run tests 47 | 48 | To run the tests, use the following command: 49 | 50 | ```cmd 51 | npm test 52 | ``` 53 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('cypress'); 2 | const createBundler = require('@bahmutov/cypress-esbuild-preprocessor'); 3 | const preprocessor = require('@badeball/cypress-cucumber-preprocessor'); 4 | const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild').default; 5 | const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 6 | 7 | module.exports = defineConfig({ 8 | reporter: '@reportportal/agent-js-cypress', 9 | reporterOptions: { 10 | endpoint: 'http://your-instance.com:8080/api/v1', 11 | apiKey: 'reportportalApiKey', 12 | launch: 'LAUNCH_NAME', 13 | project: 'PROJECT_NAME', 14 | description: 'LAUNCH_DESCRIPTION', 15 | autoMerge: true, 16 | attributes: [ 17 | { 18 | key: 'attributeKey', 19 | value: 'attrbiuteValue', 20 | }, 21 | { 22 | value: 'secondAttrbiuteValue', 23 | }, 24 | ], 25 | restClientConfig: { 26 | timeout: 0, 27 | }, 28 | }, 29 | e2e: { 30 | async setupNodeEvents(on, config) { 31 | await preprocessor.addCucumberPreprocessorPlugin(on, config); 32 | on( 33 | 'file:preprocessor', 34 | createBundler({ 35 | plugins: [createEsbuildPlugin(config)], 36 | }), 37 | ); 38 | registerReportPortalPlugin(on, config); 39 | 40 | return config; 41 | }, 42 | specPattern: 'cypress/e2e/**/*.feature', 43 | supportFile: 'cypress/support/e2e.js', 44 | }, 45 | }); 46 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/google/google.feature: -------------------------------------------------------------------------------- 1 | Feature: The Google 2 | 3 | I want to open Google page 4 | 5 | Scenario: Opening a Google network page 6 | Given I open Google page 7 | Then I see "Google" in the title 8 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/google/step_definitions/openingGoogle.js: -------------------------------------------------------------------------------- 1 | import { Given, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | const url = 'https://google.com'; 4 | 5 | Given(`I open Google page`, () => { 6 | cy.setTestDescription('This test case checks the *Google* word on the Google example page.'); 7 | cy.addTestAttributes([ 8 | { 9 | key: 'page', 10 | value: 'Google', 11 | }, 12 | ]); 13 | cy.visit(url); 14 | }); 15 | 16 | Then(`I see {string} in the title`, (title) => { 17 | cy.title().should('include', title); 18 | }); 19 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/simple.feature: -------------------------------------------------------------------------------- 1 | Feature: Being a plugin 2 | 3 | As a cucumber cypress plugin 4 | I want to allow people to use gherkin syntax in cypress tests 5 | So they can create beautiful executable specification for their projects 6 | 7 | Scenario: Basic example 8 | Given a feature and a matching step definition file 9 | When I run cypress tests 10 | Then they run properly 11 | 12 | Scenario: DataTable 13 | When I add all following numbers: 14 | | number | another number | 15 | | 1 | 2 | 16 | | 3 | 4 | 17 | Then I verify the datatable result is equal to 10 18 | 19 | Scenario: DocString 20 | When I use DocString for code like this: 21 | """ 22 | expect(true).to.equal(true) 23 | variableToVerify = "hello world" 24 | """ 25 | Then I ran it and verify that it executes it 26 | 27 | Scenario Outline: Using Scenario Outlines 28 | When I add and 29 | Then I verify that the result is equal the 30 | 31 | Examples: 32 | | provided number | another provided number | provided | 33 | | 1 | 2 | 3 | 34 | | 100 | 200 | 300 | 35 | 36 | Scenario Outline: Search the details of a phone 37 | Given a list of phones on phones store 38 | When I search the phone in search input 39 | Then appears on the screen 40 | 41 | Examples: 42 | | brand | model | 43 | | iPhone | 6s | 44 | | Samsung | S8 | 45 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/step_definitions/basic.js: -------------------------------------------------------------------------------- 1 | import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | Given('a feature and a matching step definition file', () => { 4 | expect(true).to.equal(true); 5 | }); 6 | 7 | When('I run cypress tests', () => { 8 | cy.info('test log'); 9 | expect(true).to.equal(true); 10 | }); 11 | 12 | Then('they run properly', () => { 13 | expect(true).to.equal(true); 14 | }); 15 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/step_definitions/dataTable.js: -------------------------------------------------------------------------------- 1 | import { When, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | let sum = 0; 4 | 5 | When('I add all following numbers:', (dataTable) => { 6 | sum = dataTable.rawTable 7 | .slice(1) 8 | .reduce( 9 | (rowA, rowB) => 10 | rowA.reduce((a, b) => parseInt(a, 10) + parseInt(b, 10)) + 11 | rowB.reduce((a, b) => parseInt(a, 10) + parseInt(b, 10)), 12 | ); 13 | }); 14 | 15 | Then('I verify the datatable result is equal to {int}', (result) => { 16 | expect(sum).to.equal(result); 17 | }); 18 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/step_definitions/docString.js: -------------------------------------------------------------------------------- 1 | import { When, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | let code = ''; 4 | let variableToVerify = ''; 5 | 6 | When('I use DocString for code like this:', (dataString) => { 7 | code = dataString; 8 | }); 9 | 10 | Then('I ran it and verify that it executes it', () => { 11 | eval(code); 12 | expect(variableToVerify).to.equal('hello world'); 13 | }); 14 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/step_definitions/scenario_outline_integer.js: -------------------------------------------------------------------------------- 1 | import { When, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | let sum = 0; 4 | 5 | When('I add {int} and {int}', (a, b) => { 6 | sum = a + b; 7 | }); 8 | 9 | Then('I verify that the result is equal the {int}', (result) => { 10 | expect(sum).to.equal(result); 11 | }); 12 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/e2e/simpleFeature/step_definitions/scenario_outline_word.js: -------------------------------------------------------------------------------- 1 | import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | Given('a list of phones on phones store', () => { 4 | expect(true).to.equal(true); 5 | }); 6 | 7 | When('I search the phone {word} in search input', () => { 8 | expect(true).to.equal(true); 9 | }); 10 | 11 | Then('{word} {word} appears on the screen', (brand, model) => { 12 | cy.info(`model=${model} brand=${brand}`); 13 | expect(typeof model).to.equal('string'); 14 | expect(typeof brand).to.equal('string'); 15 | }); 16 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | require('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands'); 18 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/support/e2e.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import './commands'; 18 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/cypress/support/step_definitions.js: -------------------------------------------------------------------------------- 1 | import { BeforeStep, AfterStep } from '@badeball/cypress-cucumber-preprocessor'; 2 | 3 | BeforeStep((step) => { 4 | cy.cucumberStepStart(step); 5 | }); 6 | 7 | AfterStep((step) => { 8 | cy.cucumberStepEnd(step); 9 | }); 10 | -------------------------------------------------------------------------------- /example-cypress/cucumber-preprocessor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "cypress run" 4 | }, 5 | "license": "Apache-2.0", 6 | "devDependencies": { 7 | "@badeball/cypress-cucumber-preprocessor": "^20.0.3", 8 | "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0", 9 | "@reportportal/agent-js-cypress": "^5.3.0", 10 | "cypress": "^13.7.2" 11 | }, 12 | "cypress-cucumber-preprocessor": { 13 | "nonGlobalStepDefinitions": true, 14 | "stepDefinitions": [ 15 | "cypress/support/step_definitions.js", 16 | "cypress/e2e/**/step_definitions/*.js" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example-jasmine/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-jasmine](https://www.npmjs.com/package/@reportportal/agent-js-jasmine) 2 | 3 | ## Run test example: 4 | 5 | To run the example you must have java installed. 6 | 7 | Inside `reportportalConf.js` you need to insert data about your instance of the ReportPortal. 8 | 9 | To run the tests, type the following command in the console: 10 | ```cmd 11 | npm install 12 | npm run webdriver-update 13 | npm run webdriver-start 14 | npm run protractor OR npm run protractor-multiTread 15 | ``` 16 | -------------------------------------------------------------------------------- /example-jasmine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Apache-2.0", 3 | "scripts": { 4 | "protractor": "protractor protractor/simpleConfig.js", 5 | "protractor-multiTread": "node protractor-multiTread/protractorLaunchFile.js", 6 | "webdriver-update": "webdriver-manager update", 7 | "webdriver-start": "webdriver-manager start" 8 | }, 9 | "devDependencies": { 10 | "protractor": "^5.4.4", 11 | "protractor-flake": "^2.7.0", 12 | "@reportportal/agent-js-jasmine": "^5.0.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example-jasmine/protractor-multiTread/multiThreadConf.js: -------------------------------------------------------------------------------- 1 | const ReportportalAgent = require('@reportportal/agent-js-jasmine'); 2 | const reportportalConfig = require('../reportportalConf'); 3 | 4 | exports.config = { 5 | multiCapabilities: [ 6 | { 7 | name: 'normal', 8 | browserName: 'chrome', 9 | maxInstances: 2, 10 | shardTestFiles: true, 11 | chromeOptions: { 12 | args: ['--window-size=1024,768', '--disable-infobars'] 13 | } 14 | } 15 | ], 16 | specs: ['../tests/*.spec.js'], 17 | onPrepare() { 18 | const config = Object.assign({ 19 | id: browser.params.id 20 | }, reportportalConfig); 21 | const agent = new ReportportalAgent(config); 22 | /*Its a hack. There is an issue since 2015. That Jasmine doesn't wait for report's async functions. 23 | links to the issues https://github.com/jasmine/jasmine/issues/842 24 | https://github.com/angular/protractor/issues/1938 25 | So it needed to wait until requests would be sent to the Report Portal. 26 | */ 27 | afterAll((done) => agent.getPromiseFinishAllItems(agent.tempLaunchId).then(()=> done())); 28 | jasmine.getEnv().addReporter(agent.getJasmineReporter()); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /example-jasmine/protractor-multiTread/protractorLaunchFile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* global process */ 3 | /* Any type of launchers could be used, this is just for example as favorite one*/ 4 | const protractorFlake = require('protractor-flake'); 5 | const AgentJasmine = require('@reportportal/agent-js-jasmine'); 6 | const reportportalConfig = require('../reportportalConf'); 7 | const agent = new AgentJasmine(reportportalConfig); 8 | 9 | agent.getLaunchStartPromise().then((launchData) =>{ 10 | protractorFlake({ 11 | maxAttempts: 1, 12 | protractorArgs: [ 13 | './protractor-multiTread/multiThreadConf.js', 14 | '--params.id', 15 | launchData.id 16 | ] 17 | }, (status, output) => { 18 | // Close the report after all tests have finished 19 | agent.getExitPromise().then(() =>{ 20 | process.exit(status); 21 | }); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /example-jasmine/protractor/simpleConfig.js: -------------------------------------------------------------------------------- 1 | const ReportportalAgent = require('@reportportal/agent-js-jasmine'); 2 | const reportportalConfig = require('../reportportalConf'); 3 | let agent; 4 | 5 | exports.config = { 6 | specs: ['../tests/*.spec.js'], 7 | onPrepare(){ 8 | agent = new ReportportalAgent(reportportalConfig); 9 | 10 | jasmine.getEnv().addReporter(agent.getJasmineReporter()); 11 | }, 12 | afterLaunch(number) { 13 | return agent.getExitPromise(); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /example-jasmine/reportportalConf.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | endpoint: 'http://your-instance.com:8080/api/v1', 3 | apiKey: '', 4 | launch: 'Your launch name', 5 | project: 'Your reportportal project name', 6 | description: 'PROJECT_DESCRIPTION', 7 | attachPicturesToLogs: false, 8 | attributes: [ 9 | { 10 | key: 'attributeKey', 11 | value: 'attributeValue', 12 | }, 13 | { 14 | value: 'secondAttrbuteValue', 15 | }, 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } 4 | -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | 6 | -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-jasmine/tests/attachments/test.jpg -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } 4 | -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-jasmine/tests/attachments/test.mp4 -------------------------------------------------------------------------------- /example-jasmine/tests/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-jasmine/tests/attachments/test.png -------------------------------------------------------------------------------- /example-jasmine/tests/attributesTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const PublicReportingAPI = require('@reportportal/agent-js-jasmine/lib/publicReportingAPI'); 18 | 19 | describe('attributes for suite/test', function () { 20 | PublicReportingAPI.setDescription( 21 | 'This suite should have the correct suite attributes', 22 | 'attributes for suite/test', 23 | ); 24 | PublicReportingAPI.addAttributes( 25 | [ 26 | { 27 | key: 'suiteKeyOne', 28 | value: 'suiteValueOne', 29 | }, 30 | ], 31 | 'attributes for suite/test', 32 | ); 33 | PublicReportingAPI.addAttributes( 34 | [ 35 | { 36 | key: 'suiteKeyTwo', 37 | value: 'suiteValueTwo', 38 | }, 39 | { 40 | value: 'suiteValueThree', 41 | }, 42 | ], 43 | 'attributes for suite/test', 44 | ); 45 | it('should have the correct test attributes', function () { 46 | PublicReportingAPI.setDescription('This test should have the correct test attributes'); 47 | PublicReportingAPI.addAttributes([ 48 | { 49 | key: 'testKey', 50 | value: 'testValue', 51 | }, 52 | { 53 | value: 'testValueTwo', 54 | }, 55 | ]); 56 | expect(true).toBe(true); 57 | }); 58 | }); 59 | -------------------------------------------------------------------------------- /example-jasmine/tests/descriptionsTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const PublicReportingAPI = require('@reportportal/agent-js-jasmine/lib/publicReportingAPI'); 18 | 19 | describe('description for suite/test', function () { 20 | PublicReportingAPI.setDescription('The description for the suite', 'description for suite/test'); 21 | 22 | it('should have the correct description', function () { 23 | PublicReportingAPI.setDescription('The description for the test'); 24 | expect(true).toBe(true); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /example-jasmine/tests/testCaseIdTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const PublicReportingAPI = require('@reportportal/agent-js-jasmine/lib/publicReportingAPI'); 18 | 19 | describe('testCaseId for suite/test', function () { 20 | PublicReportingAPI.setTestCaseId('TestCaseIdForTheSuite', 'testCaseId for suite/test'); 21 | 22 | it('should have the explicit testCaseId', function () { 23 | PublicReportingAPI.setDescription('This test case contains explicit test case id'); 24 | PublicReportingAPI.addAttributes([ 25 | { 26 | key: 'feature', 27 | value: 'ExplicitTestCaseId', 28 | }, 29 | ]); 30 | PublicReportingAPI.setTestCaseId('TestCaseIdForTheTest'); 31 | expect(true).toBe(true); 32 | }); 33 | it('should have the autogenerate testCaseId', function () { 34 | PublicReportingAPI.setDescription( 35 | 'This test case contains automatically generated testcase id', 36 | ); 37 | PublicReportingAPI.addAttributes([ 38 | { 39 | key: 'feature', 40 | value: 'AutoGeneratedTestCaseId', 41 | }, 42 | ]); 43 | expect(true).toBe(true); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /example-jest/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-jest](https://www.npmjs.com/package/@reportportal/agent-js-jest) 2 | 3 | ## Run test example: 4 | Inside of jest.config.js you need to insert data about your instance of the ReportPortal. 5 | 6 | To run the tests, type the following commands in the console: 7 | 8 | ```cmd 9 | npm install 10 | npm run test 11 | ``` 12 | -------------------------------------------------------------------------------- /example-jest/__tests__/attachments.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const fs = require('fs'); 18 | const path = require('path'); 19 | 20 | describe('Tests with attachments', () => { 21 | test('should be passed with attachment', () => { 22 | const fileName = 'test.png'; 23 | const fileContent = fs.readFileSync(path.resolve(__dirname, './attachments', fileName)); 24 | 25 | ReportingApi.attachment({ 26 | name: fileName, 27 | type: 'image/png', 28 | content: fileContent.toString('base64'), 29 | }); 30 | 31 | expect(true).toBe(true); 32 | }); 33 | 34 | test('should be failed with attachment', () => { 35 | const fileName = 'test.png'; 36 | const fileContent = fs.readFileSync(path.resolve(__dirname, './attachments', fileName)); 37 | 38 | ReportingApi.attachment({ 39 | name: fileName, 40 | type: 'image/png', 41 | content: fileContent.toString('base64'), 42 | }, 'Attachment description'); 43 | 44 | expect(true).toBe(false); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /example-jest/__tests__/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-jest/__tests__/attachments/test.png -------------------------------------------------------------------------------- /example-jest/__tests__/differentStatuses.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | describe('Tests with different statuses', () => { 18 | test('should be passed', () => { 19 | expect(true).toBe(true); 20 | }); 21 | 22 | test('should be failed', () => { 23 | expect(true).toEqual(false); 24 | }); 25 | 26 | test.skip('should be skipped', () => { 27 | expect(true).toEqual(true); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /example-jest/__tests__/parametrized.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const calculator = require('../src/calculator'); 18 | 19 | describe('Calculator', () => { 20 | it.each([ 21 | [[1, 41], 42], 22 | [[1, 2, 39], 42], 23 | [[1, 2, NaN], NaN], 24 | [[1, 2, Infinity], Infinity], 25 | ])('adds %p expecting %p', (numbers, result) => { 26 | expect(calculator('+', numbers)).toEqual(result); 27 | }); 28 | 29 | it.each([ 30 | [[43, 1], 42], 31 | [[44, 1, 1], 42], 32 | [[1, 2, NaN], NaN], 33 | [[1, 2, Infinity], -Infinity], 34 | ])('subtracts %p expecting %p', (numbers, result) => { 35 | expect(calculator('-', numbers)).toEqual(result); 36 | }); 37 | 38 | it.each([ 39 | [[21, 2], 42], 40 | [[3, 7, 2], 42], 41 | [[42, NaN], NaN], 42 | [[42, Infinity], Infinity], 43 | ])('multiplies %p expecting %p', (numbers, result) => { 44 | expect(calculator('*', numbers)).toEqual(result); 45 | }); 46 | 47 | it.each([ 48 | [[84, 2], 42], 49 | [[168, 2, 2], 42], 50 | [[42, 0], Infinity], 51 | [[42, NaN], NaN], 52 | ])('divides %p expecting %p', (numbers, result) => { 53 | expect(calculator('/', numbers)).toEqual(result); 54 | }); 55 | }); 56 | -------------------------------------------------------------------------------- /example-jest/__tests__/retries.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | describe('Tests with retries enabled', () => { 18 | jest.retryTimes(3); 19 | 20 | test('should be retried as failed', () => { 21 | expect(true).toEqual(false); 22 | }); 23 | 24 | test('should not be retried as passed', () => { 25 | expect(true).toEqual(true); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /example-jest/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testRunner: 'jest-circus/runner', 3 | testRegex: ['/__tests__/.*.spec.js?$'], 4 | reporters: [ 5 | 'default', 6 | [ 7 | '@reportportal/agent-js-jest', 8 | { 9 | apiKey: '', 10 | endpoint: 'https://your.reportportal.server/api/v1', 11 | launch: 'LAUNCH_NAME', 12 | project: 'PROJECT_NAME', 13 | description: 'YOUR_DESCRIPTION', 14 | debug: true, 15 | attributes: [ 16 | { 17 | 'key': 'test-framework', 18 | 'value': 'jest' 19 | }, 20 | { 21 | 'value': 'YourValue' 22 | }, 23 | ], 24 | restClientConfig:{ 25 | timeout: 0, 26 | } 27 | } 28 | ] 29 | ], 30 | }; 31 | -------------------------------------------------------------------------------- /example-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Apache-2.0", 3 | "scripts": { 4 | "test": "jest --config ./jest.config.js" 5 | }, 6 | "devDependencies": { 7 | "jest": "^29.7.0", 8 | "jest-cli": "^29.7.0", 9 | "jest-circus": "^29.7.0", 10 | "@reportportal/agent-js-jest": "^5.1.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example-jest/src/calculator.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | function calculator(operator, inputs) { 18 | 19 | if (inputs.length < 2) { 20 | throw new Error(`inputs should have length >= 2`); 21 | } 22 | 23 | switch (operator) { 24 | case '+': 25 | return inputs.reduce((prev, curr) => prev + curr); 26 | case '-': 27 | return inputs.reduce((prev, curr) => prev - curr); 28 | case '*': 29 | return inputs.reduce((prev, curr) => prev * curr); 30 | case '/': 31 | return inputs.reduce((prev, curr) => prev / curr); 32 | default: 33 | throw new Error(`Unknown operator ${operator}`); 34 | } 35 | } 36 | 37 | module.exports = calculator; 38 | -------------------------------------------------------------------------------- /example-mocha/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-mocha](https://www.npmjs.com/package/@reportportal/agent-js-mocha) 2 | 3 | ## Run test example: 4 | 5 | Install the packages: 6 | 7 | ```cmd 8 | npm install 9 | ``` 10 | 11 | Fill reporterOptions in Mocha: 12 | ```javascript 13 | const mochaMain = new Mocha({ 14 | reporter: '@reportportal/agent-js-mocha', 15 | reporterOptions: { 16 | endpoint: 'http://your-instance.com:8080/api/v2', 17 | apiKey: 'reportportalApiKey', 18 | launch: 'LAUNCH_NAME', 19 | project: 'PROJECT_NAME', 20 | description: 'LAUNCH_DESCRIPTION' 21 | }, 22 | timeout: 250000 23 | }); 24 | ``` 25 | 26 | To run the tests, use the following command: 27 | ```cmd 28 | npm test 29 | ``` 30 | -------------------------------------------------------------------------------- /example-mocha/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // create mocha instance 18 | const Mocha = require('mocha'); 19 | 20 | // TODO: Add example with mocharc file usage 21 | const mochaMain = new Mocha({ 22 | reporter: '@reportportal/agent-js-mocha', 23 | reporterOptions: { 24 | endpoint: 'http://your-instance.com:8080/api/v1', 25 | apiKey: '', 26 | launch: 'Your launch name', 27 | project: 'Your ReportPortal project name', 28 | description: 'PROJECT_DESCRIPTION', 29 | attributes: [ 30 | { 31 | key: 'attributeKey', 32 | value: 'attrbuteValue', 33 | }, 34 | { 35 | value: 'secondAttrbuteValue', 36 | }, 37 | ], 38 | }, 39 | timeout: 250000, 40 | }); 41 | 42 | // run tests 43 | try { 44 | mochaMain.files = [ 45 | 'spec/attributesTest.spec.js', 46 | 'spec/descriptionsTest.spec.js', 47 | 'spec/logTest.spec.js', 48 | 'spec/statusesTest.spec.js', 49 | 'spec/testCaseIdTest.spec.js', 50 | ]; 51 | mochaMain.run((failures) => process.on('exit', () => process.exit(failures))); // exit with non-zero exit code, otherwise fails will not fail mocha run 52 | } catch (err) { 53 | console.error(`Test suite doesn't exists or set. Error: ${err}`); 54 | } 55 | -------------------------------------------------------------------------------- /example-mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "node main.js" 4 | }, 5 | "license": "Apache-2.0", 6 | "devDependencies": { 7 | "@reportportal/agent-js-mocha": "^5.1.0", 8 | "mocha": "^10.7.0", 9 | "chai": "^4.3.7" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-mocha/spec/attachments/test.jpg -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-mocha/spec/attachments/test.mp4 -------------------------------------------------------------------------------- /example-mocha/spec/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-mocha/spec/attachments/test.png -------------------------------------------------------------------------------- /example-mocha/spec/attributesTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const PublicReportingAPI = require('@reportportal/agent-js-mocha/lib/publicReportingAPI'); 19 | 20 | describe('attributes for suite/test', function () { 21 | before(function () { 22 | PublicReportingAPI.setDescription('This suite should have the correct suite attributes'); 23 | PublicReportingAPI.addAttributes([ 24 | { 25 | key: 'suiteKeyOne', 26 | value: 'suiteValueOne', 27 | }, 28 | ]); 29 | PublicReportingAPI.addAttributes([ 30 | { 31 | key: 'suiteKeyTwo', 32 | value: 'suiteValueTwo', 33 | }, 34 | { 35 | value: 'suiteValueThree', 36 | }, 37 | ]); 38 | }); 39 | 40 | it('should have the correct test attributes', function () { 41 | PublicReportingAPI.setDescription('This test should have the correct test attributes'); 42 | PublicReportingAPI.addAttributes([ 43 | { 44 | key: 'testKey', 45 | value: 'testValue', 46 | }, 47 | { 48 | value: 'testValueTwo', 49 | }, 50 | ]); 51 | expect(true).to.be.equal(true); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /example-mocha/spec/descriptionsTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const PublicReportingAPI = require('@reportportal/agent-js-mocha/lib/publicReportingAPI'); 19 | 20 | describe('description for suite/test', function () { 21 | before(function () { 22 | PublicReportingAPI.setDescription('The description for the suite'); 23 | }); 24 | 25 | it('should have the correct description', function () { 26 | PublicReportingAPI.setDescription('The description for the test'); 27 | expect(true).to.be.equal(true); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /example-mocha/spec/testCaseIdTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const PublicReportingAPI = require('@reportportal/agent-js-mocha/lib/publicReportingAPI'); 19 | 20 | describe('testCaseId for suite/test', function () { 21 | before(function () { 22 | PublicReportingAPI.setTestCaseId('TestCaseIdForTheSuite'); 23 | }); 24 | 25 | it('should have the explicit testCaseId', function () { 26 | PublicReportingAPI.setDescription('This test case contains explicit test case id'); 27 | PublicReportingAPI.addAttributes([ 28 | { 29 | key: 'feature', 30 | value: 'ExplicitTestCaseId', 31 | }, 32 | ]); 33 | PublicReportingAPI.setTestCaseId('TestCaseIdForTheTest'); 34 | expect(true).to.be.equal(true); 35 | }); 36 | 37 | it('should have the autogenerate testCaseId', function () { 38 | PublicReportingAPI.setDescription( 39 | 'This test case contains automatically generated testcase id', 40 | ); 41 | PublicReportingAPI.addAttributes([ 42 | { 43 | key: 'feature', 44 | value: 'AutoGeneratedTestCaseId', 45 | }, 46 | ]); 47 | expect(true).to.be.equal(true); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | 3 | module.exports = { 4 | src_folders : ['./PFR-exampleChromeDriver/tests'], 5 | test_workers: true, 6 | 7 | test_settings: { 8 | default: { 9 | webdriver: { 10 | start_process: true, 11 | server_path: chromedriver.path, 12 | port: 4444, 13 | cli_args: ['--port=4444'] 14 | }, 15 | screenshots : { 16 | enabled: true, 17 | path: './screenshots', 18 | on_failure: true 19 | }, 20 | desiredCapabilities: { 21 | browserName: 'chrome', 22 | chromeOptions: { 23 | args: ['--headless'] 24 | }, 25 | acceptSslCerts: true 26 | } 27 | } 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/params.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | launch: 'NIGHTWATCH_EXAMPLE_CHROMEDRIVER', 3 | description: 'This launch contains nightwatch tests results run with chromedriver', 4 | attributes: [{ key: 'lib', value: 'chromedriver' }], 5 | parallelRun: true, 6 | }; 7 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/reporter.js: -------------------------------------------------------------------------------- 1 | const { PostFactumReporter } = require('@reportportal/agent-js-nightwatch'); 2 | const config = require('../rp'); 3 | const params = require('./params'); 4 | 5 | const agent = new PostFactumReporter({ ...config, ...params }); 6 | 7 | module.exports = { 8 | write: (results, options, done) => { 9 | return agent.startReporting(results, done); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/tests/suite1/home.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | 3 | module.exports = { 4 | before() { 5 | chromedriver.start(); 6 | }, 7 | 8 | after() { 9 | chromedriver.stop(); 10 | }, 11 | 12 | 'Demo test beta.demo.reportportal.io': function(browser) { 13 | browser 14 | .url('https://beta.demo.reportportal.io/') 15 | .pause(1000) 16 | .end(); 17 | }, 18 | 19 | 'Demo test ecosia.org': function(browser) { 20 | browser 21 | .url('https://www.ecosia.org/') 22 | .pause(1000) 23 | .end(); 24 | }, 25 | 26 | Finished(browser) { 27 | browser 28 | .perform(() => { 29 | console.log('[perform]: Finished Test:', browser.currentTest.name); 30 | }) 31 | .end(); 32 | }, 33 | }; 34 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/tests/suite1/search.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | 3 | module.exports = { 4 | '@disabled': false, 5 | 6 | before() { 7 | chromedriver.start(); 8 | }, 9 | 10 | after() { 11 | chromedriver.stop(); 12 | }, 13 | 14 | 'demo test google' : function (browser) { 15 | browser 16 | .url('https://google.com') 17 | .waitForElementPresent('body', 1000); 18 | }, 19 | 20 | 'part two' : function(browser) { 21 | browser 22 | .setValue('input[type=text]', ['nightwatch', browser.Keys.ENTER]) 23 | .pause(1000) 24 | .assert.urlContains('search?') 25 | .assert.urlContains('nightwatch') 26 | .end(); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/tests/suite2/google.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | 3 | module.exports = { 4 | 5 | before() { 6 | chromedriver.start(); 7 | }, 8 | 9 | after() { 10 | chromedriver.stop(); 11 | }, 12 | 13 | 'Demo test Google' : function (browser) { 14 | browser 15 | .url('http://google.com') 16 | .pause(1000) 17 | .waitForElementVisible('body', 1000) 18 | .assert.urlContains('blablabla'); 19 | 20 | browser.end(); 21 | }, 22 | 23 | 'Demo test Loogle' : function (browser) { 24 | browser 25 | .url('http://google.com') 26 | .pause(1000) 27 | .waitForElementVisible('body', 1000) 28 | .assert.urlContains('blablabla'); 29 | 30 | browser.end(); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleChromeDriver/tests/suite2/others.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | 3 | module.exports = { 4 | before() { 5 | chromedriver.start(); 6 | }, 7 | 8 | after() { 9 | chromedriver.stop(); 10 | }, 11 | 12 | 'NightwatchJS.org': function(browser) { 13 | browser 14 | .url('http://nightwatchjs.org') 15 | .waitForElementVisible('body', 1500) 16 | .pause(1000) 17 | .end(); 18 | }, 19 | 20 | Finished(browser) { 21 | browser 22 | .perform(() => { 23 | console.log('[perform]: Finished Test:', browser.currentTest.name); 24 | }) 25 | .end(); 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/nightwatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_folders" : ["./PFR-exampleUnitTests/tests"], 3 | "custom_commands_path" : "", 4 | "page_objects_path" : "", 5 | "custom_assertions_path" : "", 6 | "globals_path" : "", 7 | "live_output" : false, 8 | "parallel_process_delay" : 10, 9 | "disable_colors": false, 10 | "test_workers" : false, 11 | "unit_tests_mode": true, 12 | 13 | "selenium" : { 14 | "start_session" : false, 15 | "start_process" : false 16 | }, 17 | 18 | "test_settings" : { 19 | "default" : { 20 | "disable_colors": false, 21 | "screenshots" : { 22 | "enabled" : true, 23 | "path" : "screenshots", 24 | "on_failure" : true 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/params.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | launch: 'NIGHTWATCH_EXAMPLE_CHAI', 3 | description: 'This launch contains nightwatch tests results asserted by chai', 4 | attributes: [{ key: 'lib', value: 'chai' }], 5 | }; 6 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/reporter.js: -------------------------------------------------------------------------------- 1 | const { PostFactumReporter } = require('@reportportal/agent-js-nightwatch'); 2 | const config = require('../rp'); 3 | const params = require('./params'); 4 | 5 | const agent = new PostFactumReporter({ ...config, ...params }); 6 | 7 | module.exports = { 8 | write: (results, options, done) => { 9 | return agent.startReporting(results, done); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/tests/suite1/test1.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | module.exports = { 4 | 5 | beforeTest(done) { 6 | expectEquals('bar'); 7 | done(); 8 | }, 9 | 10 | 'example test': function() { 11 | expectEquals('bar'); 12 | }, 13 | }; 14 | 15 | const expectEquals = (name) => { 16 | expect(name).to.equal('bar'); 17 | }; 18 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/tests/suite1/test2.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | module.exports = { 4 | 'test 2_1': function() { 5 | expect(false).to.be.ok; 6 | }, 7 | 'test 2_2': function() { 8 | expect(true).to.be.ok; 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /example-nightwatch/PFR-exampleUnitTests/tests/suite2/test1.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | module.exports = { 4 | 'test': { 5 | testSmth() { 6 | expect(false).to.be.ok; 7 | }, 8 | testSmth2() { 9 | expect(true).to.be.ok; 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /example-nightwatch/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-nightwatch](https://www.npmjs.com/package/@reportportal/agent-js-nightwatch) 2 | 3 | ## Preparation: 4 | Inside of rp.json you need to insert data about your instance of the Report Portal. 5 | 6 | Do not forget to install all the necessary dependencies: 7 | ```cmd 8 | npm install 9 | ``` 10 | 11 | ### Post-factum reporter. Example with unit tests 12 | 13 | To run the example with unit tests please use the following command: 14 | ```cmd 15 | npm run postFactumReporter:unitTests 16 | ``` 17 | 18 | ### Post-factum reporter. Example with chrome driver 19 | 20 | To run the example with chrome driver please use the following command: 21 | ```cmd 22 | npm run postFactumReporter:chromeDriver 23 | ``` 24 | 25 | ### Real-time reporter. Example with chrome driver 26 | 27 | To run the example with chrome driver please use the following command: 28 | ```cmd 29 | npm run realTimeReporter:chromeDriver 30 | ``` 31 | 32 | ### Real-time reporter. Example with chrome driver for parallel tests execution. 33 | 34 | To run the example with chrome driver please use the following command: 35 | ```cmd 36 | npm run realTimeReporter:chromeDriver:parallelRun 37 | ``` 38 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/data/cities.json: -------------------------------------------------------------------------------- 1 | { 2 | "Belarus": ["Minsk", "Soligorsk", "Slutsk", "Grodno"], 3 | "Russia": ["Moskow", "Lipetsk", "Tver", "Ryazan"], 4 | "USA": ["Washington", "New York", "Chicago", "Las Vegas"] 5 | } 6 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | const chromedriver = require('chromedriver'); 2 | const { RealTimeReporter, ReportingAPI } = require('@reportportal/agent-js-nightwatch'); 3 | const config = require('../rp'); 4 | 5 | const rpReporter = new RealTimeReporter({ ...config, launch: 'REAL_TIME_REPORTER_LAUNCH' }); 6 | 7 | module.exports = { 8 | src_folders: ['./RTR-exampleChromeDriver/tests'], 9 | custom_commands_path: ['./node_modules/@reportportal/agent-js-nightwatch/build/commands'], 10 | 11 | test_settings: { 12 | default: { 13 | skip_testcases_on_fail: false, 14 | webdriver: { 15 | start_process: true, 16 | server_path: chromedriver.path, 17 | port: 4444, 18 | cli_args: ['--port=4444'] 19 | }, 20 | globals: { 21 | before: function (done) { 22 | ReportingAPI.init(); 23 | 24 | const launchParams = { 25 | description: 'This launch contains nightwatch tests results run with chromedriver', 26 | attributes: [{ key: 'lib', value: 'chromedriver' }, { key: 'agent', value: 'nightwatch' }], 27 | }; 28 | 29 | rpReporter.startLaunch(launchParams); 30 | done(); 31 | }, 32 | 33 | after: function (done) { 34 | rpReporter.finishLaunch(); 35 | 36 | ReportingAPI.destroy(); 37 | done(); 38 | }, 39 | }, 40 | desiredCapabilities: { 41 | browserName: 'chrome', 42 | chromeOptions: { 43 | args: ['--headless'] 44 | }, 45 | acceptSslCerts: true 46 | } 47 | } 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/tests/attributes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const {ReportingAPI} = require('@reportportal/agent-js-nightwatch'); 19 | 20 | const suiteName = 'Attribute example'; 21 | 22 | describe(suiteName, () => { 23 | before(() => { 24 | const suiteObject = { 25 | name: suiteName, 26 | attributes: [{key: 'suite', value: 'attributes.js'}] 27 | }; 28 | 29 | ReportingAPI.startSuite(suiteObject); 30 | 31 | ReportingAPI.addDescription('This `suite` and `test` contains **attributes**'); 32 | }); 33 | 34 | after((browser, done) => { 35 | ReportingAPI.finishSuite(suiteName); 36 | browser.end(() => { 37 | done(); 38 | }); 39 | }); 40 | 41 | beforeEach((browser) => { 42 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 43 | }); 44 | 45 | afterEach((browser) => { 46 | ReportingAPI.finishTestCase(browser.currentTest); 47 | }); 48 | 49 | test('Test with attributes', (browser) => { 50 | browser 51 | .url('https://www.ecosia.org/') 52 | .waitForElementVisible('body') 53 | .assert.titleContains('Ecosia') 54 | .end(); 55 | 56 | ReportingAPI.addAttributes([{key: 'key', value: 'value'}, {value: 'value_2'}]); 57 | ReportingAPI.addDescription('`Step` with **attributes**'); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/tests/home.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const {ReportingAPI} = require('@reportportal/agent-js-nightwatch'); 19 | 20 | const suiteName = 'Home'; 21 | 22 | describe(suiteName, function () { 23 | 24 | this.retries(3); 25 | 26 | before(() => { 27 | ReportingAPI.startBeforeSuite(); 28 | // beforeSuite related actions 29 | ReportingAPI.addDescription('This is **before suite hook**'); 30 | ReportingAPI.addAttributes([{key: 'suite', value: 'home.js'}]); 31 | ReportingAPI.finishBeforeSuite(); 32 | 33 | const item = { 34 | name: suiteName, 35 | attributes: [{ key: 'suite', value: 'home.js' }], 36 | description: 'Suite description', 37 | }; 38 | ReportingAPI.startSuite(item); 39 | ReportingAPI.addDescription('`Suite` contain `tests` with retries') 40 | }); 41 | 42 | after((browser, done) => { 43 | ReportingAPI.finishSuite(suiteName); 44 | browser.end(() => { 45 | done(); 46 | }); 47 | }); 48 | 49 | beforeEach((browser) => { 50 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 51 | }); 52 | 53 | afterEach((browser) => { 54 | ReportingAPI.finishTestCase(browser.currentTest); 55 | }); 56 | 57 | test('ecosia.org test', function(browser) { 58 | ReportingAPI.addDescription('Demo test for ecosia.org'); 59 | 60 | browser 61 | .url('https://www.ecosia.org/') 62 | .setValue('input[type=search]', 'nightwatch') 63 | .saveScreenshot('testScreen.png', (data) => { 64 | ReportingAPI.logInfo('This is a log with screenshot attachment', { 65 | name: 'testScreen', 66 | content: data.value, 67 | }); 68 | }) 69 | .rpSaveScreenshot('rpTestScreen.jpg') 70 | .rpLog('Screenshot attached successfully') 71 | .click('button[type=submit]') 72 | .assert.containsText('.mainline-results', 'Nightwatch.js') 73 | .end(); 74 | 75 | ReportingAPI.logInfo('Info log for suite', null, suiteName); 76 | 77 | ReportingAPI.addAttributes([{ key: 'check', value: 'success' }]); 78 | ReportingAPI.addDescription('Attributes added to the test item'); 79 | }); 80 | 81 | test('search nightwatch on ecosia.org', function(browser) { 82 | ReportingAPI.addDescription('Demo test for ecosia.org #2'); 83 | 84 | let expectedMainlineText = 'Nightwatch.jsasd'; 85 | 86 | if (browser.currentTest.results.retries > 2) { 87 | expectedMainlineText = 'Nightwatch.js'; 88 | } 89 | 90 | browser 91 | .url('https://www.ecosia.org/') 92 | .setValue('input[type=search]', 'nightwatch') 93 | .click('button[type=submit]') 94 | .assert.containsText('.mainline-results', expectedMainlineText) 95 | .end(); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/tests/logs.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const {ReportingAPI, FILE_TYPES} = require('@reportportal/agent-js-nightwatch'); 19 | const fs = require('fs'); 20 | const path = require('path'); 21 | 22 | const suiteName = 'Logs example'; 23 | 24 | module.exports = { 25 | before: () => { 26 | const suiteObj = { 27 | name: suiteName, 28 | attributes: [{key: 'suite', value: 'logs.js'}], 29 | } 30 | ReportingAPI.startSuite(suiteObj); 31 | 32 | ReportingAPI.launchLogFatal('Launch FATAL log'); 33 | ReportingAPI.launchLogError('Launch ERROR log'); 34 | ReportingAPI.launchLogWarn('Launch WARN log'); 35 | ReportingAPI.launchLogInfo('Launch INFO log'); 36 | ReportingAPI.launchLogDebug('Launch DEBUG log'); 37 | ReportingAPI.launchLogTrace('Launch TRACE log'); 38 | 39 | ReportingAPI.logTrace('TRACE log for suite', null, suiteName); 40 | ReportingAPI.logError('ERROR log for suite', null, suiteName); 41 | ReportingAPI.logWarn('WARN log for suite', null, suiteName); 42 | ReportingAPI.logInfo('INFO log for suite', null, suiteName); 43 | ReportingAPI.logDebug('DEBUG log for suite', null, suiteName); 44 | ReportingAPI.logFatal('FATAL log for suite', null, suiteName); 45 | 46 | const attachment = { 47 | name: 'Cities', 48 | type: FILE_TYPES.JSON, 49 | content: fs.readFileSync(path.resolve(__dirname, '../data', 'cities.json')), 50 | }; 51 | ReportingAPI.launchLogInfo('INFO log with attachment for launch', attachment); 52 | 53 | ReportingAPI.addDescription('This `launch`, `suite` and `steps` contains **different level logs** and logs with **attachments**'); 54 | }, 55 | 56 | beforeEach: (browser) => { 57 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 58 | }, 59 | 60 | afterEach: (browser) => { 61 | ReportingAPI.finishTestCase(browser.currentTest); 62 | }, 63 | 64 | after: function (browser, done) { 65 | ReportingAPI.finishSuite(suiteName); 66 | browser.end(() => { 67 | done(); 68 | }); 69 | }, 70 | 71 | 'Step with logs': (browser) => { 72 | browser 73 | .url('https://www.ecosia.org/') 74 | .waitForElementVisible('body') 75 | .assert.titleContains('Ecosia') 76 | .end(); 77 | 78 | ReportingAPI.logTrace('step TRACE log'); 79 | ReportingAPI.logError('step ERROR log'); 80 | ReportingAPI.logWarn('step WARN log'); 81 | ReportingAPI.logInfo('step INFO log'); 82 | ReportingAPI.logDebug('step DEBUG log'); 83 | ReportingAPI.logFatal('step FATAL log'); 84 | 85 | ReportingAPI.addDescription('This `step` with **different level logs**'); 86 | }, 87 | 88 | 'Step with attachment' : (browser) => { 89 | browser 90 | .url('https://www.ecosia.org/') 91 | .waitForElementVisible('body') 92 | .assert.titleContains('Ecosia') 93 | .end(); 94 | 95 | const attachment = { 96 | name: 'Cities', 97 | type: FILE_TYPES.JSON, 98 | content: fs.readFileSync(path.resolve(__dirname, '../data', 'cities.json')), 99 | }; 100 | ReportingAPI.logWarn('WARN log with attachment', attachment); 101 | 102 | ReportingAPI.addDescription('This `step` contain log with **attachment**'); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/tests/search.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const fs = require('fs'); 19 | const path = require('path'); 20 | const { ReportingAPI, FILE_TYPES } = require('@reportportal/agent-js-nightwatch'); 21 | 22 | const suiteName = 'Search'; 23 | 24 | module.exports = { 25 | before: function () { 26 | const item = { 27 | name: suiteName, 28 | description: 'Suite description', 29 | attributes: [{ key: 'suite', value: 'search' }], 30 | }; 31 | ReportingAPI.startSuite(item); 32 | }, 33 | 34 | beforeEach: function (browser) { 35 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 36 | }, 37 | 38 | afterEach: function (browser) { 39 | ReportingAPI.finishTestCase(browser.currentTest); 40 | 41 | ReportingAPI.startAfterTestCase(suiteName); 42 | // afterEach related actions 43 | ReportingAPI.addDescription('This is **after step hook**'); 44 | ReportingAPI.finishAfterTestCase(); 45 | }, 46 | 47 | after: function (browser, done) { 48 | ReportingAPI.finishSuite(suiteName); 49 | browser.end(() => { 50 | done(); 51 | }); 52 | }, 53 | 54 | 'test google' : function (browser) { 55 | browser 56 | .url('https://google.com') 57 | .waitForElementPresent('foo', 1000); 58 | 59 | ReportingAPI.logInfo('Info log for demo test item'); 60 | ReportingAPI.addDescription('Demo test for google.com'); 61 | ReportingAPI.setTestCaseId('itemTestCaseId'); 62 | }, 63 | 64 | 'searching nightwatch' : function(browser) { 65 | browser 66 | .setValue('input[type=text]', ['nightwatch', browser.Keys.ENTER]) 67 | .pause(1000) 68 | .assert.urlContains('search?') 69 | .assert.urlContains('nightwatch') 70 | .end(); 71 | 72 | const attachment = { 73 | name: 'Cities', 74 | type: FILE_TYPES.JSON, 75 | content: fs.readFileSync(path.resolve(__dirname, '../data', 'cities.json')), 76 | }; 77 | 78 | ReportingAPI.setStatusPassed(); 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriver/tests/testCaseId.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const {ReportingAPI} = require('@reportportal/agent-js-nightwatch'); 19 | 20 | const suiteName = 'TestCaseId example'; 21 | 22 | describe(suiteName, () => { 23 | before(() => { 24 | const suiteObject = { 25 | name: suiteName, 26 | attributes: [{key: 'suite', value: 'testCaseId.js'}] 27 | }; 28 | 29 | ReportingAPI.startSuite(suiteObject); 30 | 31 | ReportingAPI.setTestCaseId('SUITE_testCaseId'); 32 | ReportingAPI.addDescription('This `suite` and `test` contains custom **testCaseId**'); 33 | }); 34 | 35 | after((browser, done) => { 36 | ReportingAPI.finishSuite(suiteName); 37 | browser.end(() => { 38 | done(); 39 | }); 40 | }); 41 | 42 | beforeEach((browser) => { 43 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 44 | }); 45 | 46 | afterEach((browser) => { 47 | ReportingAPI.finishTestCase(browser.currentTest); 48 | }); 49 | 50 | test('Test with custom testCaseId', (browser) => { 51 | browser 52 | .url('https://www.ecosia.org/') 53 | .waitForElementVisible('body') 54 | .assert.titleContains('Ecosia') 55 | .end(); 56 | 57 | ReportingAPI.setTestCaseId('TEST_testCaseId'); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriverParallelRun/data/cities.json: -------------------------------------------------------------------------------- 1 | { 2 | "Belarus": ["Minsk", "Soligorsk", "Slutsk", "Grodno"], 3 | "Russia": ["Moskow", "Lipetsk", "Tver", "Ryazan"], 4 | "USA": ["Washington", "New York", "Chicago", "Las Vegas"] 5 | } 6 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriverParallelRun/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const chromedriver = require('chromedriver'); 19 | const { RealTimeReporter } = require('@reportportal/agent-js-nightwatch'); 20 | const config = require('../rp'); 21 | 22 | let rpReporter; 23 | 24 | module.exports = { 25 | src_folders: ['./RTR-exampleChromeDriverParallelRun/tests'], 26 | custom_commands_path: ['./node_modules/@reportportal/agent-js-nightwatch/build/commands'], 27 | test_workers: true, 28 | 29 | test_settings: { 30 | default: { 31 | skip_testcases_on_fail: false, 32 | webdriver: { 33 | start_process: true, 34 | server_path: chromedriver.path, 35 | port: 4444, 36 | cli_args: ['--port=4444'] 37 | }, 38 | globals: { 39 | before: function (done) { 40 | rpReporter = new RealTimeReporter({ ...config, launch: 'PARALLEL_RUN_LAUNCH' }); 41 | 42 | const launchParams = { 43 | description: 'This launch contains nightwatch tests results run with chromedriver', 44 | attributes: [{ key: 'lib', value: 'chromedriver' }, { key: 'agent', value: 'nightwatch' }], 45 | }; 46 | 47 | rpReporter.startLaunch(launchParams); 48 | done(); 49 | }, 50 | 51 | after: function (done) { 52 | rpReporter.finishLaunch(); 53 | done(); 54 | }, 55 | }, 56 | persist_globals: true, 57 | desiredCapabilities: { 58 | browserName: 'chrome', 59 | chromeOptions: { 60 | args: ['--headless'] 61 | }, 62 | acceptSslCerts: true 63 | } 64 | } 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriverParallelRun/tests/home.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const { ReportingAPI } = require('@reportportal/agent-js-nightwatch'); 19 | ReportingAPI.init(); 20 | 21 | const suiteName = 'Home'; 22 | 23 | describe(suiteName, function() { 24 | 25 | this.retries(3); 26 | 27 | before(() => { 28 | ReportingAPI.startBeforeSuite(); 29 | // beforeSuite related actions 30 | ReportingAPI.finishBeforeSuite(); 31 | 32 | const item = { 33 | name: suiteName, 34 | attributes: [{ key: 'suite', value: 'home' }], 35 | description: 'Common suite description', 36 | }; 37 | ReportingAPI.startSuite(item); 38 | }); 39 | 40 | after((browser, done) => { 41 | ReportingAPI.finishSuite(suiteName); 42 | browser.end(() => { 43 | ReportingAPI.destroy(); 44 | done(); 45 | }); 46 | }); 47 | 48 | beforeEach((browser) => { 49 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 50 | }); 51 | 52 | afterEach((browser) => { 53 | ReportingAPI.finishTestCase(browser.currentTest); 54 | }); 55 | 56 | test('demo test', function(browser) { 57 | const itemName = 'demo test'; 58 | ReportingAPI.addDescription('Demo test for ecosia.org', itemName); 59 | 60 | browser 61 | .url('https://www.ecosia.org/') 62 | .setValue('input[type=search]', 'nightwatch') 63 | .saveScreenshot('testScreen.png', (data) => { 64 | ReportingAPI.logInfo('This is a log with screenshot attachment', { 65 | name: 'testScreen', 66 | content: data.value, 67 | }, itemName); 68 | }) 69 | .rpSaveScreenshot('rpTestScreen.jpg', itemName) 70 | .rpLog('Screenshot attached successfully', 'INFO', itemName) 71 | .click('button[type=submit]') 72 | .assert.containsText('.mainline-results', 'Nightwatch.js') 73 | .end(); 74 | 75 | ReportingAPI.logInfo('Info log for suite', null, suiteName); 76 | 77 | ReportingAPI.addAttributes([{ key: 'check', value: 'success' }], itemName); 78 | ReportingAPI.addDescription('Attributes added to the test item', itemName); 79 | }); 80 | 81 | test('beta test', function(browser) { 82 | ReportingAPI.addDescription('Demo test for ecosia.org #2', 'beta test'); 83 | 84 | let expectedMainlineText = 'Nightwatch.jsasd'; 85 | 86 | if (browser.currentTest.results.retries > 2) { 87 | expectedMainlineText = 'Nightwatch.js'; 88 | } 89 | 90 | browser 91 | .url('https://www.ecosia.org/') 92 | .setValue('input[type=search]', 'nightwatch') 93 | .click('button[type=submit]') 94 | .assert.containsText('.mainline-results', expectedMainlineText) 95 | .end(); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /example-nightwatch/RTR-exampleChromeDriverParallelRun/tests/search.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const fs = require('fs'); 19 | const path = require('path'); 20 | const { ReportingAPI, FILE_TYPES } = require('@reportportal/agent-js-nightwatch'); 21 | ReportingAPI.init(); 22 | 23 | const suiteName = 'Search'; 24 | 25 | module.exports = { 26 | before: function () { 27 | const item = { 28 | name: suiteName, 29 | description: 'Suite description', 30 | attributes: [{ key: 'suite', value: 'someOtherTest.js' }], 31 | }; 32 | ReportingAPI.startSuite(item); 33 | }, 34 | 35 | beforeEach: function (browser) { 36 | ReportingAPI.startTestCase(browser.currentTest, suiteName); 37 | }, 38 | 39 | afterEach: function (browser) { 40 | ReportingAPI.finishTestCase(browser.currentTest); 41 | 42 | ReportingAPI.startAfterTestCase(suiteName); 43 | // afterEach related actions 44 | ReportingAPI.finishAfterTestCase(); 45 | }, 46 | 47 | after: function (browser, done) { 48 | ReportingAPI.finishSuite(suiteName); 49 | browser.end(() => { 50 | ReportingAPI.destroy(); 51 | done(); 52 | }); 53 | }, 54 | 55 | 'demo test google' : function (browser) { 56 | browser 57 | .url('https://google.com') 58 | .waitForElementPresent('foos', 1000); 59 | 60 | ReportingAPI.logInfo('Info log for demo test item', null, browser.currentTest.name); 61 | ReportingAPI.launchLogDebug('Debug log for launch'); 62 | ReportingAPI.addDescription('Demo test for google.com', browser.currentTest.name); 63 | }, 64 | 65 | 'part two' : function(browser) { 66 | browser 67 | .setValue('input[type=text]', ['nightwatch', browser.Keys.ENTER]) 68 | .pause(1000) 69 | .assert.urlContains('search?') 70 | .assert.urlContains('nightwatch') 71 | .end(); 72 | 73 | const attachment = { 74 | name: 'Cities', 75 | type: FILE_TYPES.JSON, 76 | content: fs.readFileSync(path.resolve(__dirname, '../data', 'cities.json')), 77 | }; 78 | 79 | ReportingAPI.launchLogInfo('Log with attachment for launch', attachment); 80 | ReportingAPI.setStatusWarn(browser.currentTest.name); 81 | } 82 | }; 83 | -------------------------------------------------------------------------------- /example-nightwatch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Apache-2.0", 3 | "scripts": { 4 | "postFactumReporter:unitTests": "nightwatch --config PFR-exampleUnitTests/nightwatch.json --reporter PFR-exampleUnitTests/reporter.js", 5 | "postFactumReporter:chromeDriver": "nightwatch --config PFR-exampleChromeDriver/nightwatch.conf.js --reporter PFR-exampleChromeDriver/reporter.js", 6 | "realTimeReporter:chromeDriver": "nightwatch --config RTR-exampleChromeDriver/nightwatch.conf.js", 7 | "realTimeReporter:chromeDriver:parallelRun": "nightwatch --config RTR-exampleChromeDriverParallelRun/nightwatch.conf.js" 8 | }, 9 | "devDependencies": { 10 | "@reportportal/agent-js-nightwatch": "^5.0.0", 11 | "chai": "^4.1.2", 12 | "chromedriver": "83.0.0", 13 | "nightwatch": "1.3.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example-nightwatch/rp.json: -------------------------------------------------------------------------------- 1 | { 2 | "project": "PROJECT_NAME", 3 | "token": "00000000-0000-0000-0000-000000000000", 4 | "endpoint": "https://your.reportportal.server/api/v1" 5 | } 6 | -------------------------------------------------------------------------------- /example-playwright/.sauce/config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1alpha 2 | kind: playwright 3 | sauce: 4 | region: eu-central-1 5 | concurrency: 30 6 | retries: 1 7 | metadata: 8 | tags: 9 | - shard 10 | docker: 11 | fileTransfer: copy 12 | playwright: 13 | version: package.json # See https://docs.saucelabs.com/web-apps/automated-testing/playwright/#supported-testing-platforms for a list of supported versions. 14 | configFile: playwright.config.ts # See https://docs.saucelabs.com/web-apps/automated-testing/playwright/yaml/#configfile for a list of supported configuration files. 15 | rootDir: ./ 16 | reporters: 17 | json: 18 | enabled: true 19 | filename: saucectl-report.json 20 | junit: 21 | enabled: true 22 | filename: saucectl-junit-report.xml 23 | npm: 24 | dependencies: 25 | - "@reportportal/agent-js-playwright" 26 | suites: 27 | - name: "Chromium Win" 28 | platformName: "Windows 11" 29 | screenResolution: "1440x900" 30 | testMatch: ["tests/rp-features"] 31 | smartRetry: 32 | failedOnly: true 33 | shard: spec 34 | params: 35 | browserName: "chromium" 36 | slowMo: 1000 37 | # project: "basic" # Runs the project that's defined in `playwright.config.js` 38 | artifacts: 39 | cleanup: true 40 | download: 41 | when: always 42 | match: 43 | - '*.*' 44 | directory: ./artifacts/ 45 | -------------------------------------------------------------------------------- /example-playwright/.sauceignore: -------------------------------------------------------------------------------- 1 | # This file instructs saucectl to not package any files mentioned here. 2 | .git/ 3 | .github/ 4 | .DS_Store 5 | .hg/ 6 | .vscode/ 7 | .idea/ 8 | .gitignore 9 | .hgignore 10 | .gitlab-ci.yml 11 | .npmrc 12 | *.gif 13 | # Remove this to have node_modules uploaded with code 14 | # node_modules/ 15 | -------------------------------------------------------------------------------- /example-playwright/README.md: -------------------------------------------------------------------------------- 1 | # Example for [@reportportal/agent-js-playwright](https://github.com/reportportal/agent-js-playwright) 2 | 3 | ## Run test example: 4 | 5 | Install dependencies: 6 | 7 | ```bash 8 | npm install 9 | ``` 10 | 11 | Fill in the following options in `playwright.config.ts`: 12 | 13 | ```typescript 14 | const rpConfig = { 15 | // required fields 16 | apiKey: '00000000-0000-0000-0000-000000000000', 17 | endpoint: 'https://your.reportportal.server/api/v1', 18 | project: 'Your ReportPortal project name', 19 | launch: 'Custom regression', 20 | // optional fields 21 | attributes: [ 22 | { 23 | key: 'agent', 24 | value: 'playwright', 25 | }, 26 | { 27 | value: 'demo', 28 | }, 29 | ], 30 | description: 'This is an example launch with playwright tests', 31 | restClientConfig: { 32 | timeout: 0, 33 | }, 34 | includeTestSteps: true, 35 | skippedIssue: false, 36 | }; 37 | ``` 38 | 39 | To run the tests, use the following command: 40 | ```bash 41 | npm test 42 | ``` 43 | 44 | ## Run in SauceLabs 45 | 46 | 1. If you are using SauceLabs to run Playwright tests, don't forget to include the agent package in `npm` dependencies in the `.sauce/config.yml`: 47 | 48 | ```yaml 49 | # ... 50 | npm: 51 | packages: 52 | "@reportportal/agent-js-playwright": "^5.1.11" 53 | # ... 54 | ``` 55 | 56 | 2. Make sure the integration configured on [ReportPortal side](https://reportportal.io/docs/plugins/SauceLabs/). 57 | 58 | To make the SauceLabs page visible on ReportPortal UI, just provide the corresponding attributes to any of tests cases where you wish to observe it: 59 | 60 | ```typescript 61 | test('Just test', async ({ page, browserName }) => { 62 | ReportingApi.addAttributes([{ 63 | key: 'SLID', 64 | value: process.env.SAUCE_JOB_ID, 65 | }, { 66 | key: 'SLDC', 67 | value: String(process.env.SAUCE_REGION || '').toLowerCase().includes('us') ? 'US' : 'EU', 68 | }]); 69 | 70 | // ... 71 | }); 72 | ``` 73 | 74 | 3. Run the tests 75 | 76 | ```bash 77 | cross-env SAUCE_USERNAME=\"user_name\" SAUCE_ACCESS_KEY=\"access_key\" saucectl run --build playwright-build-123 78 | ``` 79 | 80 | `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` can be also set to environment variables prior execution. 81 | -------------------------------------------------------------------------------- /example-playwright/global-setup.ts: -------------------------------------------------------------------------------- 1 | import { FullConfig } from '@playwright/test'; 2 | 3 | async function globalSetup(config: FullConfig) { 4 | } 5 | 6 | export default globalSetup; 7 | -------------------------------------------------------------------------------- /example-playwright/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "npx playwright test --config=playwright.config.ts", 4 | "test:basic": "npx playwright test --config=playwright.config.ts --project=basic", 5 | "test:by-rp-features": "npx playwright test --config=playwright.config.ts --project=by-rp-features", 6 | "test:with-retries": "npx playwright test --config=playwright.config.ts --project=with-retries", 7 | "test:sauce": "cross-env SAUCE_USERNAME=\"user_name\" SAUCE_ACCESS_KEY=\"access_key\" saucectl run --build playwright-build-123" 8 | }, 9 | "devDependencies": { 10 | "@playwright/test": "^1.47.2", 11 | "@reportportal/agent-js-playwright": "^5.1.11", 12 | "@types/node": "^22.7.4", 13 | "cross-env": "^7.0.3", 14 | "saucectl": "^0.186.1", 15 | "@reportportal/client-javascript": "^5.3.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example-playwright/playwright.config.ts: -------------------------------------------------------------------------------- 1 | import { PlaywrightTestConfig } from '@playwright/test'; 2 | import { config as rpConfig } from './rpConfigCi'; 3 | 4 | const config: PlaywrightTestConfig = { 5 | timeout: 2 * 60 * 1000, 6 | expect: { 7 | timeout: 10000, 8 | }, 9 | fullyParallel: true, 10 | forbidOnly: true, 11 | workers: 5, 12 | use: { 13 | headless: true, 14 | screenshot: { 15 | mode: 'only-on-failure', 16 | fullPage: true, 17 | }, 18 | video: 'retain-on-failure', 19 | actionTimeout: 8000, 20 | navigationTimeout: 40000, 21 | trace: 'retain-on-failure', 22 | }, 23 | reporter: [['@reportportal/agent-js-playwright', rpConfig]], 24 | testDir: './tests', 25 | projects: [ 26 | { 27 | name: 'basic', 28 | testDir: './tests/basic', 29 | }, 30 | { 31 | name: 'by-rp-features', 32 | testDir: './tests/rp-features', 33 | testIgnore: ['retries.spec.ts'], 34 | }, 35 | { 36 | name: 'with-retries', 37 | testMatch: /retries.spec.ts/, 38 | retries: 2, 39 | }, 40 | ], 41 | }; 42 | 43 | export default config; 44 | -------------------------------------------------------------------------------- /example-playwright/rpConfigCi.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | endpoint: process.env.RP_ENDPOINT, 3 | apiKey: process.env.RP_API_KEY, 4 | launch: process.env.RP_LAUNCH || 'Custom regression', 5 | project: process.env.RP_PROJECT, 6 | attributes: [ 7 | { 8 | key: 'agent', 9 | value: 'playwright', 10 | }, 11 | { 12 | value: 'example', 13 | }, 14 | ], 15 | description: 'This is an example launch with playwright tests', 16 | launchId: process.env.RP_LAUNCH_ID, 17 | includeTestSteps: true, 18 | skippedIssue: false, 19 | restClientConfig: { 20 | timeout: 0, 21 | }, 22 | }; 23 | 24 | module.exports = { config }; 25 | -------------------------------------------------------------------------------- /example-playwright/scripts/finishLaunch.js: -------------------------------------------------------------------------------- 1 | const RPClient = require('@reportportal/client-javascript'); 2 | const { config } = require('../rpConfigCi'); 3 | 4 | const client = new RPClient(config); 5 | 6 | const finishLaunch = async () => { 7 | const launchTempId = client.startLaunch({ id: process.env.RP_LAUNCH_ID }).tempId; 8 | const response = await client.finishLaunch(launchTempId, {}).promise; 9 | 10 | return response; 11 | }; 12 | 13 | module.exports = finishLaunch; 14 | -------------------------------------------------------------------------------- /example-playwright/scripts/startLaunch.js: -------------------------------------------------------------------------------- 1 | const RPClient = require('@reportportal/client-javascript'); 2 | const { config } = require('../rpConfigCi'); 3 | 4 | const client = new RPClient(config); 5 | 6 | const startLaunch = async () => { 7 | const { mode, launch, attributes, description } = config; 8 | const response = await client.startLaunch({ name: launch, mode, attributes, description }).promise; 9 | const launchId = response.id; 10 | 11 | return launchId; 12 | }; 13 | 14 | module.exports = startLaunch; 15 | -------------------------------------------------------------------------------- /example-playwright/tests/basic/another-feature.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi } from '@reportportal/agent-js-playwright'; 3 | 4 | const suiteName = 'More checks related to Playwright website. It should'; 5 | 6 | test.describe(suiteName, () => { 7 | test.describe.configure({ mode: 'serial', retries: 2 }); // use 'serial' mode and retries for this suite 8 | 9 | ReportingApi.addAttributes([ 10 | { 11 | key: 'component', 12 | value: 'website', 13 | }, 14 | { 15 | key: 'feature', 16 | value: 'title', 17 | }, 18 | { 19 | key: 'feature', 20 | value: 'get-started', 21 | }, 22 | { 23 | value: 'demo', 24 | }, 25 | ], suiteName); 26 | ReportingApi.setDescription( 27 | 'This suite contains several tests that performs some checks with the **Playwright** website main page.', 28 | suiteName, 29 | ); 30 | 31 | test('has the correct title', async ({ page, browserName }) => { 32 | ReportingApi.addAttributes([ 33 | { 34 | key: 'browser', 35 | value: browserName, 36 | }, 37 | { 38 | value: 'demo', 39 | }, 40 | ]); 41 | ReportingApi.setDescription(`The test name is self-descriptive, but do not hesitate to provide additional *info* about the test, 42 | e.g. some important notes from the **Test Case Management system**, special conditions, etc. 43 | `); 44 | 45 | await page.goto('https://playwright.dev/'); 46 | 47 | await test.step('step. Have "Playwright" title', async () => { 48 | await expect(page).toHaveTitle(/Playwright/); 49 | }); 50 | 51 | await expect(page).toHaveTitle(/Playwright/); 52 | }); 53 | 54 | test('redirect to "intro" page after clicking on get started link', async ({ page, browserName }, testInfo) => { 55 | ReportingApi.addAttributes([ 56 | { 57 | key: 'browser', 58 | value: browserName, 59 | }, 60 | { 61 | value: 'demo', 62 | }, 63 | ]); 64 | ReportingApi.setDescription(`The test name is self-descriptive, but do not hesitate to provide additional *info* about the test, 65 | e.g. some important notes from the **Test Case Management system**, special conditions, etc. 66 | `); 67 | 68 | console.log('The *"Get started"* link will be clicked.'); 69 | 70 | await page.goto('https://playwright.dev/'); 71 | let expectedUrl = /.*intrO/; 72 | 73 | if (testInfo.retry > 1) { 74 | expectedUrl = /.*intro/; 75 | } 76 | 77 | const screenshot = await page.screenshot(); 78 | await testInfo.attach('screenshot', { body: screenshot, contentType: 'image/png' }); 79 | 80 | await page.getByRole('link', { name: 'Get started' }).click(); 81 | await expect(page).toHaveURL(expectedUrl); 82 | }); 83 | 84 | test('should be passed when previous tests passed', async ({ page }) => { 85 | await page.goto('https://playwright.dev/'); 86 | const title = page.locator('.navbar__inner .navbar__title'); 87 | await expect(title).toHaveText('Playwright'); 88 | }); 89 | }); 90 | 91 | test.describe('Checks with "toPass" timeouts', () => { 92 | test(`Expect pool @desktop`, async () => { 93 | await expect 94 | .poll( 95 | () => { 96 | return 1; 97 | }, 98 | { timeout: 30_000 } 99 | ) 100 | .toBe(2); 101 | }); 102 | test('Expect toPass @desktop', async () => { 103 | await expect(() => { 104 | expect(1).toBe(2); 105 | }).toPass({ timeout: 30_000 }); 106 | }); 107 | }); 108 | 109 | -------------------------------------------------------------------------------- /example-playwright/tests/basic/feature.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi } from '@reportportal/agent-js-playwright'; 3 | 4 | test('The Playwright`s website main page should contain "ReportPortal" word', async ({ page, browserName }) => { 5 | console.log('Add **ReportPortal** related *metadata* before starting main test actions.'); 6 | ReportingApi.addAttributes([ 7 | { 8 | key: 'browser', 9 | value: browserName, 10 | }, 11 | { 12 | value: 'demo', 13 | }, 14 | ]); 15 | ReportingApi.setDescription(` 16 | This test simply checks that **Playwright** website contains **"ReportPortal"** word in the navigation bar. 17 | But seems like this test will *fail*. 18 | `); 19 | await page.waitForTimeout(1000); 20 | 21 | console.warn('Warning! The **Playwright** website may not contain "ReportPortal" mentions in its `navigation`.'); 22 | 23 | await page.goto('https://playwright.dev/'); 24 | const title = page.locator('.navbar__inner .navbar__title'); 25 | await page.waitForTimeout(1000); 26 | await expect(title).toHaveText('ReportPortal'); 27 | }); 28 | 29 | test('Just test', async ({ page, browserName }) => { 30 | ReportingApi.addAttributes([{ 31 | key: 'SLID', 32 | value: String(process.env.SAUCE_JOB_ID), 33 | }, { 34 | key: 'SLDC', 35 | value: String(process.env.SAUCE_REGION || '').toLowerCase().includes('us') ? 'US' : 'EU', 36 | }]); 37 | 38 | await page.goto('https://playwright.dev/'); 39 | 40 | const title = page.locator('.navbar__inner .navbar__title'); 41 | await page.waitForTimeout(Math.random() * 1000); 42 | await expect(title).toHaveText('ReportPortal'); 43 | }); 44 | 45 | test('Another test', async ({ page, browserName }) => { 46 | await page.goto('https://playwright.dev/'); 47 | const title = page.locator('.navbar__inner .navbar__title'); 48 | await page.waitForTimeout(3000); 49 | await expect(title).toHaveText('ReportPortal'); 50 | }); 51 | 52 | test('Test to pass', async ({ page, browserName }) => { 53 | await page.goto('https://playwright.dev/'); 54 | const title = page.locator('.navbar__inner .navbar__title'); 55 | await expect(title).toHaveText('Playwright'); 56 | }); 57 | 58 | test.skip('Check that everything is ok', async ({ page, browserName }) => { 59 | console.log('Add **ReportPortal** related *metadata* before starting main test actions.'); 60 | ReportingApi.addAttributes([ 61 | { 62 | key: 'browser', 63 | value: browserName, 64 | }, 65 | { 66 | value: 'demo', 67 | }, 68 | ]); 69 | ReportingApi.setDescription(` 70 | This test simply checks that **Playwright** website contains **"ReportPortal"** word in the navigation bar. 71 | But seems like this test will *fail*. 72 | `); 73 | 74 | console.warn('Warning! The **Playwright** website may not contain "ReportPortal" mentions in its `navigation`.'); 75 | 76 | await page.waitForTimeout(1000); 77 | 78 | await page.goto('https://playwright.dev/'); 79 | const title = page.locator('.navbar__inner .navbar__title'); 80 | 81 | await page.waitForTimeout(1000); 82 | await expect(title).toHaveText('ReportPortal'); 83 | }); 84 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } 4 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | 6 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-playwright/tests/rp-features/attachments/test.jpg -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } 4 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-playwright/tests/rp-features/attachments/test.mp4 -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-playwright/tests/rp-features/attachments/test.png -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/attributes-and-description.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi } from '@reportportal/agent-js-playwright'; 3 | 4 | const suiteName = 'Attributes and description repoting'; 5 | 6 | test.describe(suiteName, () => { 7 | // set description to the suite 8 | ReportingApi.setDescription( 9 | 'This suite contains tests with attributes and description provided via ReportingApi', 10 | suiteName, 11 | ); 12 | // add attributes to the suite 13 | ReportingApi.addAttributes([ 14 | { 15 | key: 'feature', 16 | value: 'attributes', 17 | }, 18 | { 19 | key: 'feature', 20 | value: 'description', 21 | }, 22 | ], suiteName); 23 | ReportingApi.addAttributes([ 24 | { 25 | value: 'demo', 26 | }, 27 | ], suiteName); 28 | 29 | test('should be passed, should have the correct attributes and description', async ({ page, browserName }) => { 30 | // set description to the test 31 | ReportingApi.setDescription('This test just expects Playwright website contains "Playwright" word in the title'); 32 | // add attributes to the test 33 | ReportingApi.addAttributes([ 34 | { 35 | key: 'browser', 36 | value: browserName, 37 | }, 38 | { 39 | value: 'demo', 40 | }, 41 | ]); 42 | 43 | await page.goto('https://playwright.dev/'); 44 | await expect(page).toHaveTitle(/Playwright/); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/retries.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi } from '@reportportal/agent-js-playwright'; 3 | 4 | const suiteName = 'Suite to demonstrate reporting of retried tests.'; 5 | 6 | test.describe(suiteName, () => { 7 | ReportingApi.addAttributes([ 8 | { 9 | key: 'feature', 10 | value: 'retries', 11 | }, 12 | { 13 | value: 'demo', 14 | }, 15 | ], suiteName); 16 | ReportingApi.setDescription('This suite demonstrates retries reporting', suiteName); 17 | 18 | test('should be passed on the second retry', async ({ page, browserName }, testInfo) => { 19 | ReportingApi.addAttributes([ 20 | { 21 | key: 'feature', 22 | value: 'retries', 23 | }, 24 | { 25 | key: 'browser', 26 | value: browserName, 27 | }, 28 | { 29 | value: 'demo', 30 | }, 31 | ]); 32 | ReportingApi.setDescription('This test should be retried according to the config'); 33 | 34 | let expectedTitle = 'wrong value'; 35 | 36 | if (testInfo.retry > 1) { 37 | expectedTitle = 'Playwright'; 38 | } 39 | console.log(`Use "${expectedTitle}" word to title check`); 40 | 41 | await page.goto('https://playwright.dev/'); 42 | const title = page.locator('.navbar__inner .navbar__title'); 43 | await expect(title).toHaveText(expectedTitle); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/statuses.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi } from '@reportportal/agent-js-playwright'; 3 | 4 | const suiteName = 'Getting Started with statuses'; 5 | 6 | test.describe(suiteName, () => { 7 | ReportingApi.addAttributes([ 8 | { 9 | key: 'feature', 10 | value: 'custom-status', 11 | }, 12 | { 13 | value: 'demo', 14 | }, 15 | ], suiteName); 16 | ReportingApi.setDescription( 17 | 'This suite contains tests to demonstrate custom statuses reporting via ReportingApi.', 18 | suiteName, 19 | ); 20 | 21 | test('should be passed, but marked as FAILED in ReportPortal', async ({ page, browserName }) => { 22 | ReportingApi.addAttributes([ 23 | { 24 | key: 'feature', 25 | value: 'custom-status', 26 | }, 27 | { 28 | key: 'entity', 29 | value: 'test', 30 | }, 31 | { 32 | key: 'browser', 33 | value: browserName, 34 | }, 35 | { 36 | value: 'demo', 37 | }, 38 | ]); 39 | ReportingApi.setDescription('This test demonstrates custom statuses reporting via ReportingApi: setStatusFailed()'); 40 | 41 | await page.goto('https://playwright.dev/'); 42 | await expect(page).toHaveTitle(/Playwright/); 43 | 44 | if (true) { 45 | // set failed status when it should be passed 46 | ReportingApi.setStatusFailed(); 47 | } 48 | }); 49 | 50 | test('should be failed, but marked as PASSED in ReportPortal', async ({ page, browserName }) => { 51 | ReportingApi.addAttributes([ 52 | { 53 | key: 'feature', 54 | value: 'custom-status', 55 | }, 56 | { 57 | key: 'entity', 58 | value: 'test', 59 | }, 60 | { 61 | key: 'browser', 62 | value: browserName, 63 | }, 64 | { 65 | value: 'demo', 66 | }, 67 | ]); 68 | ReportingApi.setDescription('This test demonstrates custom statuses reporting via ReportingApi: setStatusPassed()'); 69 | 70 | if (true) { 71 | // set passed status when it should be failed 72 | ReportingApi.setStatusPassed(); 73 | } 74 | 75 | await page.goto('https://playwright.dev/'); 76 | await expect(page).toHaveTitle(/Glaywright/); 77 | }); 78 | 79 | test('should be failed, but set PASSED status for launch in ReportPortal', async ({ page, browserName }) => { 80 | ReportingApi.addAttributes([ 81 | { 82 | key: 'feature', 83 | value: 'custom-status-for-launch', 84 | }, 85 | { 86 | key: 'entity', 87 | value: 'launch', 88 | }, 89 | { 90 | key: 'browser', 91 | value: browserName, 92 | }, 93 | { 94 | value: 'demo', 95 | }, 96 | ]); 97 | ReportingApi.setDescription('This test demonstrates custom statuses reporting via ReportingApi: setLaunchStatusPassed()'); 98 | 99 | ReportingApi.setLaunchStatusPassed(); 100 | 101 | await page.goto('https://playwright.dev/'); 102 | await expect(page).toHaveTitle(/Glaywright/); 103 | }); 104 | }); 105 | 106 | -------------------------------------------------------------------------------- /example-playwright/tests/rp-features/test-case-id.spec.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from '@playwright/test'; 2 | import { ReportingApi} from '@reportportal/agent-js-playwright'; 3 | 4 | const suiteName = 'Test case id reporting suite'; 5 | 6 | test.describe(suiteName, () => { 7 | ReportingApi.addAttributes([ 8 | { 9 | key: 'feature', 10 | value: 'test-case-id', 11 | }, 12 | { 13 | value: 'demo', 14 | }, 15 | ], suiteName); 16 | ReportingApi.setDescription('This suite demonstrates Test case id reporting. Please see the [docs](https://reportportal.io/docs/Test-case-ID%3Ewhat-is-it-test-case-id)', suiteName); 17 | 18 | test('should be failed. No manually provided Test case id', async ({ page, browserName }) => { 19 | ReportingApi.addAttributes([ 20 | { 21 | key: 'feature', 22 | value: 'test-case-id', 23 | }, 24 | { 25 | key: 'method', 26 | value: 'autogenerated', 27 | }, 28 | { 29 | key: 'browser', 30 | value: browserName, 31 | }, 32 | { 33 | value: 'demo', 34 | }, 35 | ]); 36 | ReportingApi.setDescription( 37 | 'This test should contain Test case id that will be generated automatically based on [codeRef](https://reportportal.io/docs/Test-case-ID%3Ewhat-does-happen-if-you-do-not-report-items-with-test-case-id-)', 38 | ); 39 | 40 | await page.goto('https://playwright.dev/'); 41 | const title = page.locator('.navbar__inner .navbar__title'); 42 | await expect(title).toHaveText('wrong value'); 43 | }); 44 | 45 | test('should be passed. Test case id explicitly set via ReportingApi', async ({ page, browserName }) => { 46 | ReportingApi.addAttributes([ 47 | { 48 | key: 'feature', 49 | value: 'test-case-id', 50 | }, 51 | { 52 | key: 'method', 53 | value: 'reporting-api', 54 | }, 55 | { 56 | key: 'browser', 57 | value: browserName, 58 | }, 59 | { 60 | value: 'demo', 61 | }, 62 | ]); 63 | ReportingApi.setDescription('This test should contain Test case id specified by user via ReportingApi'); 64 | // set Test case id manually 65 | ReportingApi.setTestCaseId('myCustomTestIdentifier'); 66 | 67 | await page.goto('https://playwright.dev/'); 68 | const title = page.locator('.navbar__inner .navbar__title'); 69 | await expect(title).toHaveText('Playwright'); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /example-postman/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/newman-reporter-agent-js-postman](https://www.npmjs.com/package/@reportportal/newman-reporter-agent-js-postman) 2 | 3 | ## Run test example: 4 | 5 | Install the packages: 6 | 7 | ```cmd 8 | npm install 9 | ``` 10 | 11 | Specify the following options in index.js: 12 | 13 | ```json 14 | { 15 | "@reportportal/agent-js-postman": { 16 | "endpoint": "http://your-instance.com:8080/api/v1", 17 | "token": "00000000-0000-0000-0000-000000000000", 18 | "launch": "LAUNCH_NAME", 19 | "project": "PROJECT_NAME", 20 | "description": "PROJECT_DESCRIPTION" 21 | } 22 | } 23 | ``` 24 | 25 | To run the tests, use the following command: 26 | ```cmd 27 | npm test 28 | ``` -------------------------------------------------------------------------------- /example-postman/index.js: -------------------------------------------------------------------------------- 1 | const newman = require('newman'); 2 | 3 | newman.run( 4 | { 5 | collection: './collections/Example.postman_collection.json', 6 | reporters: '@reportportal/agent-js-postman', 7 | reporter: { 8 | '@reportportal/agent-js-postman': { 9 | endpoint: 'http://your-instance.com:8080/api/v1', 10 | apiKey: '', 11 | launch: 'Your launch name', 12 | project: 'Your reportportal project name', 13 | description: 'Your launch description', 14 | attributes: [ 15 | { 16 | key: 'attributeKey', 17 | value: 'attrbuteValue', 18 | }, 19 | { 20 | value: 'secondAttrbuteValue', 21 | }, 22 | ], 23 | }, 24 | }, 25 | }, 26 | function (err) { 27 | if (err) { 28 | throw err; 29 | } 30 | }, 31 | ); 32 | -------------------------------------------------------------------------------- /example-postman/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Apache-2.0", 3 | "scripts": { 4 | "test": "node ./index.js" 5 | }, 6 | "dependencies": { 7 | "@reportportal/newman-reporter-agent-js-postman": "^5.1.1", 8 | "newman": "^6.1.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example-testcafe/.testcaferc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | browsers: "chrome", 3 | src: "./tests/**/*.js", 4 | screenshots: { 5 | path: "./screenshots/" 6 | }, 7 | reporter: [ 8 | { 9 | name: "list" 10 | }, 11 | { 12 | name: "agent-js-testcafe" 13 | } 14 | ], 15 | takeScreenshotsOnFails: true 16 | }; 17 | -------------------------------------------------------------------------------- /example-testcafe/README.md: -------------------------------------------------------------------------------- 1 | ## Example for [@reportportal/agent-js-testcafe](https://www.npmjs.com/package/@reportportal/testcafe-reporter-agent-js-testcafe) 2 | 3 | ## Run test example: 4 | 5 | Install the packages: 6 | 7 | ```cmd 8 | npm install 9 | ``` 10 | 11 | Specify the following [options](https://github.com/reportportal/agent-js-testcafe#configuration) in the rp.json: 12 | 13 | ```json 14 | { 15 | "token": "00000000-0000-0000-0000-000000000000", 16 | "endpoint": "https://your.reportportal.server/api/v1", 17 | "project": "YourReportPortalProjectName", 18 | "launch": "YourLauncherName", 19 | "attributes": [ 20 | { 21 | "key": "YourKey", 22 | "value": "YourValue" 23 | }, 24 | { 25 | "value": "YourValue" 26 | } 27 | ], 28 | "description": "Your launch description" 29 | } 30 | ``` 31 | 32 | To run the tests via TestCafe API, use the following command: 33 | ```cmd 34 | npm run test:viaAPI 35 | ``` 36 | 37 | To run the tests via TestCafe CLI, use the following command: 38 | ```cmd 39 | npm run test:viaCLI 40 | ``` 41 | -------------------------------------------------------------------------------- /example-testcafe/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test:viaAPI": "node testcafeManualSetup.js", 4 | "test:viaCLI": "testcafe --config-file .testcaferc.js" 5 | }, 6 | "devDependencies": { 7 | "testcafe": "3.6.2", 8 | "testcafe-reporter-agent-js-testcafe": "npm:@reportportal/testcafe-reporter-agent-js-testcafe@^5.1.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example-testcafe/rp.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiKey": "", 3 | "endpoint": "https://your.reportportal.server/api/v1", 4 | "project": "YourReportPortalProjectName", 5 | "launch": "YourLauncherName", 6 | "attributes": [ 7 | { 8 | "key": "YourKey", 9 | "value": "YourValue" 10 | }, 11 | { 12 | "value": "YourValue" 13 | } 14 | ], 15 | "description": "Your launch description" 16 | } 17 | -------------------------------------------------------------------------------- /example-testcafe/testcafeManualSetup.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | const createTestCafe = require('testcafe'); 19 | const { createReporter } = require('testcafe-reporter-agent-js-testcafe/build/createReporter'); 20 | const rpConfig = require('./rp.json'); 21 | 22 | async function start() { 23 | const testcafe = await createTestCafe('localhost'); 24 | const runner = testcafe.createRunner(); 25 | 26 | await runner.reporter(createReporter(rpConfig)).run(); 27 | 28 | await testcafe.close(); 29 | } 30 | 31 | start(); 32 | -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-testcafe/tests/attachments/test.jpg -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-testcafe/tests/attachments/test.mp4 -------------------------------------------------------------------------------- /example-testcafe/tests/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-testcafe/tests/attachments/test.png -------------------------------------------------------------------------------- /example-testcafe/tests/attributesTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const { ReportingApi } = require('testcafe-reporter-agent-js-testcafe/build/reportingApi'); 18 | 19 | fixture`Show ReportPortal features`.before(() => { 20 | ReportingApi.addAttributes([ 21 | { 22 | key: 'feature', 23 | value: 'attributes', 24 | }, 25 | ]); 26 | ReportingApi.addAttributes([ 27 | { 28 | key: 'browser', 29 | value: 'chrome', 30 | }, 31 | { 32 | value: 'demo', 33 | }, 34 | ]); 35 | }).page`http://devexpress.github.io/testcafe/example`; 36 | 37 | test('should have the correct attributes', async (t) => { 38 | ReportingApi.addAttributes([ 39 | { 40 | key: 'feature', 41 | value: 'attributes', 42 | }, 43 | { 44 | value: 'demo', 45 | }, 46 | ]); 47 | await t.expect(true).eql(true); 48 | }); 49 | -------------------------------------------------------------------------------- /example-testcafe/tests/descriptionWithError.spec.js: -------------------------------------------------------------------------------- 1 | import { RequestLogger } from 'testcafe'; 2 | const { ReportingApi } = require('testcafe-reporter-agent-js-testcafe/build/reportingApi'); 3 | 4 | const url = 'http://localhost:3000/download-file'; 5 | 6 | const logger = RequestLogger( 7 | { url, method: 'GET' }, 8 | { 9 | logResponseHeaders: true, 10 | logResponseBody: true, 11 | stringifyResponseBody: true, 12 | }, 13 | ); 14 | 15 | fixture`Description with error`.page('./hello.html').before(() => { 16 | ReportingApi.addAttributes([ 17 | { 18 | key: 'feature', 19 | value: 'errorMessageInDescription', 20 | }, 21 | ]); 22 | ReportingApi.addAttributes([ 23 | { 24 | key: 'browser', 25 | value: 'chrome', 26 | }, 27 | { 28 | value: 'demo', 29 | }, 30 | ]); 31 | }).requestHooks(logger); 32 | 33 | test('Check file name and content', async (t) => { 34 | ReportingApi.addAttributes([ 35 | { 36 | key: 'feature', 37 | value: 'errorMessageInDescription', 38 | }, 39 | ]); 40 | ReportingApi.addAttributes([ 41 | { 42 | key: 'browser', 43 | value: 'chrome', 44 | }, 45 | { 46 | value: 'demo', 47 | }, 48 | ]); 49 | const fileNameRegEx = /attachment; filename=.*.txt/; 50 | 51 | await t 52 | .click('#download-btn') 53 | .expect( 54 | logger.contains((r) => { 55 | if (r.response.statusCode !== 200) return false; 56 | 57 | const requestInfo = logger.requests[0]; 58 | 59 | if (!requestInfo) return false; 60 | 61 | const downloadedFileName = requestInfo.response.headers['content-disposition']; 62 | 63 | if (!downloadedFileName) false; 64 | 65 | if (!fileNameRegEx.test(downloadedFileName)) return false; 66 | 67 | const downloadedFileContent = logger.requests[0].response.body; 68 | 69 | return downloadedFileContent === 'Test content'; 70 | }), 71 | ) 72 | .ok(); 73 | }); 74 | -------------------------------------------------------------------------------- /example-testcafe/tests/foo.spec.js: -------------------------------------------------------------------------------- 1 | import { Selector } from 'testcafe'; 2 | import { ReportingApi } from 'testcafe-reporter-agent-js-testcafe/build/reportingApi'; 3 | 4 | fixture`Getting Started with statuses`.page`http://devexpress.github.io/testcafe/example` 5 | .before(() => { 6 | ReportingApi.setLaunchStatusCancelled(); 7 | ReportingApi.setStatusInterrupted(); 8 | }) 9 | .meta({ 10 | description: 'This suite contains tests to demonstrate custom statuses reporting via agent-js-testcafe', 11 | attributes: [{ key: 'feature', value: 'customStatus' }, { value: 'demo' }], 12 | }); 13 | 14 | test('My first test', async (page) => { 15 | ReportingApi.setStatusInfo(); 16 | await page 17 | .typeText('#developer-name', 'John Smith') 18 | .click('#submit-button') 19 | // Use the assertion to check if the actual header text is equal to the expected one 20 | .expect(Selector('#article-header').innerText) 21 | .eql('Thank you, John Smith!'); 22 | }).meta({ 23 | description: 'This test contains demonstrates custom statuses reporting via agent-js-testcafe', 24 | attributes: [{ key: 'feature', value: 'customStatus' }, { value: 'demo' }], 25 | }); 26 | 27 | fixture`The next fixture about predefined values`.page`http://devexpress.github.io/testcafe/example`.meta({ 28 | description: 'This suite contains tests to demonstrate predefined attributes reporting via agent-js-testcafe', 29 | attributes: [{ key: 'feature', value: 'predefinedAttributes' }, { value: 'demo' }], 30 | }); 31 | 32 | test('Should fail with error', async (page) => { 33 | await page 34 | .typeText('#developer-name', 'John Smith') 35 | .click('#submit-button') 36 | 37 | .expect(Selector('#article-header').innerText) 38 | .eql('Thank you, Baraka Omaba!'); 39 | }).meta({ 40 | description: 'second test description', 41 | attributes: [{ key: 'feature', value: 'predefinedAttributes' }, { value: 'demo' }], 42 | }); 43 | -------------------------------------------------------------------------------- /example-testcafe/tests/logTest.spec.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import fs from 'fs'; 3 | import { ReportingApi } from 'testcafe-reporter-agent-js-testcafe/build/reportingApi'; 4 | 5 | const attachments = [ 6 | { 7 | filename: 'test.jpg', 8 | type: 'image/jpg', 9 | }, 10 | { 11 | filename: 'test.png', 12 | type: 'image/png', 13 | }, 14 | { 15 | filename: 'test.html', 16 | type: 'text/html', 17 | }, 18 | { 19 | filename: 'test.json', 20 | type: 'application/json', 21 | }, 22 | { 23 | filename: 'test.css', 24 | type: 'application/css', 25 | }, 26 | { 27 | filename: 'test.mp4', 28 | type: 'video/mp4', 29 | }, 30 | ]; 31 | 32 | fixture`launch, suite and test should contain logs` 33 | .page('http://devexpress.github.io/testcafe/example') 34 | .before(async () => { 35 | ReportingApi.debug('debug suite log'); 36 | ReportingApi.trace('trace suite log'); 37 | ReportingApi.warn('warn suite log'); 38 | ReportingApi.error('error suite log'); 39 | ReportingApi.fatal('fatal suite log'); 40 | ReportingApi.info('info suite log'); 41 | }) 42 | .meta({ 43 | description: 'This suite contains tests to demonstrate custom logs reporting via agent-js-testcafe', 44 | attributes: [{ key: 'feature', value: 'customLogs' }, { value: 'demo' }], 45 | }); 46 | 47 | test('should contain simple logs of different levels', async (page) => { 48 | ReportingApi.launchLog('INFO', 'launch log with manually specified info level'); 49 | ReportingApi.launchInfo('info launch log'); 50 | ReportingApi.launchDebug('debug launch log'); 51 | ReportingApi.launchTrace('trace launch log'); 52 | ReportingApi.launchWarn('warn launch log'); 53 | ReportingApi.launchError('error launch log'); 54 | ReportingApi.launchFatal('fatal launch log'); 55 | ReportingApi.debug('debug log'); 56 | ReportingApi.trace('trace log'); 57 | ReportingApi.warn('warning'); 58 | ReportingApi.error('error log'); 59 | ReportingApi.fatal('fatal log'); 60 | ReportingApi.info('info log'); 61 | await page.expect(true).eql(true); 62 | }) 63 | .meta({ 64 | description: 'This test demonstrates custom logs reporting via agent-js-testcafe', 65 | attributes: [{ key: 'feature', value: 'customLogs' }, { value: 'demo' }], 66 | }); 67 | 68 | test('should contain logs with attachments', async (page) => { 69 | const readFilesPromises = attachments.map( 70 | ({ filename, type }) => 71 | new Promise((resolve, reject) => 72 | fs.readFile(path.resolve(__dirname, './attachments', filename), (err, data) => { 73 | if (err) { 74 | reject(err); 75 | } 76 | const attachment = { 77 | name: filename, 78 | type, 79 | content: data.toString('base64'), 80 | }; 81 | ReportingApi.info('info log with attachment', attachment); 82 | resolve(); 83 | }), 84 | ), 85 | ); 86 | await Promise.all(readFilesPromises); 87 | 88 | await page.expect(true).eql(true); 89 | }) 90 | .meta({ 91 | description: 'This test demonstrates custom logs with attachments reporting via agent-js-testcafe', 92 | attributes: [{ key: 'feature', value: 'customLogs' }, { value: 'demo' }, { value: 'withAttachments' }], 93 | }); 94 | -------------------------------------------------------------------------------- /example-testcafe/tests/testCaseIdTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const { ReportingApi } = require('testcafe-reporter-agent-js-testcafe/build/reportingApi'); 18 | 19 | fixture`Report custom testCaseId for suite/test`.before(() => { 20 | ReportingApi.setTestCaseId('TestCaseIdForTheSuite'); 21 | }).page`http://devexpress.github.io/testcafe/example` 22 | .meta({ 23 | description: 'This suite demonstrates testCaseId reporting via agent-js-testcafe', 24 | attributes: [{ key: 'feature', value: 'explicitTestCaseId' }, { key: 'feature', value: 'autogeneratedTestCaseId' }, { value: 'demo' }], 25 | }); 26 | 27 | test('should have the correct explicit testCaseId', async (t) => { 28 | ReportingApi.setTestCaseId('TestCaseIdForTheTest'); 29 | await t.expect(true).eql(true); 30 | }) 31 | .meta({ 32 | description: 'This test demonstrates explicit testCaseId reporting via agent-js-testcafe', 33 | attributes: [{ key: 'feature', value: 'explicitTestCaseId' }, { value: 'demo' }], 34 | }); 35 | 36 | test('should have the correct autogenerated testCaseId', async (t) => { 37 | await t.expect(true).eql(true); 38 | }) 39 | .meta({ 40 | description: 'This test demonstrates autogenerated testCaseId reporting via agent-js-testcafe', 41 | attributes: [{ key: 'feature', value: 'autogeneratedTestCaseId' }, { value: 'demo' }], 42 | }); 43 | -------------------------------------------------------------------------------- /example-vitest/basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "vitest run" 4 | }, 5 | "devDependencies": { 6 | "vitest": "1.2.2", 7 | "@reportportal/agent-js-vitest": "^5.1.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example-vitest/basic/src/basic.ts: -------------------------------------------------------------------------------- 1 | export const squared = (n: number) => n * n; 2 | 3 | -------------------------------------------------------------------------------- /example-vitest/basic/test/basic.spec.ts: -------------------------------------------------------------------------------- 1 | import { assert, expect, test } from 'vitest'; 2 | import { squared } from '../src/basic'; 3 | 4 | test('Math.sqrt()', () => { 5 | expect(Math.sqrt(4)).toBe(2); 6 | expect(Math.sqrt(144)).toBe(12); 7 | expect(Math.sqrt(2)).toBe(Math.SQRT2); 8 | }); 9 | 10 | test('Squared', () => { 11 | expect(squared(2)).toBe(4); 12 | expect(squared(12)).toBe(1440); 13 | }); 14 | 15 | test('JSON', () => { 16 | const input = { 17 | foo: 'hello', 18 | bar: 'world', 19 | }; 20 | console.log(input.foo); 21 | 22 | const output = JSON.stringify(input); 23 | 24 | expect(output).eq('{"foo":"hello","bar":"world"}'); 25 | assert.deepEqual(JSON.parse(output), input, 'matches original'); 26 | }); 27 | -------------------------------------------------------------------------------- /example-vitest/basic/test/files/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-vitest/basic/test/files/test.png -------------------------------------------------------------------------------- /example-vitest/basic/test/reportingApi.spec.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest'; 2 | import fs from 'fs'; 3 | import path from 'path'; 4 | 5 | test('Attachment', () => { 6 | const fileName = 'test.png'; 7 | const fileContent = fs.readFileSync(path.resolve(__dirname, './files', fileName)); 8 | 9 | ReportingApi.attachment({ 10 | name: fileName, 11 | type: 'image/png', 12 | content: fileContent.toString('base64'), 13 | }, 'Test PNG description'); 14 | 15 | expect(true).toBe(true); 16 | }); 17 | -------------------------------------------------------------------------------- /example-vitest/basic/test/suite.spec.ts: -------------------------------------------------------------------------------- 1 | import { assert, describe, expect, it } from 'vitest'; 2 | 3 | describe('suite name', () => { 4 | it.skip('statically skipped test', () => { 5 | assert.equal(Math.sqrt(4), 2); 6 | }) 7 | 8 | it('dynamically skipped test', (context) => { 9 | context.skip(); 10 | expect(1 + 1).eq(2); 11 | }); 12 | 13 | it.todo('todo test', () => { 14 | assert.equal(Math.sqrt(4), 2); 15 | }); 16 | 17 | it.fails('Should be failed', () => { 18 | assert.equal(Math.sqrt(4), 2); 19 | }); 20 | 21 | it('snapshot', () => { 22 | console.log('12345'); 23 | expect({ foo: 'bar' }).toMatchSnapshot(); 24 | }); 25 | 26 | it('foo', () => { 27 | assert.equal(Math.sqrt(4), 3); 28 | }); 29 | }); 30 | 31 | describe('empty suite', () => { 32 | console.log('empty suite log'); 33 | }); 34 | -------------------------------------------------------------------------------- /example-vitest/basic/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | import RPReporter from '@reportportal/agent-js-vitest'; 3 | 4 | const rpConfig = { 5 | launch: 'Custom regression with vitest', 6 | apiKey: '00000000-0000-0000-0000-000000000000', 7 | endpoint: 'https://your.reportportal.server/api/v1', 8 | project: 'Your project', 9 | attributes: [ 10 | { 11 | key: 'agent', 12 | value: 'vitest', 13 | }, 14 | { 15 | value: 'example', 16 | }, 17 | ], 18 | description: 'This is an example launch with Vitest tests', 19 | }; 20 | 21 | export default defineConfig({ 22 | test: { 23 | setupFiles: ["@reportportal/agent-js-vitest/setup"], 24 | reporters: ['default', new RPReporter(rpConfig)], 25 | fileParallelism: true, 26 | sequence: { 27 | concurrent: true, 28 | }, 29 | }, 30 | }); 31 | -------------------------------------------------------------------------------- /example-vitest/playwright/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Playwright Vitest Test Page 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example-vitest/playwright/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "build": "vite build", 4 | "test": "vite build && vitest run", 5 | "test:ui": "vite build && vitest --ui" 6 | }, 7 | "devDependencies": { 8 | "@playwright/test": "^1.41.0", 9 | "@vitest/ui": "latest", 10 | "playwright": "^1.41.0", 11 | "vite": "latest", 12 | "vitest": "latest", 13 | "@reportportal/agent-js-vitest": "^5.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example-vitest/playwright/src/index.ts: -------------------------------------------------------------------------------- 1 | const root = document.createElement('div'); 2 | const button = document.createElement('button'); 3 | 4 | let count = 0; 5 | 6 | button.textContent = `Clicked ${count} time(s)`; 7 | 8 | button.onclick = () => { 9 | count++; 10 | button.textContent = `Clicked ${count} time(s)`; 11 | } 12 | 13 | root.appendChild(button); 14 | document.body.appendChild(root); 15 | -------------------------------------------------------------------------------- /example-vitest/playwright/test/basic.test.ts: -------------------------------------------------------------------------------- 1 | import { afterAll, beforeAll, describe, test } from 'vitest' 2 | import { preview } from 'vite' 3 | import type { PreviewServer } from 'vite' 4 | import { chromium } from 'playwright' 5 | import type { Browser, Page } from 'playwright' 6 | import { expect } from '@playwright/test' 7 | 8 | const PORT = 3001 9 | 10 | describe('basic', async () => { 11 | let server: PreviewServer 12 | let browser: Browser 13 | let page: Page 14 | 15 | beforeAll(async () => { 16 | server = await preview({ preview: { port: PORT } }) 17 | browser = await chromium.launch({ headless: true }) 18 | page = await browser.newPage() 19 | }) 20 | 21 | afterAll(async () => { 22 | await browser.close() 23 | await new Promise((resolve, reject) => { 24 | server.httpServer.close(error => error ? reject(error) : resolve()) 25 | }) 26 | }) 27 | 28 | test('should change count when button clicked', async () => { 29 | console.log('Load URL'); 30 | await page.goto(`http://localhost:${PORT}`); 31 | const button = page.getByRole('button', { name: /Clicked/ }); 32 | await expect(button).toBeVisible(); 33 | await expect(button).toHaveText('Clicked 0 time(s)'); 34 | 35 | await button.click(); 36 | await expect(button).toHaveText('Clicked 1 time(s)'); 37 | }, 30_000); 38 | 39 | test('should fail on change count when button clicked', async () => { 40 | await page.goto(`http://localhost:${PORT}`) 41 | const button = page.getByRole('button', { name: /Clicked/ }) 42 | await expect(button).toBeVisible() 43 | 44 | await expect(button).toHaveText('Clicked 0 time(s)') 45 | 46 | console.warn('Smth can be wrong'); 47 | await button.click() 48 | await expect(button).toHaveText('Clicked xx time(s)') 49 | }, 800); 50 | }) 51 | -------------------------------------------------------------------------------- /example-vitest/playwright/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /example-vitest/playwright/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import { RPReporter } from '@reportportal/agent-js-vitest'; 3 | 4 | const rpConfig = { 5 | launch: 'Custom regression with vitest', 6 | apiKey: '00000000-0000-0000-0000-000000000000', 7 | endpoint: 'https://your.reportportal.server/api/v1', 8 | project: 'Your project', 9 | attributes: [ 10 | { 11 | key: 'agent', 12 | value: 'vitest', 13 | }, 14 | { 15 | value: 'example', 16 | }, 17 | ], 18 | description: 'This is an example launch with Vitest tests', 19 | }; 20 | 21 | export default defineConfig({ 22 | test: { 23 | reporters: ['default', new RPReporter(rpConfig)], 24 | fileParallelism: true, 25 | testTimeout: 800, 26 | hookTimeout: 60_000, 27 | }, 28 | }) 29 | -------------------------------------------------------------------------------- /example-webdriverio/README.md: -------------------------------------------------------------------------------- 1 | ## Example for @reportportal/agent-js-webdriverio 2 | 3 | ## Run test example: 4 | 5 | ## Installation 6 | Add test framework. Follow the instruction on the page [WDIO frameworks](https://webdriver.io/docs/frameworks) 7 | 8 | Run: 9 | ```cmd 10 | npm install or npm i 11 | ``` 12 | 13 | ## Configuration 14 | Configure `wdio.conf.js` file: 15 | ```js 16 | const { Reporter } = require('@reportportal/agent-js-webdriverio'); 17 | 18 | const rpConfig = { 19 | reportPortalClientConfig: { 20 | token: '00000000-0000-0000-0000-00000000000', 21 | endpoint: 'http://your-instance:8080/api/v1', 22 | launch: 'launch_name', 23 | project: 'project_name', 24 | mode: 'DEFAULT', 25 | debug: false, 26 | description: 'Launch description', 27 | attributes: [{ key: 'key', value: 'value' }, { value: 'value' }], // launch attributes 28 | }, 29 | }; 30 | 31 | exports.config = { 32 | // ... 33 | services: [[Reporter, rpConfig]], 34 | framework: 'jasmine' // chosen framework 35 | // ... 36 | }; 37 | ``` 38 | 39 | To run the tests use command 40 | ```cmd 41 | npm run test 42 | ``` 43 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "wdio" 4 | }, 5 | "devDependencies": { 6 | "@reportportal/agent-js-webdriverio": "^5.1.1", 7 | "@wdio/cli": "^7.13.2", 8 | "@wdio/cucumber-framework": "^7.13.2", 9 | "@wdio/local-runner": "^7.13.2", 10 | "chromedriver": "*", 11 | "wdio-chromedriver-service": "^7.2.2", 12 | "@cucumber/cucumber": "^7.3.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/features/attributes.feature: -------------------------------------------------------------------------------- 1 | @custom:attribute @value 2 | Feature: attributes 3 | example: how to provide **attributes** 4 | 5 | Scenario: Given and expected value are equal 6 | Given I put "true" 7 | Then I should compare it with "false" 8 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/features/description.feature: -------------------------------------------------------------------------------- 1 | Feature: descriptions 2 | example: how to provide **description** 3 | 4 | Scenario: Get the title of webpage 5 | Given I go to the website 6 | Then I expect the title of the page "Google" 7 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/features/logs.feature: -------------------------------------------------------------------------------- 1 | Feature: logs 2 | example: how to provide **logs** 3 | 4 | Scenario: Provide attachments 5 | Given I want add INFO log to step and TRACE log to launch 6 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/features/statuses.feature: -------------------------------------------------------------------------------- 1 | Feature: statuses 2 | example: how to provide **statuses** 3 | 4 | Scenario: Provide custom statuses 5 | Given I want change PASSED step status to INFO 6 | Then I want change FAILED step status to PASSED 7 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/attributes/given.js: -------------------------------------------------------------------------------- 1 | const { Given } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | 4 | Given('I put {string}', function (givenValue) { 5 | ReportingApi.addAttributes([ 6 | { 7 | key: 'runner', 8 | value: 'cucumber', 9 | }, 10 | { 11 | value: 'when_attribute', 12 | }, 13 | ]); 14 | 15 | this.value = givenValue; 16 | }); 17 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/attributes/then.js: -------------------------------------------------------------------------------- 1 | const { Then } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require("@reportportal/agent-js-webdriverio"); 3 | const assert = require('assert'); 4 | 5 | Then('I should compare it with {string}', function (expectedValue) { 6 | ReportingApi.addAttributes([ 7 | { 8 | key: 'runner', 9 | value: 'cucumber', 10 | }, 11 | { 12 | value: 'then_attribute', 13 | }, 14 | ]); 15 | 16 | assert.strictEqual(this.value, expectedValue); 17 | }); 18 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/description/given.js: -------------------------------------------------------------------------------- 1 | const { Given } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | 4 | Given('I go to the website', async () => { 5 | ReportingApi.addAttributes([{ 6 | key: 'feature', 7 | value: 'description', 8 | }]); 9 | ReportingApi.setDescription('This is a **description** for `given step`'); 10 | await browser.url('https://www.google.com'); 11 | }); 12 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/description/then.js: -------------------------------------------------------------------------------- 1 | const { Then } = require('@cucumber/cucumber'); 2 | const assert = require('assert'); 3 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 4 | 5 | Then(/^I expect the title of the page "([^"]*)"$/, (title) => { 6 | ReportingApi.addAttributes([{ 7 | key: 'feature', 8 | value: 'description', 9 | }]); 10 | ReportingApi.setDescription('This is a **description** for `then step`'); 11 | 12 | assert.strictEqual(title, 'Google_2'); 13 | }); 14 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/logs/given.js: -------------------------------------------------------------------------------- 1 | const { Given } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | 4 | Given('I want add INFO log to step and TRACE log to launch', () => { 5 | ReportingApi.addAttributes([{ 6 | key: 'feature', 7 | value: 'logs', 8 | }]); 9 | ReportingApi.launchTrace('Launch TRACE log'); 10 | ReportingApi.info('Step INFO log'); 11 | ReportingApi.warn('Step WARN log'); 12 | }); 13 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/logs/then.js: -------------------------------------------------------------------------------- 1 | const { Then } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | const assert = require('assert'); 4 | 5 | Then('I want add FATAL log to step', () => { 6 | ReportingApi.addAttributes([{ 7 | key: 'feature', 8 | value: 'logs', 9 | }]); 10 | ReportingApi.info('Do some actions'); 11 | ReportingApi.fatal('FATAL log'); 12 | 13 | assert.strictEqual(true, false); 14 | }); 15 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/statuses/given.js: -------------------------------------------------------------------------------- 1 | const { Given } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | 4 | Given('I want change PASSED step status to INFO', () => { 5 | ReportingApi.addAttributes([{ 6 | key: 'feature', 7 | value: 'explicitLaunchStatus', 8 | }]); 9 | ReportingApi.setLaunchStatusStopped(); 10 | }); 11 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-cucumber/tests/stepDefinitions/statuses/then.js: -------------------------------------------------------------------------------- 1 | const { Then } = require('@cucumber/cucumber'); 2 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 3 | const assert = require('assert'); 4 | 5 | Then('I want change FAILED step status to PASSED', () => { 6 | ReportingApi.addAttributes([{ 7 | key: 'feature', 8 | value: 'explicitStatus', 9 | }]); 10 | ReportingApi.setStatusPassed(); 11 | 12 | assert.strictEqual(true, false); 13 | }); 14 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "wdio" 4 | }, 5 | "devDependencies": { 6 | "@reportportal/agent-js-webdriverio": "^5.1.1", 7 | "@wdio/cli": "^7.13.2", 8 | "@wdio/jasmine-framework": "^7.13.2", 9 | "@wdio/local-runner": "^7.13.2", 10 | "chromedriver": "*", 11 | "wdio-chromedriver-service": "^7.2.2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } 4 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | 6 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.jpg -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } 4 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.mp4 -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/example-webdriverio-jasmine/tests/attachments/test.png -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/attributes.spec.js: -------------------------------------------------------------------------------- 1 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 2 | 3 | describe('Provide attributes to the test', () => { 4 | ReportingApi.addAttributes( 5 | [ 6 | { 7 | key: 'runner', 8 | value: 'jasmine', 9 | }, 10 | { 11 | value: 'suite_attribute', 12 | }, 13 | ], 14 | 'Provide attributes to the test', 15 | ); 16 | 17 | it('Step with custom attributes', async () => { 18 | ReportingApi.addAttributes( 19 | [ 20 | { 21 | key: 'check', 22 | value: 'attributes', 23 | }, 24 | { 25 | value: 'custom_attribute', 26 | }, 27 | ], 28 | ); 29 | await browser.url('https://webdriver.io'); 30 | const title = await browser.getTitle(); 31 | 32 | expect(title).toBe( 33 | 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO', 34 | ); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/description.spec.js: -------------------------------------------------------------------------------- 1 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 2 | 3 | describe('Set description to the test', () => { 4 | ReportingApi.setDescription('Description from the test file', 'Set description to the test'); 5 | 6 | it('Check title', async () => { 7 | ReportingApi.addAttributes([{ 8 | key: 'feature', 9 | value: 'description', 10 | }]); 11 | ReportingApi.setDescription('Description from the test file'); 12 | await browser.url('https://webdriver.io'); 13 | const title = await browser.getTitle(); 14 | 15 | expect(title).toBe( 16 | 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO', 17 | ); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/foo.spec.js: -------------------------------------------------------------------------------- 1 | const {ReportingApi} = require('@reportportal/agent-js-webdriverio'); 2 | 3 | describe('Suite', () => { 4 | it('Test should be STOPPED instead of PASSED', async () => { 5 | ReportingApi.addAttributes([{ 6 | key: 'feature', 7 | value: 'explicitStatus', 8 | }]); 9 | ReportingApi.setStatusStopped(); 10 | await browser.url('https://webdriver.io'); 11 | const title = await browser.getTitle(); 12 | 13 | expect(title).toBe( 14 | 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO', 15 | ); 16 | }); 17 | 18 | xit('Test should be SKIPPED', async () => { 19 | await browser.url('https://webdriver.io'); 20 | const title = await browser.getTitle(); 21 | 22 | expect(title).toBe( 23 | 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO', 24 | ); 25 | }); 26 | 27 | it('Test should be FAILED', async () => { 28 | await browser.url('https://webdriver.io'); 29 | const title = await browser.getTitle(); 30 | await browser.saveScreenshot('./screenshots/screenshot.png'); 31 | 32 | expect(title).toBe( 33 | 'WebdriverIO', 34 | ); 35 | }); 36 | 37 | describe('should be type:TEST', () => { 38 | it('test should be FAILED', () => { 39 | expect(true).toBe(false); 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/logs.spec.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 4 | 5 | const attachments = [ 6 | { 7 | filename: 'test.jpg', 8 | type: 'image/jpg', 9 | }, 10 | { 11 | filename: 'test.png', 12 | type: 'image/png', 13 | }, 14 | { 15 | filename: 'test.html', 16 | type: 'application/html', 17 | }, 18 | { 19 | filename: 'test.json', 20 | type: 'application/json', 21 | }, 22 | { 23 | filename: 'test.css', 24 | type: 'application/css', 25 | }, 26 | { 27 | filename: 'test.mp4', 28 | type: 'video/mp4', 29 | }, 30 | ]; 31 | 32 | describe('Logs attaching. Launch, suite and tests with different logs', () => { 33 | ReportingApi.trace( 34 | 'suite TRACE message log', 35 | null, 36 | 'Logs attaching. Launch, suite and tests with different logs', 37 | ); 38 | ReportingApi.debug( 39 | 'suite DEBUG message log', 40 | null, 41 | 'Logs attaching. Launch, suite and tests with different logs', 42 | ); 43 | ReportingApi.info( 44 | 'suite INFO message log', 45 | null, 46 | 'Logs attaching. Launch, suite and tests with different logs', 47 | ); 48 | ReportingApi.warn( 49 | 'suite WARN message log', 50 | null, 51 | 'Logs attaching. Launch, suite and tests with different logs', 52 | ); 53 | ReportingApi.error( 54 | 'suite ERROR message log', 55 | null, 56 | 'Logs attaching. Launch, suite and tests with different logs', 57 | ); 58 | ReportingApi.fatal( 59 | 'suite FATAL message log', 60 | null, 61 | 'Logs attaching. Launch, suite and tests with different logs', 62 | ); 63 | 64 | it('test with message logs', () => { 65 | ReportingApi.addAttributes([{ 66 | key: 'feature', 67 | value: 'logs', 68 | }]); 69 | // launch logs 70 | ReportingApi.launchTrace('TRACE message log'); 71 | ReportingApi.launchDebug('DEBUG message log'); 72 | ReportingApi.launchInfo('INFO message log'); 73 | ReportingApi.launchWarn('WARN message log'); 74 | ReportingApi.launchError('ERROR message log'); 75 | ReportingApi.launchFatal('FATAL message log'); 76 | // test logs 77 | ReportingApi.trace('TRACE message log'); 78 | ReportingApi.debug('DEBUG message log'); 79 | ReportingApi.info('INFO message log'); 80 | ReportingApi.warn('WARN message log'); 81 | ReportingApi.error('ERROR message log'); 82 | ReportingApi.fatal('FATAL message log'); 83 | 84 | expect(true).toBe(true); 85 | }); 86 | 87 | it('test with attachments', async () => { 88 | ReportingApi.addAttributes([{ 89 | key: 'feature', 90 | value: 'logs with attachments', 91 | }]); 92 | const readFilesPromises = attachments.map( 93 | ({ filename, type }) => 94 | new Promise((resolve) => 95 | fs.readFile(path.resolve(__dirname, './attachments', filename), (err, data) => { 96 | if (err) { 97 | throw err; 98 | } 99 | const attachment = { 100 | name: filename, 101 | type, 102 | content: data.toString('base64'), 103 | }; 104 | ReportingApi.info('info log with attachment', attachment); 105 | resolve(); 106 | }), 107 | ), 108 | ); 109 | await Promise.all(readFilesPromises); 110 | 111 | expect(true).toBe(false); 112 | }); 113 | }); 114 | -------------------------------------------------------------------------------- /example-webdriverio/example-webdriverio-jasmine/tests/statuses.spec.js: -------------------------------------------------------------------------------- 1 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 2 | 3 | describe('Manual status attaching. Suite with STOPPED status', () => { 4 | ReportingApi.addAttributes([{ 5 | key: 'feature', 6 | value: 'explicitStatuses', 7 | }]); 8 | ReportingApi.setLaunchStatusInterrupted(); 9 | ReportingApi.setStatusStopped('Manual status attaching. Suite with STOPPED status'); 10 | 11 | it('Test with PASSED status', () => { 12 | ReportingApi.addAttributes([{ 13 | key: 'feature', 14 | value: 'explicitStatus', 15 | }]); 16 | ReportingApi.setStatusPassed(); 17 | 18 | expect(true).toBe(false); 19 | }); 20 | 21 | it('Test with FAILED status', () => { 22 | ReportingApi.addAttributes([{ 23 | key: 'feature', 24 | value: 'explicitStatus', 25 | }]); 26 | ReportingApi.setStatusFailed(); 27 | 28 | expect(true).toBe(true); 29 | }); 30 | 31 | it('Test with SKIPPED status', () => { 32 | ReportingApi.addAttributes([{ 33 | key: 'feature', 34 | value: 'explicitStatus', 35 | }]); 36 | ReportingApi.setStatusSkipped(); 37 | 38 | expect(true).toBe(true); 39 | }); 40 | 41 | it('Test with STOPPED status', () => { 42 | ReportingApi.addAttributes([{ 43 | key: 'feature', 44 | value: 'explicitStatus', 45 | }]); 46 | ReportingApi.setStatusStopped(); 47 | 48 | expect(true).toBe(true); 49 | }); 50 | 51 | it('Test with INTERRUPTED status', () => { 52 | ReportingApi.addAttributes([{ 53 | key: 'feature', 54 | value: 'explicitStatus', 55 | }]); 56 | ReportingApi.setStatusInterrupted(); 57 | 58 | expect(true).toBe(true); 59 | }); 60 | 61 | it('Test with CANCELLED status', () => { 62 | ReportingApi.addAttributes([{ 63 | key: 'feature', 64 | value: 'explicitStatus', 65 | }]); 66 | ReportingApi.setStatusCancelled(); 67 | 68 | expect(true).toBe(true); 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "wdio" 4 | }, 5 | "devDependencies": { 6 | "@reportportal/agent-js-webdriverio": "^5.1.1", 7 | "@wdio/cli": "^8.17.0", 8 | "@wdio/local-runner": "^8.17.0", 9 | "@wdio/mocha-framework": "^8.17.0", 10 | "chai": "^4.3.10", 11 | "chromedriver": "*", 12 | "wdio-chromedriver-service": "^8.1.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.css: -------------------------------------------------------------------------------- 1 | .header { 2 | border-bottom: 1px solid black; 3 | } -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
this is a test file
4 | 5 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.jpg -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "isReportPortalAwesome": true 3 | } -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.mp4 -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-js/55a2ee6788af7dbb65bf7d471a4ba94ecb287f1f/example-webdriverio/examples-webdriverio-mocha/tests/attachments/test.png -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/attributesTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 19 | 20 | describe('attributes for suite/test', () => { 21 | before(() => { 22 | ReportingApi.setDescription('This suite should have the correct suite attributes'); 23 | ReportingApi.addAttributes([ 24 | { 25 | key: 'suiteKeyOne', 26 | value: 'suiteValueOne', 27 | }, 28 | ]); 29 | ReportingApi.addAttributes([ 30 | { 31 | key: 'suiteKeyTwo', 32 | value: 'suiteValueTwo', 33 | }, 34 | { 35 | value: 'suiteValueThree', 36 | }, 37 | ]); 38 | }); 39 | 40 | it('should have the correct test attributes', async () => { 41 | ReportingApi.setDescription('This test should have the correct test attributes'); 42 | ReportingApi.addAttributes([ 43 | { 44 | key: 'testKey', 45 | value: 'testValue', 46 | }, 47 | { 48 | value: 'testValueTwo', 49 | }, 50 | ]); 51 | 52 | await browser.url('https://webdriver.io'); 53 | const title = await browser.getTitle(); 54 | 55 | expect(title).to.be.equal( 56 | 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO', 57 | ); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/descriptionsTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 19 | 20 | describe('description for suite/test', () => { 21 | before(() => { 22 | ReportingApi.setDescription('The description for the suite'); 23 | }); 24 | 25 | it('should have the correct description', async () => { 26 | ReportingApi.addAttributes([{ key: 'feature', value: 'description' }]); 27 | ReportingApi.setDescription('The description for the test'); 28 | 29 | await browser.url('https://webdriver.io'); 30 | 31 | const element = await $$('.navbar__link')[1]; 32 | await element.click(); 33 | 34 | await browser.waitUntil(async () => (await element.getAttribute('class')).includes('active')); 35 | const title = await browser.getTitle(); 36 | 37 | expect(title).to.be.equal('Introduction | WebdriverIO'); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/statusesTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | const expect = require('chai').expect; 17 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 18 | 19 | describe('populated statuses for launch/suite/test', () => { 20 | before(() => { 21 | ReportingApi.setLaunchStatusInfo(); 22 | ReportingApi.setStatusInfo(); 23 | }); 24 | 25 | it('should have status passed', () => { 26 | ReportingApi.setDescription('This test should have manually provided `Passed` status'); 27 | ReportingApi.addAttributes([ 28 | { 29 | key: 'feature', 30 | value: 'manualStatusPassed', 31 | }, 32 | ]); 33 | ReportingApi.setStatusPassed(); 34 | expect(true).to.be.false; 35 | }); 36 | 37 | it('should have status failed', () => { 38 | ReportingApi.setDescription('This test should have manually provided `Failed` status'); 39 | ReportingApi.addAttributes([ 40 | { 41 | key: 'feature', 42 | value: 'manualStatusFailed', 43 | }, 44 | ]); 45 | ReportingApi.setStatusFailed(); 46 | expect(true).to.be.true; 47 | }); 48 | 49 | it('should have status info', () => { 50 | ReportingApi.setDescription('This test should have manually provided `Info` status'); 51 | ReportingApi.addAttributes([ 52 | { 53 | key: 'feature', 54 | value: 'manualStatusInfo', 55 | }, 56 | ]); 57 | ReportingApi.setStatusInfo(); 58 | expect(true).to.be.true; 59 | }); 60 | 61 | it('should have the status warn', () => { 62 | ReportingApi.setDescription('This test should have manually provided `Warn` status'); 63 | ReportingApi.addAttributes([ 64 | { 65 | key: 'feature', 66 | value: 'manualStatusWarn', 67 | }, 68 | ]); 69 | ReportingApi.setStatusWarn(); 70 | expect(true).to.be.true; 71 | }); 72 | 73 | it('should have the status cancelled', () => { 74 | ReportingApi.setDescription('This test should have manually provided `Cancelled` status'); 75 | ReportingApi.addAttributes([ 76 | { 77 | key: 'feature', 78 | value: 'manualStatusCancelled', 79 | }, 80 | ]); 81 | ReportingApi.setStatusCancelled(); 82 | expect(true).to.be.true; 83 | }); 84 | 85 | it('should have the status interrupted', () => { 86 | ReportingApi.setDescription('This test should have manually provided `Interrupted` status'); 87 | ReportingApi.addAttributes([ 88 | { 89 | key: 'feature', 90 | value: 'manualStatusInterrupted', 91 | }, 92 | ]); 93 | ReportingApi.setStatusInterrupted(); 94 | expect(true).to.be.true; 95 | }); 96 | 97 | it('should have the status skipped', () => { 98 | ReportingApi.setDescription('This test should have manually provided `Skipped` status'); 99 | ReportingApi.addAttributes([ 100 | { 101 | key: 'feature', 102 | value: 'manualStatusSkipped', 103 | }, 104 | ]); 105 | ReportingApi.setStatusSkipped(); 106 | expect(true).to.be.true; 107 | }); 108 | 109 | it('should have the status stopped', () => { 110 | ReportingApi.setDescription('This test should have manually provided `Stopped` status'); 111 | ReportingApi.addAttributes([ 112 | { 113 | key: 'feature', 114 | value: 'manualStatusStopped', 115 | }, 116 | ]); 117 | ReportingApi.setStatusStopped(); 118 | expect(true).to.be.true; 119 | }); 120 | }); 121 | -------------------------------------------------------------------------------- /example-webdriverio/examples-webdriverio-mocha/tests/testCaseIdTest.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const expect = require('chai').expect; 18 | const { ReportingApi } = require('@reportportal/agent-js-webdriverio'); 19 | 20 | describe('testCaseId for suite/test', () => { 21 | before(() => { 22 | ReportingApi.setTestCaseId('TestCaseIdForTheSuite'); 23 | }); 24 | 25 | it('should have the explicit testCaseId', () => { 26 | ReportingApi.setDescription('This test case contains explicit test case id'); 27 | ReportingApi.addAttributes([ 28 | { 29 | key: 'feature', 30 | value: 'ExplicitTestCaseId', 31 | }, 32 | ]); 33 | ReportingApi.setTestCaseId('TestCaseIdForTheTest'); 34 | expect(true).to.be.true; 35 | }); 36 | 37 | it('should have the autogenerate testCaseId', () => { 38 | ReportingApi.setDescription('This test case contains automatically generated testcase id'); 39 | ReportingApi.addAttributes([ 40 | { 41 | key: 'feature', 42 | value: 'AutoGeneratedTestCaseId', 43 | }, 44 | ]); 45 | expect(true).to.be.true; 46 | }); 47 | }); 48 | --------------------------------------------------------------------------------