diff --git a/README.md b/README.md index 9e14a62..361bd13 100644 --- a/README.md +++ b/README.md @@ -1,754 +1,3 @@ # Zebrunner Playwright reporting agent To learn how to get started and explore available features, please refer to the official Zebrunner Playwright agent [documentation](https://zebrunner.com/documentation/reporting/playwright/) for more information. - -## Inclusion into your project - -### Adding dependency - -First, you need to add the Zebrunner Agent into your `package.json`. - -=== "NPM" - - ```shell - npm install @zebrunner/javascript-agent-playwright - ``` - -=== "Yarn" - - ```shell - yarn add @zebrunner/javascript-agent-playwright - ``` - -### Reporter setup - -The agent does not work automatically after adding it into the project, it requires extra configuration. -For this, you need to navigate to the Playwright configuration file (by default, it is `playwright.config.ts`) and provide the following information: - -- Add `@zebrunner/javascript-agent-playwright` to the list of reporters; -- Provide the reporter configuration (you can find more about the configuration in the [Reporter configuration section](#reporter-configuration) ). - -The reporter must be specified in a nested array. The first array element is `@zebrunner/javascript-agent-playwright`, the second element is a reporter configuration object. - -Here is an example of a configuration snippet: - -```ts title="playwright.config.ts" -export default defineConfig({ - testDir: './tests', - reporter: [ - [ - '@zebrunner/javascript-agent-playwright', - { - // Zebrunner reporter configuration - enabled: true, - // ... - }, - ], - ], -}); -``` - -## Reporter configuration - -Once the agent is added into your project, it is **not** automatically enabled. The valid configuration must be provided first. - -It is currently possible to provide the configuration via: - -1. Environment variables -2. Playwright config (`playwright.config.ts` file) - -The configuration lookup will be performed in the order listed above, meaning that environment configuration will always take precedence over `playwright.config.ts` file. As a result, it is possible to override configuration parameters by passing them through a configuration mechanism with higher precedence. - -### Configuration options - -The following subsections contain tables with configuration options. The first column in these tables contains the name of the option. It is represented as an environment variable (the first value) and as a reporter config property from `playwright.config.ts` file (the second value). The second column contains description of the configuration option. - -#### Common configuration - -| Env var / Reporter config | Description | -| -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_ENABLED`
`enabled` | Enables or disables reporting. The default value is `false`. If disabled, agent provides output only to console. | -| `REPORTING_PROJECT_KEY`
`projectKey` | Optional value. It is the key of Zebrunner project that the launch belongs to. The default value is `DEF`. | -| `REPORTING_SERVER_HOSTNAME`
`server.hostname` | Mandatory if reporting is enabled. It is your Zebrunner hostname, e.g. `https://mycompany.zebrunner.com`. | -| `REPORTING_SERVER_ACCESS_TOKEN`
`server.accessToken` | Mandatory if reporting is enabled. The access token is used to perform API calls. It can be obtained in Zebrunner on the 'Account and profile' page in the 'API Access' section. | - -#### Automation launch configuration - -The following configuration options allow you to configure accompanying information that will be displayed in Zebrunner for the automation launch. - -| Env var / Reporter config | Description | -| ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_LAUNCH_DISPLAY_NAME`
`launch.displayName` | Display name of the launch in Zebrunner. The default value is `Default Suite`. | -| `REPORTING_LAUNCH_BUILD`
`launch.build` | Build number associated with the launch. It can reflect either the test build number or the build number of the application under test. | -| `REPORTING_LAUNCH_ENVIRONMENT`
`launch.environment` | Represents the target environment in which the tests were run. For example, `stage` or `prod`. | -| `REPORTING_LAUNCH_LOCALE`
`launch.locale` | Locale that will be displayed for the automation launch in Zebrunner. For example, `en_US`. | -| `REPORTING_LAUNCH_TREAT_SKIPS_AS_FAILURES`
`launch.treatSkipsAsFailures` | If the value is set to true, skipped tests will be treated as failures when the result of the entire launch is calculated. For example, launch with all passed tests but one skipped will be considered a failure. The default value is true. | - -#### Test logs - -Zebrunner provides log capabilities for automation launch test results. The following options configure log rules. - -| Env var / Reporter config | Description | -| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_LOGS_IGNORE_PLAYWRIGHT_STEPS`
`logs.ignorePlaywrightSteps` | Determines whether the agent should ignore test steps collected by Playwright when sending logs to Zebrunner. The default value is `false`. If ignored, only custom logs will be displayed, eliminating the option to retrieve lines from the test source code. | -| `REPORTING_LOGS_USE_LINES_FROM_SOURCE_CODE`
`logs.useLinesFromSourceCode` | Determines whether the agent should replace Playwright step names with real lines from test source code when sending logs to Zebrunner. The default value is `true`. | -| `REPORTING_LOGS_IGNORE_CONSOLE`
`logs.ignoreConsole` | Determines whether the agent should ignore `console.log()`'s from test source code when sending logs to Zebrunner. The default value is `false`. | -| `REPORTING_LOGS_IGNORE_MANUAL`
`logs.ignoreCustom` | Determines whether the agent should ignore logs added to test manually with `CurrentTest.attachLog()` when sending logs to Zebrunner. The default value is `false`. | -| `REPORTING_LOGS_IGNORE_CUSTOM_SCREENSHOTS`
`logs.ignoreManualScreenshots` | Determines whether the agent should ignore screenshots attached with `CurrentTest.attachScreenshot()` when sending logs to Zebrunner. The default value is `false`. | -| `REPORTING_LOGS_IGNORE_AUTO_SCREENSHOTS`
`logs.ignoreAutoScreenshots` | Determines whether the agent should ignore screenshots that are automatically collected and attached to test by Playwright when sending logs to Zebrunner. The default value is `false`. | - -#### Milestone - -Zebrunner Milestone for the automation launch can be configured using the following configuration options (all of them are optional). - -| Env var / Reporter config | Description | -| ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_MILESTONE_ID`
`milestone.id` | Id of the Zebrunner Milestone to link the automation launch to. The id is not displayed on Zebrunner UI, so the field is basically used for internal purposes. If the milestone does not exist, the launch will continue executing. | -| `REPORTING_MILESTONE_NAME`
`milestone.name` | Name of the Zebrunner Milestone to link the automation launch to. If the milestone does not exist, the appropriate warning message will be displayed in logs, but the test suite will continue executing. | - -#### Notifications - -Zebrunner provides notification capabilities for automation launch results. The following options configure notification rules and targets. - -| Env var / Reporter config | Description | -| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `REPORTING_NOTIFICATION_NOTIFY_ON_EACH_FAILURE`
`notifications.notifyOnEachFailure` | Specifies whether Zebrunner should send notifications to Slack/Teams on each test failure. The notifications will be sent even if the launch is still running. The default value is `false`. | -| `REPORTING_NOTIFICATION_SLACK_CHANNELS`
`notifications.slackChannels` | A comma-separated list of Slack channels to send notifications to. Notifications will be sent only if the Slack integration is properly configured in Zebrunner with valid credentials for the project the launch is reported to. Zebrunner can send two types of notifications: on each test failure (if the appropriate property is enabled) and on the launch finish. | -| `REPORTING_NOTIFICATION_MS_TEAMS_CHANNELS`
`notifications.teamsChannels` | A comma-separated list of Microsoft Teams channels to send notifications to. Notifications will be sent only if the Teams integration is configured in the Zebrunner project with valid webhooks for the channels. Zebrunner can send two types of notifications: on each test failure (if the appropriate property is enabled) and on the launch finish. | -| `REPORTING_NOTIFICATION_EMAILS`
`notifications.emails` | A comma-separated list of emails to send notifications to. This type of notifications does not require further configuration on Zebrunner side. Unlike other notification mechanisms, Zebrunner can send emails only on the launch finish. | - -#### Integration with Test Case Management systems - -Zebrunner integrates with different Test Case Management (TCM) systems and provides the following capabilities: - -1. Linking test cases to test executions -2. Previewing linked test cases in Zebrunner -3. Pushing test execution results to the TCM system - -This functionality is currently supported only for Zebrunner Test Case Management, TestRail, Xray, Zephyr Squad and Zephyr Scale. - -The link between execution of a test method and corresponding test cases can only be set from within the test method code. For more information about this, see the [Linking test cases to test executions](#linking-test-cases-to-test-executions) section. - -If you want to push the execution results to the TCM system, you need to provide additional configuration for the Agent. For all the supported TCMs, Zebrunner can push results to a pre-created test suite execution (this term has a different name in different systems). For TestRail, you can also create a new Test Run based on the Agent configuration and push the results into it. If enabled, the push can be performed either at the end of the whole launch, or in real time after each test. - -The following subsection covers how to provide configuration for pushing results to each of the TCM systems. - -##### Zebrunner Test Case Management (TCM) - -| Env var / Reporter config | Description | -| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_TCM_ZEBRUNNER_PUSH_RESULTS`
`tcm.zebrunner.pushResults` | Boolean value which specifies if the execution results should be pushed to Zebrunner TCM. The default value is `false`. | -| `REPORTING_TCM_ZEBRUNNER_PUSH_IN_REAL_TIME`
`tcm.zebrunner.pushInRealTime` | Boolean value. Specifies whether to push execution results immediately after each test is finished (value `true`) or not (value `false`). The default value is `false`. | -| `REPORTING_TCM_ZEBRUNNER_TEST_RUN_ID`
`tcm.zebrunner.testRunId` | Numeric id of the target Test Run in Zebrunner TCM. If a value is not provided, no new runs will be created. | - -##### TestRail - -| Env var / Reporter config | Description | -| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `REPORTING_TCM_TESTRAIL_PUSH_RESULTS`
`tcm.testRail.pushResults` | Boolean value which specifies if the execution results should be pushed to TestRail. The default value is `false`. | -| `REPORTING_TCM_TESTRAIL_PUSH_IN_REAL_TIME`
`tcm.testRail.pushInRealTime` | Boolean value. Specifies whether to push execution results immediately after each test is finished (value `true`) or not (value `false`). The default value is `false`. Enabling of this option forces the `includeAllTestCasesInNewRun` to be `true`. | -| `REPORTING_TCM_TESTRAIL_SUITE_ID`
`tcm.testRail.suiteId` | Specifies the numeric id of the TestRail Suite in which the tests reside. TestRail displays the ids prefixed with 'S' letter. You need to provide the id without this letter. | -| `REPORTING_TCM_TESTRAIL_RUN_ID`
`tcm.testRail.runId` | The id of the TestRail Test Run where the results should be pushed. TestRail displays the ids prefixed with 'R' letter. You need to provide the id without this letter. | -| `REPORTING_TCM_TESTRAIL_RUN_NAME`
`tcm.testRail.runName` | Specifies the name of a new Test Run in TestRail. If push is enabled and run id is not provided, Zebrunner will create a new run in TestRail. If the value is not provided, Zebrunner will use the launch display name. | -| `REPORTING_TCM_TESTRAIL_INCLUDE_ALL_IN_NEW_RUN`
`tcm.testRail.includeAllTestCasesInNewRun` | If the value is set to `true`, all cases from the Suite will be added to the newly created Test Run. The value is forced to be `true` if real-time push is enabled. Default value is `false`. | -| `REPORTING_TCM_TESTRAIL_MILESTONE_NAME`
`tcm.testRail.milestoneName` | The newly created Test Run will be associated with the milestone specified using this property. | -| `REPORTING_TCM_TESTRAIL_ASSIGNEE`
`tcm.testRail.assignee` | Assignee of the newly created Test Run. The value should be the email of an existing TestRail user. | - -##### Xray - -| Env var / Reporter config | Description | -| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_TCM_XRAY_PUSH_RESULTS`
`tcm.xray.pushResults` | Boolean value which specifies if the execution results should be pushed to Xray. The default value is `false`. | -| `REPORTING_TCM_XRAY_PUSH_IN_REAL_TIME`
`tcm.xray.pushInRealTime` | Boolean value. Specifies whether to push execution results immediately after each test is finished (value `true`) or not (value `false`). The default value is `false`. | -| `REPORTING_TCM_XRAY_EXECUTION_KEY`
`tcm.xray.executionKey` | The key of the Xray Execution where the results should be pushed. | - -##### Zephyr - -| Env var / Reporter config | Description | -| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REPORTING_TCM_ZEPHYR_PUSH_RESULTS`
`tcm.zephyr.pushResults` | Boolean value which specifies if the execution results should be pushed to Zephyr. The default value is `false`. | -| `REPORTING_TCM_ZEPHYR_PUSH_IN_REAL_TIME`
`tcm.zephyr.pushInRealTime` | Boolean value. Specifies whether to push execution results immediately after each test is finished (value `true`) or not (value `false`). The default value is `false`. | -| `REPORTING_TCM_ZEPHYR_JIRA_PROJECT_KEY`
`tcm.zephyr.jiraProjectKey` | Specifies the key of the Jira project where the tests reside. | -| `REPORTING_TCM_ZEPHYR_TEST_CYCLE_KEY`
`tcm.zephyr.testCycleKey` | The key of the Zephyr Test Cycle where the results should be pushed. | - -##### Custom Result Statuses - -By default, when the execution results are being pushed to a TCM system, Zebrunner maps each test execution result to an appropriate result status in the target TCM system. Most of the time this works perfectly, but in some cases Zebrunner is not able to derive the appropriate target result status. - -One of the examples of such cases is when a test case result status does not correlate with the test execution status, or when you have conditional logic determining the actual result status for the test case. For such cases, the Agent comes with a special method which sets a specific Result Status to the test case. For more information about this, see the [Linking test cases to test executions](#linking-test-cases-to-test-executions) section. - -Another example is custom Result Statuses in the target TCM system. In this case, we cannot anticipate the correct status and simply skip the test execution. In order to tackle this, Zebrunner allows you to configure default status for passed and failed test executions. - -| Env var / Reporter config | Description | -| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- | -| `REPORTING_TCM_TEST_CASE_STATUS_ON_PASS`
`tcm.testCaseStatus.onPass` | The default status that will be assigned to passed test executions when they are pushed to a TCM system. | -| `REPORTING_TCM_TEST_CASE_STATUS_ON_FAIL`
`tcm.testCaseStatus.onFail` | The default status that will be assigned to failed test executions when they are pushed to a TCM system. | -| `REPORTING_TCM_TEST_CASE_STATUS_ON_SKIP`
`tcm.testCaseStatus.onSkip` | The default status that will be assigned to skipped test executions when they are pushed to a TCM system. | - -When pushing results to a TCM system, Zebrunner derives the Result Status in the following order: - -1. Checks the explicitly assigned value (which was assigned using the `testCaseStatus()` method). -2. Takes the default status provided via configuration for passed and/or failed tests. -3. Uses internal mapping of Zebrunner statuses to the Result Statuses of the target TCM system. - -### Examples - -#### Environment Variables - -The following code snippet is a list of all configuration environment variables from `.env` file: - -```text - REPORTING_ENABLED=TRUE - REPORTING_PROJECT_KEY=DEF - REPORTING_SERVER_HOSTNAME=https://mycompany.zebrunner.com - REPORTING_SERVER_ACCESS_TOKEN=somesecretaccesstoken - - REPORTING_LAUNCH_DISPLAY_NAME=Nightly Regression - REPORTING_LAUNCH_BUILD=2.41.2.2431-SNAPSHOT - REPORTING_LAUNCH_ENVIRONMENT=QA - REPORTING_LAUNCH_LOCALE=en_US - REPORTING_LAUNCH_TREAT_SKIPS_AS_FAILURES=TRUE - - REPORTING_LOGS_IGNORE_PLAYWRIGHT_STEPS=FALSE - REPORTING_LOGS_USE_LINES_FROM_SOURCE_CODE=TRUE - REPORTING_LOGS_IGNORE_CONSOLE=FALSE - REPORTING_LOGS_IGNORE_MANUAL=FALSE - REPORTING_LOGS_IGNORE_CUSTOM_SCREENSHOTS=FALSE - REPORTING_LOGS_IGNORE_AUTO_SCREENSHOTS=FALSE - - REPORTING_MILESTONE_ID=1 - REPORTING_MILESTONE_NAME=Release 1.0.0 - - REPORTING_NOTIFICATION_NOTIFY_ON_EACH_FAILURE=FALSE - REPORTING_NOTIFICATION_SLACK_CHANNELS=dev,qa - REPORTING_NOTIFICATION_MS_TEAMS_CHANNELS=dev-channel,management - REPORTING_NOTIFICATION_EMAILS=manager@mycompany.com - - REPORTING_TCM_TEST_CASE_STATUS_ON_PASS=PASS - REPORTING_TCM_TEST_CASE_STATUS_ON_FAIL=FAIL - REPORTING_TCM_TEST_CASE_STATUS_ON_SKIP=SKIP - - REPORTING_TCM_ZEBRUNNER_PUSH_RESULTS=FALSE - REPORTING_TCM_ZEBRUNNER_PUSH_IN_REAL_TIME=TRUE - REPORTING_TCM_ZEBRUNNER_TEST_RUN_ID=42 - - REPORTING_TCM_TESTRAIL_PUSH_RESULTS=FALSE - REPORTING_TCM_TESTRAIL_PUSH_IN_REAL_TIME=TRUE - REPORTING_TCM_TESTRAIL_SUITE_ID=100 - REPORTING_TCM_TESTRAIL_RUN_ID=500 - REPORTING_TCM_TESTRAIL_INCLUDE_ALL_IN_NEW_RUN=TRUE - REPORTING_TCM_TESTRAIL_RUN_NAME=New Demo Run - REPORTING_TCM_TESTRAIL_MILESTONE_NAME=Demo Milestone - REPORTING_TCM_TESTRAIL_ASSIGNEE=tester@mycompany.com - - REPORTING_TCM_XRAY_PUSH_RESULTS=FALSE - REPORTING_TCM_XRAY_PUSH_IN_REAL_TIME=TRUE - REPORTING_TCM_XRAY_EXECUTION_KEY=QT-100 - - REPORTING_TCM_ZEPHYR_PUSH_RESULTS=FALSE - REPORTING_TCM_ZEPHYR_PUSH_IN_REAL_TIME=TRUE - REPORTING_TCM_ZEPHYR_JIRA_PROJECT_KEY=ZEB - REPORTING_TCM_ZEPHYR_TEST_CYCLE_KEY=ZEB-T1 -``` - -#### Configuration file - -Below you can see an example of the full configuration provided via `playwright.config.ts` file: - -```ts title="playwright.config.ts" -export default defineConfig({ - testDir: './tests', - reporter: [ - [ - '@zebrunner/javascript-agent-playwright', - { - enabled: true, - projectKey: 'DEF', - server: { - hostname: 'https://mycompany.zebrunner.com', - accessToken: 'someSecretAccessToken', - }, - launch: { - displayName: 'Playwright launch', - build: '1.0.0', - environment: 'Local', - locale: 'en_US', - treatSkipsAsFailures: true, - }, - logs: { - ignorePlaywrightSteps: false, - useLinesFromSourceCode: true, - ignoreConsole: false, - ignoreCustom: false, - ignoreManualScreenshots: false, - ignoreAutoScreenshots: false, - }, - milestone: { - id: null, - name: null, - }, - notifications: { - notifyOnEachFailure: false, - slackChannels: 'dev, qa', - teamsChannels: 'dev-channel, management', - emails: 'name@company.com', - }, - tcm: { - testCaseStatus: { - onPass: 'SUCCESS', - onFail: 'FAILED', - }, - zebrunner: { - pushResults: false, - pushInRealTime: false, - testRunId: 42, - }, - testRail: { - pushResults: false, - pushInRealTime: false, - suiteId: 100, - runId: 500, - includeAllTestCasesInNewRun: true, - runName: 'New Demo Run', - milestoneName: 'Demo Milestone', - assignee: 'tester@mycompany.com', - }, - xray: { - pushResults: false, - pushInRealTime: false, - executionKey: 'QT-100', - }, - zephyr: { - pushResults: false, - pushInRealTime: false, - jiraProjectKey: 'ZEB', - testCycleKey: 'ZEB-T1', - }, - }, - }, - ], - ], -}); -``` - -## Collecting screenshots - -It is highly recommended to add following additional configuration to your `playwright.config.ts` config file: - -- enable taking screenshots on failure feature that will allow to send them into Zebrunner: - -```ts title="playwright.config.ts" -use: { - screenshot: 'only-on-failure'; -} -``` - -[//]: # 'FIXME: when video/trace is on, launch is hang up, necessary to fix' -[//]: # '- enable capturing of a video and trace - will be attached as artifacts' -[//]: # -[//]: # '```ts title="playwright.config.ts"' -[//]: # ' use: {' -[//]: # " screenshot: 'only-on-failure'," -[//]: # " video: 'on'," -[//]: # " trace: 'on'," -[//]: # ' },' -[//]: # '```' - -- enable detection of `browser` and `os` settings that will be sent to Zebrunner: - -```ts title="playwright.config.ts" -projects: [ - ... - { - name: 'webkit', - use: { ...devices['Desktop Safari'] } - }, - ... -] -``` - -You may want to create screenshots manually during test execution. In this case you need to attach screenshot using the `attachScreenshot()` method of the `CurrentTest` object. This method accept `path` on disk or `Buffer` instance as a parameter and should be used in scope of the test method. Attached screenshot will be uploaded to `Zebrunner` after test execution along with screenshots collected by `Playwright` automatically. - -```ts -import { CurrentTest } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test suite', () => { - test('some test name', async ({ page }, testInfo) => { - // ... - CurrentTest.attachScreenshot(await page.screenshot()); - // ... - CurrentTest.attachScreenshot('./some_folder/some_image.png'); - // ... - }); -}); -``` - -## Tracking test maintainer - -You may want to add transparency to the process of automation maintenance by having an engineer responsible for evolution of specific tests or test suites. To serve that purpose, Zebrunner comes with a concept of a maintainer. - -In order to keep track of those, the Agent comes with the `setMaintainer()` method of the `CurrentTest` object. This method accepts the username of an existing Zebrunner user. If there is no user with the given username, `anonymous` will be assigned. - -```ts -import { CurrentTest } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test suite', () => { - test('first test', async ({ page }) => { - CurrentTest.setMaintainer('developer'); - // ... - }); - - test('second test', async ({ page }) => { - CurrentTest.setMaintainer('tester'); - // ... - }); -}); -``` - -In this example, `developer` will be reported as a maintainer of `first test` , while `tester` will be reported as a maintainer of the `second test`. - -## Attaching labels - -In some cases, it may be useful to attach meta information related to a test. The agent comes with a concept of labels. Label is a simple key-value pair. - -### Attaching label to test using test name - -You can attach labels by writing them in the name of the test through `@`: - -```ts -test('test running in Firefox @ff @smoke_test @slow', async ({ page }, testInfo) => { - const browser = await firefox.launch(); - const page1 = await browser.newPage(); - await page1.goto('https://example.com'); - await browser.close(); -}); -``` - -After test execution, labels with `tag` key and `ff`, `smoke_test`, `slow` values will be added to the specific test. - -### Attaching label to test or entire run using attachLabel agent method - -To attach a label to a test, you need to invoke the `attachLabel` method of the `CurrentTest` object in scope of the test method. To attach label to the entire launch, you can either invoke the `attachLabel` method of the `CurrentLaunch` object. - -The `attachLabel()` method accepts the `key` as first argument and `values` starting from the second argument. - -```ts -import { CurrentTest, CurrentLaunch } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test suite', () => { - test.beforeAll(async () => { - // will be attached to the entire run - CurrentLaunch.attachLabel('label', 'value'); - }); - - test('first test', async ({ page }) => { - CurrentTest.attachLabel('tag', 'ff'); - // ... - }); - - test('second test', async ({ page }) => { - CurrentTest.attachLabel('customLabelName', 'smoke_test', 'slow'); - // ... - }); -}); -``` - -#### In this example: - -Label with `label` key and `value` value will be added to entire run. - -Label with `tag` key and `ff` value will be added to `first test`. - -Labels with `customLabelName` key, `smoke_test` and `slow` values will be added to `second test`. - -## Adding custom log to test - -You may want to add custom test logs displayed in Zebrunner. - -The Agent comes with the `attachLog()` method of the `CurrentTest` object. This method accepts the `message` as first parameter, `level` (optional) as second parameter and should be used in the scope of the test method. Valid values for `level` are `'INFO' | 'ERROR' | 'WARN' | 'FATAL' | 'DEBUG' | 'TRACE'` or custom `string`, default is `'INFO'`. - -```ts -import { CurrentTest } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test suite', () => { - test('first test', async ({ page }) => { - CurrentTest.attachLog('INFO level log message on test start'); - // ... - - CurrentTest.attachLog('INFO level log message', 'INFO'); - CurrentTest.attachLog('ERROR level log message', 'ERROR'); - CurrentTest.attachLog('WARN level log message', 'WARN'); - CurrentTest.attachLog('FATAL level log message', 'FATAL'); - CurrentTest.attachLog('DEBUG level log message', 'DEBUG'); - CurrentTest.attachLog('TRACE level log message', 'TRACE'); - - CurrentTest.attachLog('CUSTOM string level log message', 'CUSTOM'); - // ... - }); -}); -``` - -In this example, logs with specified levels be applied to `first test` and visible in `Zebrunner` along with other logs collected by Playwright. - -## Attaching artifact references to test and launch - -Labels are not the only option for attaching meta information to test and launch. If the information you want to attach is a link (to a file or webpage), it is more useful to attach it as an artifact reference (or to put it simply as a link). - -The `attachArtifactReference` methods of the `CurrentTest` and `CurrentLaunch` objects serve exactly this purpose. These methods accept two arguments. The first one is the artifact reference name which will be shown in Zebrunner. The second one is the artifact reference value. - -```ts -import { CurrentTest, CurrentLaunch } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test Suite', () => { - test.beforeAll(async () => { - // will be attached to the entire run - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); - }); - - test('first test', async ({ page }) => { - // will be attached to 'important test' only - CurrentTest.attachArtifactReference('SUT', 'https://myapp.com/app'); - // ... - }); -}); -``` - -## Attaching artifacts to test and launch - -In case your tests or the entire launch produce some artifacts, it may be useful to track them in Zebrunner. The agent comes with convenient methods for uploading artifacts in Zebrunner and linking them to the currently running test or the launch. - -The `attachArtifact` method of the `CurrentTest` and `CurrentLaunch` objects serve exactly this purpose. This method accept two arguments. The first one is the artifact `path` on disk or `Buffer` instance. The second one is the artifact `name` which will be shown in Zebrunner. The `name` is optional. - -```ts -import * as fs from 'fs'; -import { CurrentTest, CurrentLaunch } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test Suite', () => { - test.beforeAll(async () => { - // will be attached to the entire run and named "some_text_file1.txt" - CurrentLaunch.attachArtifact('./some_folder/some_text_file1.txt'); - // ... - - // will be attached to the entire run and named "text1.txt" - CurrentLaunch.attachArtifact('./some_folder/some_text_file1.txt', 'text1.txt'); - // ... - }); - - test('first test', async ({ page }) => { - // will be attached to 'first test' only and named "some_text_file1.txt" - CurrentTest.attachArtifact('./some_folder/some_text_file1.txt'); - // ... - - // will be attached to 'first test' only and named "custom_log.txt" - const bufferFileOne = fs.readFileSync('./my_project/custom_log.txt'); - CurrentTest.attachArtifact(bufferFileOne, 'custom_log.txt'); - // ... - - // will be attached to 'first test' only and named "file_{someISODate}" - const bufferFileTwo = fs.readFileSync('./my_project/custom_log.txt'); - CurrentTest.attachArtifact(bufferFileTwo); - // ... - }); -}); -``` - -## Reverting test registration - -In some cases, it might be handy not to register test executions in Zebrunner. This may be caused by very special circumstances of a test environment or execution conditions. - -Zebrunner Agent comes with a convenient method `revertRegistration()` of the `CurrentTest` object for reverting test registration at runtime. The following code snippet shows a case where test is not reported on Monday. - -```ts -import { CurrentTest } from '@zebrunner/javascript-agent-playwright'; - -test.describe('Test Suite', () => { - test('not important test', async ({ page }) => { - if (new Date().getDay() === 1) { - currentTest.revertRegistration(); - } - // test code - }); -}); -``` - -It is worth mentioning that the method invocation does not affect the test execution, but simply unregisters the test in Zebrunner instead of finishing it. To interrupt the test execution, you need to do additional actions, for example, throw an Error. - -## Linking test cases to test executions - -Note: to learn more about pushing results to a TCM system, see the [Integration with Test Case Management systems](#integration-with-test-case-management-systems) section. - -### Zebrunner TCM - -The Agent comes with the `zebrunner` object which contains methods to link test cases to a currently executing test: - -- `testCaseKey(...testCaseKeys)` — accepts a list of test cases which should be linked to the current test; -- `testCaseStatus(testCaseKey, resultStatus)` — links one test case and provides\overrides its result status. This may be useful if the test case result status does not correlate with the test execution status or if you have conditional logic determining the actual result status for the test case. - -If these methods are invoked for the same test case id many times within a test method, the last invocation will take precedence. For example, if you invoke the `testCaseStatus('KEY-1', 'SKIPPED')` first, and then invoke the `testCaseKey('KEY-1')`, then the result status you provided in the first invocation will be ignored. - -Here is an example: - -```js -import { zebrunner } from '@zebrunner/javascript-agent-playwright'; - -describe('Test Suite', () => { - it('first test', () => { - // links single test case 'KEY-1000' to the test - zebrunner.testCaseKey('KEY-1000'); - // test code - }); - - it('second test', () => { - // links test cases 'KEY-2000' and 'KEY-2001' to the current test - zebrunner.testCaseKey('KEY-2000', 'KEY-2001'); - // test code - }); - - it('third test', () => { - // links test case 'KEY-3000' to the current test - zebrunner.testCaseKey('KEY-3000'); - // test code - if (someCondition) { - // overriddes the status of the test case when results are pushed to the Zebrunner TCM. - // using this method, you can manually specify the desired result status. - zebrunner.testCaseStatus('KEY-3000', 'SKIPPED'); - } - }); -}); -``` - -### TestRail - -The Agent comes with the `testRail` object which contains methods to link test cases to a currently executing test: - -- `testCaseId(...testCaseIds)` — accepts a list of test cases which should be linked to current test; -- `testCaseStatus(testCaseId, resultStatus)` — links one test case and provides\overrides its result status. This may be useful if the test case result status does not correlate with the test execution status, or if you have conditional logic determining the actual result status for the test case. - -If these methods are invoked for the same test case id many times within a test method, the last invocation will take precedence. For example, if you invoke the `testCaseStatus('C1', 'SKIPPED')` first and then invoke the `testCaseId('C1')`, then the result status you provided in the first invocation will be ignored. - -Here is an example: - -```js -import { testRail } from '@zebrunner/javascript-agent-playwright'; - -describe('Test Suite', () => { - it('first test', () => { - // links single test case 'C1002' to the test - testRail.testCaseId('C1000'); - // test code - }); - - it('second test', () => { - // links test cases 'C2000' and 'C2001' to the current test - testRail.testCaseId('C2000', 'C2001'); - // test code - }); - - it('third test', () => { - // links test case 'C3000' to the current test - testRail.testCaseId('C3000'); - // test code - if (someCondition) { - // overriddes the status of the test case when results are pushed to the TestRail. - // by default Zebrunner maps the test execution result to a result status from TestRail. - // using this method, you can manually specify the desired result status. - testRail.testCaseStatus('C3000', 'SKIPPED'); - } - }); -}); -``` - -### Xray - -The Agent comes with the `xray` object which contains methods to link test cases to a currently executing test: - -- `testCaseKey(...testCaseKeys)` — accepts a list of test cases which should be linked to current test; -- `testCaseStatus(testCaseKey, resultStatus)` — links one test case and provides\overrides its result status. This may be useful if the test case result status does not correlate with the test execution status, or if you have conditional logic determining the actual result status for the test case. - -If these methods are invoked for the same test case id many times within a test method, the last invocation will take precedence. For example, if you invoke the `testCaseStatus('KEY-1', 'SKIP')` first, and then invoke the `testCaseKey('KEY-1')`, then the result status you provided in the first invocation will be ignored. - -Here is an example: - -```js -import { xray } from '@zebrunner/javascript-agent-playwright'; - -describe('Test Suite', () => { - it('first test', () => { - // links single test case 'KEY-1000' to the test - xray.testCaseKey('KEY-1000'); - // test code - }); - - it('second test', () => { - // links test cases 'KEY-2000' and 'KEY-2001' to the current test - xray.testCaseKey('KEY-2000', 'KEY-2001'); - // test code - }); - - it('third test', () => { - // links test case 'KEY-3000' to the current test - xray.testCaseKey('KEY-3000'); - // test code - if (someCondition) { - // overriddes the status of the test case when results are pushed to the Xray. - // by default Zebrunner maps the test execution result to a result status from Xray. - // using this method, you can manually specify the desired result status. - xray.testCaseStatus('KEY-3000', 'SKIP'); - } - }); -}); -``` - -### Zephyr - -The Agent comes with the `zephyr` object which contains methods to link test cases to a currently executing test: - -- `testCaseKey(...testCaseKeys)` — accepts a list of test cases which should be linked to current test; -- `testCaseStatus(testCaseKey, resultStatus)` — links one test case and provides\overrides its result status. This may be useful if the test case result status does not correlate with the test execution status, or if you have conditional logic determining the actual result status for the test case. - -If these methods are invoked for the same test case id many times within a test method, the last invocation will take precedence. For example, if you invoke the `testCaseStatus('KEY-1', 'SKIP')` first, and then invoke the `testCaseKey('KEY-1')`, then the result status you provided in the first invocation will be ignored. - -Here is an example: - -```js -import { zephyr } from '@zebrunner/javascript-agent-playwright'; - -describe('Test Suite', () => { - it('first test', () => { - // links single test case 'KEY-1000' to the test - zephyr.testCaseKey('KEY-1000'); - // test code - }); - - it('second test', () => { - // links test cases 'KEY-2000' and 'KEY-2001' to the current test - zephyr.testCaseKey('KEY-2000', 'KEY-2001'); - // test code - }); - - it('third test', () => { - // links test case 'KEY-3000' to the current test - zephyr.testCaseKey('KEY-3000'); - // test code - if (someCondition) { - // overriddes the status of the test case when results are pushed to the Zephyr. - // by default Zebrunner maps the test execution result to a result status from Zephyr. - // using this method, you can manually specify the desired result status. - zephyr.testCaseStatus('KEY-3000', 'SKIP'); - } - }); -}); -``` - -## Contribution - -To check out the project and build from the source, do the following: - -``` -git clone https://github.com/zebrunner/javascript-agent-playwright.git -cd javascript-agent-playwright -``` - -## License - -Zebrunner reporting agent for Playwright is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0). diff --git a/build/javascript-agent-playwright/CurrentLaunch.js b/build/javascript-agent-playwright/CurrentLaunch.js index be4b746..8538659 100644 --- a/build/javascript-agent-playwright/CurrentLaunch.js +++ b/build/javascript-agent-playwright/CurrentLaunch.js @@ -3,25 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.CurrentLaunch = void 0; +exports.currentLaunch = void 0; const events_1 = require("./constants/events"); const helpers_1 = require("./helpers"); const type_utils_1 = require("./helpers/type-utils"); const fs_1 = __importDefault(require("fs")); -exports.CurrentLaunch = { +exports.currentLaunch = { attachLabel: (key, ...values) => { if (!(0, type_utils_1.isNotBlankString)(key)) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachLabel', `Label key must be a not blank string. Provided value is '${key}'`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachLabel', `Label key must be a not blank string. Provided value is '${key}'`); return; } if (!(0, type_utils_1.isNotEmptyArray)(values)) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`); return; } values = values.filter((value) => { const isNotBlank = (0, type_utils_1.isNotBlankString)(value); if (!isNotBlank) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachLabel', `Label value must be a not blank string. Provided value for key '${key}' is '${value}'`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachLabel', `Label value must be a not blank string. Provided value for key '${key}' is '${value}'`); } return isNotBlank; }); @@ -31,11 +31,11 @@ exports.CurrentLaunch = { }, attachArtifactReference: (name, value) => { if (!(0, type_utils_1.isNotBlankString)(name)) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachArtifactReference', `Artifact reference name must be a not blank string. Provided value is '${name}'`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachArtifactReference', `Artifact reference name must be a not blank string. Provided value is '${name}'`); return; } if (!(0, type_utils_1.isNotBlankString)(value)) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachArtifactReference', `Artifact reference value must be a not blank string. Provided value for name '${value}' is '${value}'`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachArtifactReference', `Artifact reference value must be a not blank string. Provided value for name '${value}' is '${value}'`); return; } process.stdout.write(JSON.stringify({ eventType: events_1.EVENT_NAMES.ATTACH_LAUNCH_ARTIFACT_REFERENCES, payload: { name, value } })); @@ -43,11 +43,11 @@ exports.CurrentLaunch = { attachArtifact: (pathOrBuffer, name) => { const timestamp = new Date().getTime(); if (!Buffer.isBuffer(pathOrBuffer) && !fs_1.default.existsSync(pathOrBuffer)) { - (0, helpers_1.stdoutErrorEvent)('CurrentLaunch.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); + (0, helpers_1.stdoutErrorEvent)('currentLaunch.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); return; } if (name && !name.trim().length) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`); } process.stdout.write(JSON.stringify({ eventType: events_1.EVENT_NAMES.ATTACH_LAUNCH_ARTIFACT, @@ -55,4 +55,4 @@ exports.CurrentLaunch = { })); }, }; -//# sourceMappingURL=CurrentLaunch.js.map \ No newline at end of file +//# sourceMappingURL=currentLaunch.js.map \ No newline at end of file diff --git a/build/javascript-agent-playwright/CurrentLaunch.js.map b/build/javascript-agent-playwright/CurrentLaunch.js.map index 00fce66..c39c335 100644 --- a/build/javascript-agent-playwright/CurrentLaunch.js.map +++ b/build/javascript-agent-playwright/CurrentLaunch.js.map @@ -1 +1 @@ -{"version":3,"file":"CurrentLaunch.js","sourceRoot":"","sources":["../../src/javascript-agent-playwright/CurrentLaunch.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAiD;AACjD,uCAA6C;AAC7C,qDAAyE;AACzE,4CAAoB;AAEP,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,CAAC,GAAW,EAAE,GAAG,MAAgB,EAAE,EAAE;QAChD,IAAI,CAAC,IAAA,6BAAgB,EAAC,GAAG,CAAC,EAAE;YAC1B,IAAA,0BAA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O,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CACvG,CAAC;IACJ,CAAC;IAED,cAAc,EAAE,CAAC,YAA6B,EAAE,IAAa,EAAE,EAAE;QAC/D,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YAClE,IAAA,0BAAgB,EACd,8BAA8B,EAC9B,0GAA0G,CAC3G,CAAC;YACF,OAAO;SACR;QAED,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE;YAC/B,IAAA,0BAAgB,EACd,4BAA4B,EAC5B,2DAA2D,IAAI,GAAG,CACnE,CAAC;SACH;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;YACb,SAAS,EAAE,oBAAW,CAAC,sBAAsB;YAC7C,OAAO,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE;SAC3C,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"currentLaunch.js","sourceRoot":"","sources":["../../src/javascript-agent-playwright/currentLaunch.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAiD;AACjD,uCAA6C;AAC7C,qDAAyE;AACzE,4CAAoB;AAEP,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,CAAC,GAAW,EAAE,GAAG,MAAgB,EAAE,EAAE;QAChD,IAAI,CAAC,IAAA,6BAAgB,EAAC,GAAG,CAAC,EAAE;YAC1B,IAAA,0BAAgB,EAAC,2BAA2B,EAAE,4DAA4D,GAAG,GAAG,CAAC,CAAC;YAClH,OAAO;SACR;QAED,IAAI,CAAC,IAAA,4BAAe,EAAC,MAAM,CAAC,EAAE;YAC5B,IAAA,0BAAgB,EACd,2BAA2B,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AI,EAAE,CAAC,OAAO,EAAE,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YAClE,IAAA,0BAAgB,EACd,8BAA8B,EAC9B,0GAA0G,CAC3G,CAAC;YACF,OAAO;SACR;QAED,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE;YAC/B,IAAA,0BAAgB,EACd,4BAA4B,EAC5B,2DAA2D,IAAI,GAAG,CACnE,CAAC;SACH;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;YACb,SAAS,EAAE,oBAAW,CAAC,sBAAsB;YAC7C,OAAO,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE;SAC3C,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC"} \ No newline at end of file diff --git a/build/javascript-agent-playwright/CurrentTest.js b/build/javascript-agent-playwright/CurrentTest.js index de2ceb7..5bf9b70 100644 --- a/build/javascript-agent-playwright/CurrentTest.js +++ b/build/javascript-agent-playwright/CurrentTest.js @@ -3,46 +3,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.CurrentTest = void 0; +exports.currentTest = void 0; const events_1 = require("./constants/events"); const helpers_1 = require("./helpers"); const fs_1 = __importDefault(require("fs")); -exports.CurrentTest = { +/** + * @param {string} level 'INFO' | 'ERROR' | 'WARN' | 'FATAL' | 'DEBUG' | 'TRACE' | string + */ +const attachLog = (message, level = 'INFO') => { + if ((0, helpers_1.isNotBlankString)(message) && (0, helpers_1.isNotBlankString)(level)) { + process.stdout.write(JSON.stringify({ + eventType: events_1.EVENT_NAMES.ATTACH_TEST_LOG, + payload: { message, level }, + })); + } + else { + (0, helpers_1.stdoutErrorEvent)('currentTest.log', `Message and level parameters must not be a blank string, provided parameters are '${message}' and '${level}'.`); + } +}; +exports.currentTest = { setMaintainer: (maintainer) => { if ((0, helpers_1.isNotBlankString)(maintainer)) { process.stdout.write(JSON.stringify({ eventType: events_1.EVENT_NAMES.ATTACH_TEST_MAINTAINER, payload: maintainer })); } else { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.setMaintainer', `Maintainer must not be a blank string. Provided value is '${maintainer}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.setMaintainer', `Maintainer must not be a blank string. Provided value is '${maintainer}'`); } }, - /** - * @param {string} level 'INFO' | 'ERROR' | 'WARN' | 'FATAL' | 'DEBUG' | 'TRACE' | string - */ - attachLog: (message, level = 'INFO') => { - if ((0, helpers_1.isNotBlankString)(message) && (0, helpers_1.isNotBlankString)(level)) { - process.stdout.write(JSON.stringify({ - eventType: events_1.EVENT_NAMES.ATTACH_TEST_LOG, - payload: { message, level }, - })); - } - else { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachLog', `Message and level parameters must not be a blank string, provided parameters are '${message}' and '${level}'.`); - } + log: { + info: (message) => attachLog(message, 'INFO'), + error: (message) => attachLog(message, 'ERROR'), + warn: (message) => attachLog(message, 'WARN'), + fatal: (message) => attachLog(message, 'FATAL'), + debug: (message) => attachLog(message, 'DEBUG'), + trace: (message) => attachLog(message, 'TRACE'), + custom: (message, level) => attachLog(message, level), }, attachLabel: (key, ...values) => { if (!(0, helpers_1.isNotBlankString)(key)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachLabel', `Label key must not be a blank string. Provided value is '${key}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachLabel', `Label key must not be a blank string. Provided value is '${key}'`); return; } if (!(0, helpers_1.isNotEmptyArray)(values)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`); return; } values = values.filter((value) => { const isNotBlank = (0, helpers_1.isNotBlankString)(value); if (!isNotBlank) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachLabel', `Label value must not be a blank string. Provided value for key '${key}' is '${value}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachLabel', `Label value must not be a blank string. Provided value for key '${key}' is '${value}'`); } return isNotBlank; }); @@ -52,11 +61,11 @@ exports.CurrentTest = { }, attachArtifactReference: (name, value) => { if (!(0, helpers_1.isNotBlankString)(name)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachArtifactReference', `Artifact reference name must not be a blank string. Provided value is '${name}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachArtifactReference', `Artifact reference name must not be a blank string. Provided value is '${name}'`); return; } if (!(0, helpers_1.isNotBlankString)(value)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachArtifactReference', `Artifact reference value must not be a blank string. Provided value for name '${value}' is '${value}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachArtifactReference', `Artifact reference value must not be a blank string. Provided value for name '${value}' is '${value}'`); return; } process.stdout.write(JSON.stringify({ eventType: events_1.EVENT_NAMES.ATTACH_TEST_ARTIFACT_REFERENCES, payload: { name, value } })); @@ -64,11 +73,11 @@ exports.CurrentTest = { attachArtifact: (pathOrBuffer, name) => { const timestamp = new Date().getTime(); if (!Buffer.isBuffer(pathOrBuffer) && !fs_1.default.existsSync(pathOrBuffer)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); return; } if (name && !name.trim().length) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`); } process.stdout.write(JSON.stringify({ eventType: events_1.EVENT_NAMES.ATTACH_TEST_ARTIFACT, @@ -77,7 +86,7 @@ exports.CurrentTest = { }, attachScreenshot: (pathOrBuffer) => { if (!Buffer.isBuffer(pathOrBuffer) && !fs_1.default.existsSync(pathOrBuffer)) { - (0, helpers_1.stdoutErrorEvent)('CurrentTest.attachScreenshot', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); + (0, helpers_1.stdoutErrorEvent)('currentTest.attachScreenshot', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`); return; } process.stdout.write(JSON.stringify({ @@ -90,4 +99,4 @@ exports.CurrentTest = { process.stdout.write(JSON.stringify({ eventType })); }, }; -//# sourceMappingURL=CurrentTest.js.map \ No newline at end of file +//# sourceMappingURL=currentTest.js.map \ No newline at end of file diff --git a/build/javascript-agent-playwright/CurrentTest.js.map b/build/javascript-agent-playwright/CurrentTest.js.map index 4d9139e..a8c0c2e 100644 --- a/build/javascript-agent-playwright/CurrentTest.js.map +++ b/build/javascript-agent-playwright/CurrentTest.js.map @@ -1 +1 @@ -{"version":3,"file":"CurrentTest.js","sourceRoot":"","sources":["../../src/javascript-agent-playwright/CurrentTest.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAiD;AACjD,uCAAgF;AAChF,4CAAoB;AAGP,QAAA,WAAW,GAAG;IACzB,aAAa,EAAE,CAAC,UAAkB,EAAQ,EAAE;QAC1C,IAAI,IAAA,0BAAgB,EAAC,UAAU,CAAC,EAAE;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,oBAAW,CAAC,sBAAsB,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;SAC9G;aAAM;YACL,IAAA,0BAAgB,EACd,2BAA2B,EAC3B,6DAA6D,UAAU,GAAG,CAC3E,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACH,SAAS,EAAE,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AAS,EAAE,IAAI,EAAE;SAC3C,CAAC,CACH,CAAC;IACJ,CAAC;IAED,gBAAgB,EAAE,CAAC,YAA6B,EAAE,EAAE;QAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YAClE,IAAA,0BAAgB,EACd,8BAA8B,EAC9B,0GAA0G,CAC3G,CAAC;YACF,OAAO;SACR;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;YACb,SAAS,EAAE,oBAAW,CAAC,sBAAsB;YAC7C,OAAO,EAAE,EAAE,YAAY,EAAE;SAC1B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,kBAAkB,EAAE,GAAG,EAAE;QACvB,MAAM,SAAS,GAAG,oBAAW,CAAC,wBAAwB,CAAC;QACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"currentTest.js","sourceRoot":"","sources":["../../src/javascript-agent-playwright/currentTest.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAiD;AACjD,uCAAgF;AAChF,4CAAoB;AAGpB;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,QAAkB,MAAM,EAAE,EAAE;IAC9D,IAAI,IAAA,0BAAgB,EAAC,OAAO,CAAC,IAAI,IAAA,0BAAgB,EAAC,KAAK,CAAC,EAAE;QACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;YACb,SAAS,EAAE,oBAAW,CAAC,eAAe;YACtC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC5B,CAAC,CACH,CAAC;KACH;SAAM;QACL,IAAA,0BAAgB,EACd,iBAAiB,EACjB,qFAAqF,OAAO,UAAU,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AS,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAC"} \ No newline at end of file diff --git a/build/javascript-agent-playwright/ZebrunnerReporter.js b/build/javascript-agent-playwright/ZebrunnerReporter.js index 100d8ca..74b2c98 100644 --- a/build/javascript-agent-playwright/ZebrunnerReporter.js +++ b/build/javascript-agent-playwright/ZebrunnerReporter.js @@ -194,7 +194,7 @@ class ZebrunnerReporter { } else if (eventType === events_1.EVENT_NAMES.ATTACH_TEST_SCREENSHOT) { if (!this.reportingConfig.logs.ignoreManualScreenshots) { - pwTestResult.steps.push((0, helpers_1.createPwStepObject)(prevStepTimestamp, 'CurrentTest.attachScreenshot()', 'screenshot', payload.pathOrBuffer.type === 'Buffer' ? Buffer.from(payload.pathOrBuffer) : payload.pathOrBuffer)); + pwTestResult.steps.push((0, helpers_1.createPwStepObject)(prevStepTimestamp, 'currentTest.attachScreenshot()', 'screenshot', payload.pathOrBuffer.type === 'Buffer' ? Buffer.from(payload.pathOrBuffer) : payload.pathOrBuffer)); } } else if (eventType === events_1.EVENT_NAMES.ATTACH_TEST_ARTIFACT) { diff --git a/build/javascript-agent-playwright/index.js b/build/javascript-agent-playwright/index.js index 73aba13..7b6a549 100644 --- a/build/javascript-agent-playwright/index.js +++ b/build/javascript-agent-playwright/index.js @@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.zephyr = exports.zebrunner = exports.xray = exports.testRail = exports.CurrentLaunch = exports.CurrentTest = void 0; +exports.zephyr = exports.zebrunner = exports.xray = exports.testRail = exports.currentLaunch = exports.currentTest = void 0; const ZebrunnerReporter_1 = __importDefault(require("./ZebrunnerReporter")); -var CurrentTest_1 = require("./CurrentTest"); -Object.defineProperty(exports, "CurrentTest", { enumerable: true, get: function () { return CurrentTest_1.CurrentTest; } }); -var CurrentLaunch_1 = require("./CurrentLaunch"); -Object.defineProperty(exports, "CurrentLaunch", { enumerable: true, get: function () { return CurrentLaunch_1.CurrentLaunch; } }); +var currentTest_1 = require("./currentTest"); +Object.defineProperty(exports, "currentTest", { enumerable: true, get: function () { return currentTest_1.currentTest; } }); +var currentLaunch_1 = require("./currentLaunch"); +Object.defineProperty(exports, "currentLaunch", { enumerable: true, get: function () { return currentLaunch_1.currentLaunch; } }); var tcm_1 = require("./tcm"); Object.defineProperty(exports, "testRail", { enumerable: true, get: function () { return tcm_1.testRail; } }); Object.defineProperty(exports, "xray", { enumerable: true, get: function () { return tcm_1.xray; } }); diff --git a/package.json b/package.json index 897f127..91b77b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zebrunner/javascript-agent-playwright", - "version": "1.0.0", + "version": "1.0.1", "main": "build/javascript-agent-playwright/index.js", "license": "Apache-2.0", "description": "Zebrunner Agent for Playwright", diff --git a/src/javascript-agent-playwright/CurrentLaunch.ts b/src/javascript-agent-playwright/CurrentLaunch.ts index 4554a1e..193b9a2 100644 --- a/src/javascript-agent-playwright/CurrentLaunch.ts +++ b/src/javascript-agent-playwright/CurrentLaunch.ts @@ -3,16 +3,16 @@ import { stdoutErrorEvent } from './helpers'; import { isNotBlankString, isNotEmptyArray } from './helpers/type-utils'; import fs from 'fs'; -export const CurrentLaunch = { +export const currentLaunch = { attachLabel: (key: string, ...values: string[]) => { if (!isNotBlankString(key)) { - stdoutErrorEvent('CurrentLaunch.attachLabel', `Label key must be a not blank string. Provided value is '${key}'`); + stdoutErrorEvent('currentLaunch.attachLabel', `Label key must be a not blank string. Provided value is '${key}'`); return; } if (!isNotEmptyArray(values)) { stdoutErrorEvent( - 'CurrentLaunch.attachLabel', + 'currentLaunch.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`, ); return; @@ -22,7 +22,7 @@ export const CurrentLaunch = { const isNotBlank = isNotBlankString(value); if (!isNotBlank) { stdoutErrorEvent( - 'CurrentLaunch.attachLabel', + 'currentLaunch.attachLabel', `Label value must be a not blank string. Provided value for key '${key}' is '${value}'`, ); } @@ -37,7 +37,7 @@ export const CurrentLaunch = { attachArtifactReference: (name: string, value: string) => { if (!isNotBlankString(name)) { stdoutErrorEvent( - 'CurrentLaunch.attachArtifactReference', + 'currentLaunch.attachArtifactReference', `Artifact reference name must be a not blank string. Provided value is '${name}'`, ); return; @@ -45,7 +45,7 @@ export const CurrentLaunch = { if (!isNotBlankString(value)) { stdoutErrorEvent( - 'CurrentLaunch.attachArtifactReference', + 'currentLaunch.attachArtifactReference', `Artifact reference value must be a not blank string. Provided value for name '${value}' is '${value}'`, ); return; @@ -61,7 +61,7 @@ export const CurrentLaunch = { if (!Buffer.isBuffer(pathOrBuffer) && !fs.existsSync(pathOrBuffer)) { stdoutErrorEvent( - 'CurrentLaunch.attachArtifact', + 'currentLaunch.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`, ); return; @@ -69,7 +69,7 @@ export const CurrentLaunch = { if (name && !name.trim().length) { stdoutErrorEvent( - 'CurrentTest.attachArtifact', + 'currentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`, ); } diff --git a/src/javascript-agent-playwright/CurrentTest.ts b/src/javascript-agent-playwright/CurrentTest.ts index 8dcfe00..897d19b 100644 --- a/src/javascript-agent-playwright/CurrentTest.ts +++ b/src/javascript-agent-playwright/CurrentTest.ts @@ -3,46 +3,56 @@ import { isNotBlankString, isNotEmptyArray, stdoutErrorEvent } from './helpers'; import fs from 'fs'; import { LogLevel } from './types'; -export const CurrentTest = { +/** + * @param {string} level 'INFO' | 'ERROR' | 'WARN' | 'FATAL' | 'DEBUG' | 'TRACE' | string + */ +const attachLog = (message: string, level: LogLevel = 'INFO') => { + if (isNotBlankString(message) && isNotBlankString(level)) { + process.stdout.write( + JSON.stringify({ + eventType: EVENT_NAMES.ATTACH_TEST_LOG, + payload: { message, level }, + }), + ); + } else { + stdoutErrorEvent( + 'currentTest.log', + `Message and level parameters must not be a blank string, provided parameters are '${message}' and '${level}'.`, + ); + } +}; + +export const currentTest = { setMaintainer: (maintainer: string): void => { if (isNotBlankString(maintainer)) { process.stdout.write(JSON.stringify({ eventType: EVENT_NAMES.ATTACH_TEST_MAINTAINER, payload: maintainer })); } else { stdoutErrorEvent( - 'CurrentTest.setMaintainer', + 'currentTest.setMaintainer', `Maintainer must not be a blank string. Provided value is '${maintainer}'`, ); } }, - /** - * @param {string} level 'INFO' | 'ERROR' | 'WARN' | 'FATAL' | 'DEBUG' | 'TRACE' | string - */ - attachLog: (message: string, level: LogLevel = 'INFO'): void => { - if (isNotBlankString(message) && isNotBlankString(level)) { - process.stdout.write( - JSON.stringify({ - eventType: EVENT_NAMES.ATTACH_TEST_LOG, - payload: { message, level }, - }), - ); - } else { - stdoutErrorEvent( - 'CurrentTest.attachLog', - `Message and level parameters must not be a blank string, provided parameters are '${message}' and '${level}'.`, - ); - } + log: { + info: (message: string) => attachLog(message, 'INFO'), + error: (message: string) => attachLog(message, 'ERROR'), + warn: (message: string) => attachLog(message, 'WARN'), + fatal: (message: string) => attachLog(message, 'FATAL'), + debug: (message: string) => attachLog(message, 'DEBUG'), + trace: (message: string) => attachLog(message, 'TRACE'), + custom: (message: string, level: string) => attachLog(message, level), }, attachLabel: (key: string, ...values: string[]) => { if (!isNotBlankString(key)) { - stdoutErrorEvent('CurrentTest.attachLabel', `Label key must not be a blank string. Provided value is '${key}'`); + stdoutErrorEvent('currentTest.attachLabel', `Label key must not be a blank string. Provided value is '${key}'`); return; } if (!isNotEmptyArray(values)) { stdoutErrorEvent( - 'CurrentTest.attachLabel', + 'currentTest.attachLabel', `You must provide at least one label value. The label with the key '${key}' has none`, ); return; @@ -52,7 +62,7 @@ export const CurrentTest = { const isNotBlank = isNotBlankString(value); if (!isNotBlank) { stdoutErrorEvent( - 'CurrentTest.attachLabel', + 'currentTest.attachLabel', `Label value must not be a blank string. Provided value for key '${key}' is '${value}'`, ); } @@ -67,7 +77,7 @@ export const CurrentTest = { attachArtifactReference: (name: string, value: string) => { if (!isNotBlankString(name)) { stdoutErrorEvent( - 'CurrentTest.attachArtifactReference', + 'currentTest.attachArtifactReference', `Artifact reference name must not be a blank string. Provided value is '${name}'`, ); return; @@ -75,7 +85,7 @@ export const CurrentTest = { if (!isNotBlankString(value)) { stdoutErrorEvent( - 'CurrentTest.attachArtifactReference', + 'currentTest.attachArtifactReference', `Artifact reference value must not be a blank string. Provided value for name '${value}' is '${value}'`, ); return; @@ -91,7 +101,7 @@ export const CurrentTest = { if (!Buffer.isBuffer(pathOrBuffer) && !fs.existsSync(pathOrBuffer)) { stdoutErrorEvent( - 'CurrentTest.attachArtifact', + 'currentTest.attachArtifact', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`, ); return; @@ -99,7 +109,7 @@ export const CurrentTest = { if (name && !name.trim().length) { stdoutErrorEvent( - 'CurrentTest.attachArtifact', + 'currentTest.attachArtifact', `fileName must not be a blank string. Provided value is '${name}'`, ); } @@ -115,7 +125,7 @@ export const CurrentTest = { attachScreenshot: (pathOrBuffer: Buffer | string) => { if (!Buffer.isBuffer(pathOrBuffer) && !fs.existsSync(pathOrBuffer)) { stdoutErrorEvent( - 'CurrentTest.attachScreenshot', + 'currentTest.attachScreenshot', `pathOrBuffer must point to an existing file or contain Buffer. Buffer failed validation / file not found`, ); return; diff --git a/src/javascript-agent-playwright/ZebrunnerReporter.ts b/src/javascript-agent-playwright/ZebrunnerReporter.ts index 396cbda..62f5bec 100644 --- a/src/javascript-agent-playwright/ZebrunnerReporter.ts +++ b/src/javascript-agent-playwright/ZebrunnerReporter.ts @@ -230,7 +230,7 @@ class ZebrunnerReporter implements PwReporter { pwTestResult.steps.push( createPwStepObject( prevStepTimestamp, - 'CurrentTest.attachScreenshot()', + 'currentTest.attachScreenshot()', 'screenshot', payload.pathOrBuffer.type === 'Buffer' ? Buffer.from(payload.pathOrBuffer) : payload.pathOrBuffer, ), diff --git a/src/javascript-agent-playwright/index.ts b/src/javascript-agent-playwright/index.ts index 3c963db..b153383 100644 --- a/src/javascript-agent-playwright/index.ts +++ b/src/javascript-agent-playwright/index.ts @@ -1,6 +1,6 @@ import ZebrunnerReporter from './ZebrunnerReporter'; -export { CurrentTest } from './CurrentTest'; -export { CurrentLaunch } from './CurrentLaunch'; +export { currentTest } from './currentTest'; +export { currentLaunch } from './currentLaunch'; export { testRail, xray, zebrunner, zephyr } from './tcm'; export default ZebrunnerReporter; diff --git a/tests/api/api-all-pass-skip.spec.js b/tests/api/api-all-pass-skip.spec.js index 1948549..7fd0910 100644 --- a/tests/api/api-all-pass-skip.spec.js +++ b/tests/api/api-all-pass-skip.spec.js @@ -1,6 +1,6 @@ import { - CurrentTest, - CurrentLaunch, + currentTest, + currentLaunch, zebrunner, testRail, } from '../../src/javascript-agent-playwright/index'; @@ -15,22 +15,22 @@ function timeout(ms) { } test.describe('API Testing with Playwright', () => { - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachLabel('reporting', 'Zebrunner'); - CurrentLaunch.attachLabel('TCM', 'Zebrunner'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachLabel('reporting', 'Zebrunner'); + currentLaunch.attachLabel('TCM', 'Zebrunner'); - CurrentLaunch.attachArtifact('./artifacts/zeb.png'); - CurrentLaunch.attachArtifact('./artifacts/txt.txt'); + currentLaunch.attachArtifact('./artifacts/zeb.png'); + currentLaunch.attachArtifact('./artifacts/txt.txt'); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); test('GET /users - should return a list of users (with maintainer)', async ({ request, }) => { console.log('Maintainer should be ' + maintainer); - CurrentTest.attachLog('Maintainer should be ' + maintainer); - CurrentTest.setMaintainer(maintainer); + currentTest.log.info('Maintainer should be ' + maintainer); + currentTest.setMaintainer(maintainer); zebrunner.testCaseKey('DEF-4408', 'KEY-2001'); @@ -46,10 +46,10 @@ test.describe('API Testing with Playwright', () => { test.skip('GET /users/1 - should return a single user (with console.log())', async ({ request, }) => { - CurrentTest.attachLog('Maintainer should be ' + maintainer); - CurrentTest.setMaintainer(maintainer); + currentTest.log.info('Maintainer should be ' + maintainer); + currentTest.setMaintainer(maintainer); - CurrentTest.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifact('./artifacts/zeb.png'); testRail.testCaseId('C4', 'C5'); @@ -70,7 +70,7 @@ test.describe('API Testing with Playwright', () => { }); test.skip('POST /users - should create a new user', async ({ request }) => { - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.attachLabel('type', 'smoke', 'regression'); const newUser = { name: 'John Doe', @@ -87,11 +87,11 @@ test.describe('API Testing with Playwright', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test.skip('POST /users - should be @failed', async ({ request }) => { - CurrentTest.attachLog('Custom log message example on test start'); + currentTest.log.info('Custom log message example on test start'); console.log('This code executes?'); @@ -113,7 +113,7 @@ test.describe('API Testing with Playwright', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test.skip('GET /users/1 - should be @skipped', async ({ request }) => { @@ -128,6 +128,6 @@ test.describe('API Testing with Playwright', () => { test('Not an important test (This test should not be reported in Zebrunner)', async ({ request, }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); }); }); diff --git a/tests/api/api-test-2-descr.spec.js b/tests/api/api-test-2-descr.spec.js index be47cb7..3a0b3ed 100644 --- a/tests/api/api-test-2-descr.spec.js +++ b/tests/api/api-test-2-descr.spec.js @@ -1,6 +1,6 @@ import { - CurrentTest, - CurrentLaunch, + currentTest, + currentLaunch, zebrunner, testRail, zephyr, @@ -18,24 +18,22 @@ function timeout(ms) { } test.describe('API Testing with Playwright (1st describe)', () => { - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachLabel('reporting', 'Zebrunner'); - CurrentLaunch.attachLabel('TCM', 'Zebrunner'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachLabel('reporting', 'Zebrunner'); + currentLaunch.attachLabel('TCM', 'Zebrunner'); - CurrentLaunch.attachArtifact('./artifacts/zeb.png'); - CurrentLaunch.attachArtifact('./artifacts/txt.txt'); + currentLaunch.attachArtifact('./artifacts/zeb.png'); + currentLaunch.attachArtifact('./artifacts/txt.txt'); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); - test('GET /users - should return a list of users (with maintainer)', async ({ - request, - }) => { - CurrentTest.attachLog('Describe: 1', 'WARN'); + test('GET /users - should return a list of users (with maintainer)', async ({ request }) => { + currentTest.log.warn('Describe: 1'); console.log('Maintainer should be ', maintainer); - CurrentTest.attachLog('Describe: 1', 'WARN'); + currentTest.log.warn('Describe: 1'); - CurrentTest.attachLog(`Maintainer should be ${maintainer}`, 'INFO'); - CurrentTest.setMaintainer(maintainer); + currentTest.log.info(`Maintainer should be ${maintainer}`); + currentTest.setMaintainer(maintainer); zebrunner.testCaseKey('DEF-4408', 'KEY-2001'); @@ -48,13 +46,11 @@ test.describe('API Testing with Playwright (1st describe)', () => { expect(users.length).toBeGreaterThan(0); }); - test('GET /users/1 - should return a single user (with console.log())', async ({ - request, - }) => { - CurrentTest.attachLog(`Maintainer should be ${maintainer}`, 'INFO'); - CurrentTest.setMaintainer(maintainer); + test('GET /users/1 - should return a single user (with console.log())', async ({ request }) => { + currentTest.log.info(`Maintainer should be ${maintainer}`); + currentTest.setMaintainer(maintainer); - CurrentTest.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifact('./artifacts/zeb.png'); testRail.testCaseId('C4', 'C5'); xray.testCaseKey('ZEB-17', 'ZEB-63'); @@ -78,7 +74,7 @@ test.describe('API Testing with Playwright (1st describe)', () => { }); test('POST /users - should create a new user', async ({ request }) => { - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.attachLabel('type', 'smoke', 'regression'); const newUser = { name: 'John Doe', @@ -95,11 +91,11 @@ test.describe('API Testing with Playwright (1st describe)', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish', 'INFO'); + currentTest.log.info('Custom log message example on test finish'); }); test('POST /users - should be @failed', async ({ request }) => { - CurrentTest.attachLog('Custom log message example on test start', 'INFO'); + currentTest.log.info('Custom log message example on test start'); console.log('This code executes?'); @@ -121,7 +117,7 @@ test.describe('API Testing with Playwright (1st describe)', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish', 'INFO'); + currentTest.log.info('Custom log message example on test finish'); }); test.skip('GET /users/1 - should be @skipped', async ({ request }) => { @@ -133,49 +129,40 @@ test.describe('API Testing with Playwright (1st describe)', () => { expect(user.name).toBeDefined(); }); - test('Not an important test (This test should not be reported in Zebrunner)', async ({ - request, - }) => { - CurrentTest.revertRegistration(); + test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { + currentTest.revertRegistration(); }); }); test.describe('JSONPlaceholder Post API tests (2d describe )', () => { test('should create a new post and should be passed', async ({ request }) => { - CurrentTest.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifact('./artifacts/zeb.png'); testRail.testCaseId('C4', 'C5'); xray.testCaseKey('ZEB-17', 'ZEB-63'); zebrunner.testCaseKey('DEF-4156', 'DEF-4359'); zephyr.testCaseKey('ZEB-T9', 'ZEB-T13'); - CurrentTest.attachLog('Describe: 2', 'WARN'); - const response = await request.post( - 'https://jsonplaceholder.typicode.com/posts', - { - data: { - title: 'New Post', - body: 'This is a new post created for testing purposes.', - userId: 1, - }, - } - ); + currentTest.log.warn('Describe: 2'); + const response = await request.post('https://jsonplaceholder.typicode.com/posts', { + data: { + title: 'New Post', + body: 'This is a new post created for testing purposes.', + userId: 1, + }, + }); expect(response.status()).toBe(201); const responseBody = await response.json(); expect(responseBody.title).toBe('New Post'); - expect(responseBody.body).toBe( - 'This is a new post created for testing purposes.' - ); + expect(responseBody.body).toBe('This is a new post created for testing purposes.'); expect(responseBody.userId).toBe(1); }); test('should get post details and should be failed', async ({ request }) => { zebrunner.testCaseKey('DEF-4414', 'DEF-4418'); - CurrentTest.attachLog('Describe: 2', 'WARN'); + currentTest.log.warn('Describe: 2'); - const response = await request.get( - 'https://jsonplaceholder.typicode.com/posts/1' - ); + const response = await request.get('https://jsonplaceholder.typicode.com/posts/1'); expect(response.status()).toBe(200); const responseBody = await response.json(); expect(responseBody).toHaveProperty('id', 1); diff --git a/tests/api/api-test.spec.ts b/tests/api/api-test.spec.ts index 9bcbf9c..9634021 100644 --- a/tests/api/api-test.spec.ts +++ b/tests/api/api-test.spec.ts @@ -1,6 +1,6 @@ import { - CurrentTest, - CurrentLaunch, + currentTest, + currentLaunch, zebrunner, testRail, zephyr, @@ -17,20 +17,20 @@ function timeout(ms) { } test.describe('API Testing with Playwright', () => { - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachLabel('reporting', 'Zebrunner'); - CurrentLaunch.attachLabel('TCM', 'Zebrunner'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachLabel('reporting', 'Zebrunner'); + currentLaunch.attachLabel('TCM', 'Zebrunner'); - CurrentLaunch.attachArtifact('./artifacts/zeb.png'); - CurrentLaunch.attachArtifact('./artifacts/txt.txt'); + currentLaunch.attachArtifact('./artifacts/zeb.png'); + currentLaunch.attachArtifact('./artifacts/txt.txt'); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); test('GET /users - should return a list of users (with maintainer)', async ({ request }) => { console.log('Maintainer should be ' + maintainer); - CurrentTest.attachLog('Maintainer should be ' + maintainer); - CurrentTest.setMaintainer(maintainer); + currentTest.log.info('Maintainer should be ' + maintainer); + currentTest.setMaintainer(maintainer); zebrunner.testCaseKey('DEF-4408', 'KEY-2001'); @@ -44,10 +44,10 @@ test.describe('API Testing with Playwright', () => { }); test('GET /users/1 - should return a single user (with console.log())', async ({ request }) => { - CurrentTest.attachLog('Maintainer should be ' + maintainer); - CurrentTest.setMaintainer(maintainer); + currentTest.log.info('Maintainer should be ' + maintainer); + currentTest.setMaintainer(maintainer); - CurrentTest.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifact('./artifacts/zeb.png'); testRail.testCaseId('C4', 'C5'); xray.testCaseKey('ZEB-17', 'ZEB-63'); @@ -71,7 +71,7 @@ test.describe('API Testing with Playwright', () => { }); test('POST /users - should create a new user', async ({ request }) => { - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.attachLabel('type', 'smoke', 'regression'); const newUser = { name: 'John Doe', @@ -88,14 +88,14 @@ test.describe('API Testing with Playwright', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('POST /users - should be @failed', async ({ request }, testInfo) => { - CurrentTest.attachLog('Custom log message example on test start'); + currentTest.log.info('Custom log message example on test start'); const retryCount = `Retry Count: ${testInfo.retry}`; - CurrentTest.attachLog(retryCount, 'WARN'); + currentTest.log.warn(retryCount); console.log('This code executes?'); @@ -117,7 +117,7 @@ test.describe('API Testing with Playwright', () => { expect(createdUser.id).toBeDefined(); expect(createdUser.name).toBe(newUser.name); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test.skip('GET /users/1 - should be @skipped', async ({ request }) => { @@ -130,6 +130,6 @@ test.describe('API Testing with Playwright', () => { }); test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); }); }); diff --git a/tests/example.spec.js b/tests/example.spec.js index f1624f0..e9fbe67 100644 --- a/tests/example.spec.js +++ b/tests/example.spec.js @@ -1,5 +1,5 @@ // @ts-check -import { CurrentTest, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, currentLaunch } from '../src/javascript-agent-playwright/index'; const { test, expect } = require('@playwright/test'); @@ -9,16 +9,16 @@ const automation_type = 'web'; test.describe('Web Testing with Playwright', () => { test.beforeAll(async () => { // will be attached to the entire run - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); }); test('Has title (with maintainer)', async ({ page }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); - CurrentLaunch.attachArtifact('./artifacts/zeb.png'); - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); console.log('Maintainer should be ' + maintainer); @@ -27,23 +27,23 @@ test.describe('Web Testing with Playwright', () => { // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link (with console.log() and custom screenshots and logs)', async ({ page, }, testInfo) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); + currentTest.log.info('INFO level log message on test start'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -53,45 +53,45 @@ test.describe('Web Testing with Playwright', () => { page.getByRole('heading', { name: 'Installation' }) ).toBeVisible(); - CurrentTest.attachLog('Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot('artifacts/zeb.png'); + currentTest.log.warn('Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot('artifacts/zeb.png'); console.log('Log should be 1'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); + currentTest.log.info('INFO level log message 1'); console.log('Log should be 2'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); + currentTest.log.error('ERROR level log message 2'); console.log('Log should be 3'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); + currentTest.log.warn('WARN level log message 3'); console.log('Log should be 4'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); + currentTest.log.fatal('FATAL level log message 4'); console.log('Log should be 5'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); + currentTest.log.debug('DEBUG level log message 5'); - CurrentTest.attachLog('Attaching screenshot after log mesage 5', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('Attaching screenshot after log mesage 5'); + currentTest.attachScreenshot(await page.screenshot()); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.trace('TRACE level log message 6'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); console.log('Log should be 1.1'); console.log('Log should be 1.2'); console.log('Log should be 1.3'); - CurrentTest.attachLog( + currentTest.log.info( 'Custom log message example on test finish (without log level, by default should be INFO 8)' ); - CurrentTest.attachLog('Attaching screenshot after all logs', 'INFO'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.info('Attaching screenshot after all logs'); + currentTest.attachScreenshot(await page.screenshot()); }); test('Get started link incorrect - should be @failed', async ({ page, browser, }, testInfo) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); const retryCount = `Retry Count: ${testInfo.retry}`; - CurrentTest.attachLog(retryCount, 'WARN'); + currentTest.log.warn(retryCount); const browserType = browser.browserType().name(); console.log('Browser Type:', browserType); @@ -100,29 +100,29 @@ test.describe('Web Testing with Playwright', () => { const version = await browser.version(); console.log('Browser Version:', version); - CurrentTest.attachLog('Custom log message example on test start', 'INFO'); - CurrentTest.attachLabel('reporting', 'Zebrunner'); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachLabel('reporting', 'Zebrunner'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await expect( page.getByRole('link', { name: 'Get started - Oops!' }) ).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link incorrect - should be @aborted', async ({ page, }, testInfo) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.attachLabel('type', 'smoke', 'regression'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started - Oops!' }).click(); @@ -144,19 +144,19 @@ test.describe('Web Testing with Playwright', () => { page.getByRole('heading', { name: 'Installation' }) ).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Skipped inside in test', async ({ page }, testInfo) => { - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); - CurrentTest.attachArtifact('./artifacts/zeb.png'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.attachArtifact('./artifacts/zeb.png'); - CurrentTest.attachLabel('type', 'smoke'); - CurrentTest.setMaintainer(maintainer); + currentTest.attachLabel('type', 'smoke'); + currentTest.setMaintainer(maintainer); await page.goto('https://example.com'); - CurrentTest.attachLog('This test should be skipped!)', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('This test should be skipped!)'); + currentTest.attachScreenshot(await page.screenshot()); const conditionToSkip = true; if (conditionToSkip) { diff --git a/tests/pw_nested_testsuite.spec.ts b/tests/pw_nested_testsuite.spec.ts index 6cf461e..b97f295 100644 --- a/tests/pw_nested_testsuite.spec.ts +++ b/tests/pw_nested_testsuite.spec.ts @@ -1,29 +1,29 @@ import { expect, test } from '@playwright/test'; -import { CurrentTest, zebrunner, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, zebrunner, currentLaunch } from '../src/javascript-agent-playwright/index'; const { chromium } = require('playwright'); import * as fs from 'fs'; test.describe('nested foo', () => { test.beforeAll(async () => { - CurrentLaunch.attachLabel('test_run_label_key', 'run_label_value_one', 'run_label_value_two'); - CurrentLaunch.attachArtifactReference('someRunArtifactName', 'https://zebrunner.com'); - CurrentLaunch.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); + currentLaunch.attachLabel('test_run_label_key', 'run_label_value_one', 'run_label_value_two'); + currentLaunch.attachArtifactReference('someRunArtifactName', 'https://zebrunner.com'); + currentLaunch.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); const bufferFileOne = fs.readFileSync('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT2.txt'); - CurrentLaunch.attachArtifact(bufferFileOne); + currentLaunch.attachArtifact(bufferFileOne); }); test('Get started link (with console.log() and custom screenshots and logs)', async ({ page }, testInfo) => { - CurrentTest.setMaintainer('edovnar'); + currentTest.setMaintainer('edovnar'); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); + currentTest.log.info('INFO level log message on test start'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -32,9 +32,8 @@ test.describe('nested foo', () => { await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); //await expect(page.getByRole('heading', { name: '1231231313' })).toBeVisible(); - CurrentTest.attachLog('BEFORE Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); - //CurrentTest.attachLog('AFTER Attaching screenshot via PATH on disk', 'WARN'); + currentTest.log.warn('BEFORE Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot(await page.screenshot()); console.log('Log should be 1'); console.log('Log should be 2'); @@ -42,29 +41,29 @@ test.describe('nested foo', () => { console.log('Log should be 4'); console.log('Log should be 5'); - CurrentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); - CurrentTest.attachArtifactReference('referenceT.txt', 'https://google.com'); + currentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); + currentTest.attachArtifactReference('referenceT.txt', 'https://google.com'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); + currentTest.log.info('INFO level log message 1'); + currentTest.log.error('ERROR level log message 2'); + currentTest.log.warn('WARN level log message 3'); + currentTest.log.fatal('FATAL level log message 4'); + currentTest.log.debug('DEBUG level log message 5'); + currentTest.log.trace('TRACE level log message 6'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); - CurrentTest.attachLog('Custom log message example on test finish (without log level, by default should be INFO 8)'); + currentTest.log.info('Custom log message example on test finish (without log level, by default should be INFO 8)'); }); test('Skipped inside in test', async ({ page }, testInfo) => { - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); - CurrentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); - CurrentTest.attachLabel('type', 'smoke'); - CurrentTest.setMaintainer('edovnar'); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); + currentTest.attachLabel('type', 'smoke'); + currentTest.setMaintainer('edovnar'); await page.goto('https://example.com'); - CurrentTest.attachLog('This test should be skipped!)', 'WARN'); + currentTest.log.warn('This test should be skipped!)'); const conditionToSkip = true; if (conditionToSkip) { @@ -81,35 +80,35 @@ test.describe('nested foo', () => { }); test('test running in Chrome @ff @smoke_test @slow', async ({ page }, testInfo) => { - CurrentTest.setMaintainer('edovnar'); + currentTest.setMaintainer('edovnar'); const browser = await chromium.launch(); const page1 = await browser.newPage('https://github.com'); console.log('Custom Message from console.log'); - CurrentTest.attachLog('NO PARAMETER custom log message'); + currentTest.log.info('NO PARAMETER custom log message'); - CurrentTest.attachLog('INFO level log message', 'INFO'); - CurrentTest.attachLog('DEBUG level log message', 'DEBUG'); - CurrentTest.attachLog('ERROR level log message', 'ERROR'); - CurrentTest.attachLog('WARN level log message', 'WARN'); - CurrentTest.attachLog('TRACE level log message', 'TRACE'); - CurrentTest.attachLog('FATAL level log message', 'FATAL'); + currentTest.log.info('INFO level log message'); + currentTest.log.debug('DEBUG level log message'); + currentTest.log.error('ERROR level log message'); + currentTest.log.warn('WARN level log message'); + currentTest.log.trace('TRACE level log message'); + currentTest.log.fatal('FATAL level log message'); - CurrentTest.attachLog('CUSTOM string level log message', 'CUSTOM'); + currentTest.log.custom('CUSTOM string level log message', 'CUSTOM'); zebrunner.testCaseKey('DEF-1231'); zebrunner.testCaseStatus('DEF-1249', 'Retest'); - CurrentTest.attachLabel('someTestLabelKey', 'someTestLabelValueOne', 'someTestLabelValueTwo'); - CurrentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); - CurrentTest.attachArtifactReference('someTestArtifactName', 'https://zebrunner.com'); + currentTest.attachLabel('someTestLabelKey', 'someTestLabelValueOne', 'someTestLabelValueTwo'); + currentTest.attachArtifact('C:\\Users\\Mr_Fi\\Desktop\\Zebrunner\\TEST_ARTIFACT.txt'); + currentTest.attachArtifactReference('someTestArtifactName', 'https://zebrunner.com'); await page1.goto('https://zebrunner.com'); const bufferScreenshot1 = await page1.screenshot(); - CurrentTest.attachArtifact(bufferScreenshot1); + currentTest.attachArtifact(bufferScreenshot1); const bufferScreenshot2 = await page1.screenshot(); - CurrentTest.attachArtifact(bufferScreenshot2, 'screenshot2.png'); + currentTest.attachArtifact(bufferScreenshot2, 'screenshot2.png'); - CurrentTest.attachScreenshot(await page1.screenshot()); + currentTest.attachScreenshot(await page1.screenshot()); await browser.close(); }); @@ -127,13 +126,13 @@ test.describe('nested foo', () => { test('basic test with revert @broke', async ({ page }, testInfo) => { // testInfo.annotations.push({type: 'maintainer', description: 'emarf'}); - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); const title = page.locator('.navbar__inner .navbar__title'); await expect(title).toHaveText('Playwright_broke'); }); test('my test1', async ({ page }) => { - CurrentTest.setMaintainer('emarf'); + currentTest.setMaintainer('emarf'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); diff --git a/tests/tcm-testrail-web.spec.js b/tests/tcm-testrail-web.spec.js index 39a3384..9952670 100644 --- a/tests/tcm-testrail-web.spec.js +++ b/tests/tcm-testrail-web.spec.js @@ -1,6 +1,6 @@ // @ts-check import { pseudoRandomBytes } from 'crypto'; -import { CurrentTest, testRail, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, testRail, currentLaunch } from '../src/javascript-agent-playwright/index'; const { test, expect } = require('@playwright/test'); @@ -16,17 +16,17 @@ const passed_case_key = 'C1'; test.describe('Web Testing with Playwright', () => { test.beforeAll(async () => { // will be attached to the entire run - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachLabel('TCM', 'Testrail'); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachLabel('TCM', 'Testrail'); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); }); test(`Test should be passed, but result for test case ${failed_case_key} should be imported as ${failed}`, async ({ page, }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); testRail.testCaseId('C2', failed_case_key); testRail.testCaseStatus(failed_case_key, failed); @@ -35,26 +35,26 @@ test.describe('Web Testing with Playwright', () => { console.log('Maintainer should be ' + maintainer); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Test should be passed (with console.log() and custom screenshot)', async ({ page }) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); testRail.testCaseId('C4', 'C5'); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('INFO level log message on test start'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -62,59 +62,59 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot('artifacts/zeb.png'); + currentTest.log.warn('Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot('artifacts/zeb.png'); console.log('Log should be 1'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); + currentTest.log.info('INFO level log message 1'); console.log('Log should be 2'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); + currentTest.log.error('ERROR level log message 2'); console.log('Log should be 3'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); + currentTest.log.warn('WARN level log message 3'); console.log('Log should be 4'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); + currentTest.log.fatal('FATAL level log message 4'); console.log('Log should be 5'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); + currentTest.log.debug('DEBUG level log message 5'); - CurrentTest.attachLog('Attaching screenshot after log mesage 5', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('Attaching screenshot after log mesage 5'); + currentTest.attachScreenshot(await page.screenshot()); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.trace('TRACE level log message 6'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); console.log('Log should be 1.1'); console.log('Log should be 1.2'); console.log('Log should be 1.3'); - CurrentTest.attachLog('Custom log message example on test finish (without log level, by default should be INFO 8)'); - CurrentTest.attachLog('Attaching screenshot after all logs', 'INFO'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.info('Custom log message example on test finish (without log level, by default should be INFO 8)'); + currentTest.log.info('Attaching screenshot after all logs'); + currentTest.attachScreenshot(await page.screenshot()); }); test(`Test should be @failed but result for case ${passed_case_key} should be ${passed}`, async ({ page }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachLabel('reporting', 'Zebrunner'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachLabel('reporting', 'Zebrunner'); testRail.testCaseId('C6'); testRail.testCaseStatus(passed_case_key, passed); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await expect(page.getByRole('link', { name: 'Get started - Oops!' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link incorrect - should be @aborted', async ({ page }, testInfo) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.setMaintainer(maintainer); + currentTest.attachLabel('type', 'smoke', 'regression'); testRail.testCaseId('C7'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started - Oops!' }).click(); @@ -128,16 +128,16 @@ test.describe('Web Testing with Playwright', () => { // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); testRail.testCaseId('C83'); }); @@ -145,7 +145,7 @@ test.describe('Web Testing with Playwright', () => { testRail.testCaseId('C8'); await page.goto('https://example.com'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); const conditionToSkip = true; if (conditionToSkip) { diff --git a/tests/tcm-xray-web.spec.js b/tests/tcm-xray-web.spec.js index d5f8103..a7cf527 100644 --- a/tests/tcm-xray-web.spec.js +++ b/tests/tcm-xray-web.spec.js @@ -1,6 +1,6 @@ // @ts-check import { pseudoRandomBytes } from 'crypto'; -import { CurrentTest, xray, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, xray, currentLaunch } from '../src/javascript-agent-playwright/index'; const { test, expect } = require('@playwright/test'); @@ -16,17 +16,17 @@ const passed_case_key = 'ZEB-24'; test.describe('Web Testing with Playwright', () => { test.beforeAll(async () => { // will be attached to the entire run - CurrentLaunch.attachLabel('TCM', 'Xray'); - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachLabel('TCM', 'Xray'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); }); test(`Test should be passed, but result for test case ${failed_case_key} should be imported as ${failed}`, async ({ page, }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); xray.testCaseKey('ZEB-18', failed_case_key); xray.testCaseStatus(failed_case_key, failed); @@ -34,26 +34,26 @@ test.describe('Web Testing with Playwright', () => { console.log('Maintainer should be ' + maintainer); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Test should be passed (with console.log() and custom screenshot)', async ({ page }) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); xray.testCaseKey('ZEB-17', 'ZEB-63'); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('INFO level log message on test start'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -61,59 +61,59 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot('artifacts/zeb.png'); + currentTest.log.warn('Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot('artifacts/zeb.png'); console.log('Log should be 1'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); + currentTest.log.info('INFO level log message 1'); console.log('Log should be 2'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); + currentTest.log.error('ERROR level log message 2'); console.log('Log should be 3'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); + currentTest.log.warn('WARN level log message 3'); console.log('Log should be 4'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); + currentTest.log.fatal('FATAL level log message 4'); console.log('Log should be 5'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); + currentTest.log.debug('DEBUG level log message 5'); - CurrentTest.attachLog('Attaching screenshot after log mesage 5', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('Attaching screenshot after log mesage 5'); + currentTest.attachScreenshot(await page.screenshot()); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.trace('TRACE level log message 6'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); console.log('Log should be 1.1'); console.log('Log should be 1.2'); console.log('Log should be 1.3'); - CurrentTest.attachLog('Custom log message example on test finish (without log level, by default should be INFO 8)'); - CurrentTest.attachLog('Attaching screenshot after all logs', 'INFO'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.info('Custom log message example on test finish (without log level, by default should be INFO 8)'); + currentTest.log.info('Attaching screenshot after all logs'); + currentTest.attachScreenshot(await page.screenshot()); }); test(`Test should be @failed but result for case ${passed_case_key} should be ${passed}`, async ({ page }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachLabel('reporting', 'Zebrunner'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachLabel('reporting', 'Zebrunner'); xray.testCaseKey('ZEB-65'); xray.testCaseStatus(passed_case_key, passed); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await expect(page.getByRole('link', { name: 'Get started - Oops!' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link incorrect - should be @aborted', async ({ page }, testInfo) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.setMaintainer(maintainer); + currentTest.attachLabel('type', 'smoke', 'regression'); xray.testCaseKey('ZEB-19'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started - Oops!' }).click(); @@ -131,18 +131,18 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); xray.testCaseKey('ZEB-20'); }); test('Skipped inside in test', async ({ page }, testInfo) => { xray.testCaseKey('ZEB-20'); await page.goto('https://example.com'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); const conditionToSkip = true; diff --git a/tests/tcm-zbr-web.spec.js b/tests/tcm-zbr-web.spec.js index 0f45ecb..e52a8fa 100644 --- a/tests/tcm-zbr-web.spec.js +++ b/tests/tcm-zbr-web.spec.js @@ -1,6 +1,6 @@ // @ts-check import { pseudoRandomBytes } from 'crypto'; -import { CurrentTest, zebrunner, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, zebrunner, currentLaunch } from '../src/javascript-agent-playwright/index'; const { test, expect } = require('@playwright/test'); @@ -16,17 +16,17 @@ const passed_case_key = 'DEF-4320'; test.describe('Web Testing with Playwright', () => { test.beforeAll(async () => { // will be attached to the entire run - CurrentLaunch.attachLabel('TCM', 'Zebrunner'); - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachLabel('TCM', 'Zebrunner'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); }); test(`Test should be passed, but result for test case ${failed_case_key} should be imported as ${failed}`, async ({ page, }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); zebrunner.testCaseKey('DEF-4321', failed_case_key); zebrunner.testCaseStatus(failed_case_key, failed); @@ -35,26 +35,26 @@ test.describe('Web Testing with Playwright', () => { console.log('Maintainer should be ' + maintainer); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Test should be passed (with console.log() and custom screenshot)', async ({ page }) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); zebrunner.testCaseKey('DEF-4156', 'DEF-4359'); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('INFO level log message on test start'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -62,59 +62,59 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot('artifacts/zeb.png'); + currentTest.log.warn('Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot('artifacts/zeb.png'); console.log('Log should be 1'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); + currentTest.log.info('INFO level log message 1'); console.log('Log should be 2'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); + currentTest.log.error('ERROR level log message 2'); console.log('Log should be 3'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); + currentTest.log.warn('WARN level log message 3'); console.log('Log should be 4'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); + currentTest.log.fatal('FATAL level log message 4'); console.log('Log should be 5'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); + currentTest.log.debug('DEBUG level log message 5'); - CurrentTest.attachLog('Attaching screenshot after log mesage 5', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('Attaching screenshot after log mesage 5'); + currentTest.attachScreenshot(await page.screenshot()); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.trace('TRACE level log message 6'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); console.log('Log should be 1.1'); console.log('Log should be 1.2'); console.log('Log should be 1.3'); - CurrentTest.attachLog('Custom log message example on test finish (without log level, by default should be INFO 8)'); - CurrentTest.attachLog('Attaching screenshot after all logs', 'INFO'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.info('Custom log message example on test finish (without log level, by default should be INFO 8)'); + currentTest.log.info('Attaching screenshot after all logs'); + currentTest.attachScreenshot(await page.screenshot()); }); test(`Test should be @failed but result for case ${passed_case_key} should be ${passed}`, async ({ page }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachLabel('reporting', 'Zebrunner'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachLabel('reporting', 'Zebrunner'); zebrunner.testCaseKey('DEF-4363'); zebrunner.testCaseStatus(passed_case_key, passed); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await expect(page.getByRole('link', { name: 'Get started - Oops!' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link incorrect - should be @aborted', async ({ page }, testInfo) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.setMaintainer(maintainer); + currentTest.attachLabel('type', 'smoke', 'regression'); zebrunner.testCaseKey('DEF-4367'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started - Oops!' }).click(); @@ -128,16 +128,16 @@ test.describe('Web Testing with Playwright', () => { // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); zebrunner.testCaseKey('DEF-4387'); }); @@ -145,7 +145,7 @@ test.describe('Web Testing with Playwright', () => { zebrunner.testCaseKey('DEF-4418'); await page.goto('https://example.com'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); const conditionToSkip = true; diff --git a/tests/tcm-zephyr-web.spec.js b/tests/tcm-zephyr-web.spec.js index 2fd7bb9..2e03b13 100644 --- a/tests/tcm-zephyr-web.spec.js +++ b/tests/tcm-zephyr-web.spec.js @@ -1,6 +1,6 @@ // @ts-check import { pseudoRandomBytes } from 'crypto'; -import { CurrentTest, zephyr, CurrentLaunch } from '../src/javascript-agent-playwright/index'; +import { currentTest, zephyr, currentLaunch } from '../src/javascript-agent-playwright/index'; const { test, expect } = require('@playwright/test'); @@ -16,17 +16,17 @@ const passed_case_key = 'ZEB-T5'; test.describe('Web Testing with Playwright', () => { test.beforeAll(async () => { // will be attached to the entire run - CurrentLaunch.attachLabel('TCM', 'Zephyr'); - CurrentLaunch.attachLabel('automation-type', automation_type); - CurrentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentLaunch.attachLabel('TCM', 'Zephyr'); + currentLaunch.attachLabel('automation-type', automation_type); + currentLaunch.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); }); test(`Test should be passed, but result for test case ${failed_case_key} should be imported as ${failed}`, async ({ page, }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachArtifactReference('Zebrunner', 'https://zebrunner.com'); zephyr.testCaseKey('ZEB-T2'); zephyr.testCaseStatus(failed_case_key, failed); @@ -34,26 +34,26 @@ test.describe('Web Testing with Playwright', () => { console.log('Maintainer should be ' + maintainer); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Test should be passed (with console.log() and custom screenshot)', async ({ page }) => { - CurrentTest.setMaintainer(maintainer); + currentTest.setMaintainer(maintainer); zephyr.testCaseKey('ZEB-T9', 'ZEB-T13'); - CurrentTest.attachLog('INFO level log message on test start', 'INFO'); - CurrentTest.attachLog('Navigating to Google...', 'INFO'); + currentTest.log.info('INFO level log message on test start'); + currentTest.log.info('Navigating to Google...'); await page.goto('https://www.google.com/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); @@ -61,59 +61,59 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Attaching screenshot via PATH on disk', 'WARN'); - CurrentTest.attachScreenshot('artifacts/zeb.png'); + currentTest.log.warn('Attaching screenshot via PATH on disk'); + currentTest.attachScreenshot('artifacts/zeb.png'); console.log('Log should be 1'); - CurrentTest.attachLog('INFO level log message 1', 'INFO'); + currentTest.log.info('INFO level log message 1'); console.log('Log should be 2'); - CurrentTest.attachLog('ERROR level log message 2', 'ERROR'); + currentTest.log.error('ERROR level log message 2'); console.log('Log should be 3'); - CurrentTest.attachLog('WARN level log message 3', 'WARN'); + currentTest.log.warn('WARN level log message 3'); console.log('Log should be 4'); - CurrentTest.attachLog('FATAL level log message 4', 'FATAL'); + currentTest.log.fatal('FATAL level log message 4'); console.log('Log should be 5'); - CurrentTest.attachLog('DEBUG level log message 5', 'DEBUG'); + currentTest.log.debug('DEBUG level log message 5'); - CurrentTest.attachLog('Attaching screenshot after log mesage 5', 'WARN'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.warn('Attaching screenshot after log mesage 5'); + currentTest.attachScreenshot(await page.screenshot()); - CurrentTest.attachLog('TRACE level log message 6', 'TRACE'); - CurrentTest.attachLog('CUSTOM string level log message 7', 'CUSTOM'); + currentTest.log.trace('TRACE level log message 6'); + currentTest.log.custom('CUSTOM string level log message 7', 'CUSTOM'); console.log('Log should be 1.1'); console.log('Log should be 1.2'); console.log('Log should be 1.3'); - CurrentTest.attachLog('Custom log message example on test finish (without log level, by default should be INFO 8)'); - CurrentTest.attachLog('Attaching screenshot after all logs', 'INFO'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.log.info('Custom log message example on test finish (without log level, by default should be INFO 8)'); + currentTest.log.info('Attaching screenshot after all logs'); + currentTest.attachScreenshot(await page.screenshot()); }); test(`Test should be @failed but result for case ${passed_case_key} should be ${passed}`, async ({ page }) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLog('Custom log message example on test start'); - CurrentTest.attachLabel('reporting', 'Zebrunner'); + currentTest.setMaintainer(maintainer); + currentTest.log.info('Custom log message example on test start'); + currentTest.attachLabel('reporting', 'Zebrunner'); zephyr.testCaseKey('ZEB-T1'); zephyr.testCaseStatus(passed_case_key, passed); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await expect(page.getByRole('link', { name: 'Get started - Oops!' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Get started link incorrect - should be @aborted', async ({ page }, testInfo) => { - CurrentTest.setMaintainer(maintainer); - CurrentTest.attachLabel('type', 'smoke', 'regression'); + currentTest.setMaintainer(maintainer); + currentTest.attachLabel('type', 'smoke', 'regression'); zephyr.testCaseKey('ZEB-T12'); await page.goto('https://playwright.dev/'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); // Click the get started link. await page.getByRole('link', { name: 'Get started - Oops!' }).click(); @@ -131,11 +131,11 @@ test.describe('Web Testing with Playwright', () => { // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); - CurrentTest.attachLog('Custom log message example on test finish'); + currentTest.log.info('Custom log message example on test finish'); }); test('Not an important test (This test should not be reported in Zebrunner)', async ({ request }) => { - CurrentTest.revertRegistration(); + currentTest.revertRegistration(); zephyr.testCaseKey('ZEB-T10'); }); @@ -143,7 +143,7 @@ test.describe('Web Testing with Playwright', () => { zephyr.testCaseKey('ZEB-T10'); await page.goto('https://example.com'); - CurrentTest.attachScreenshot(await page.screenshot()); + currentTest.attachScreenshot(await page.screenshot()); const conditionToSkip = true;