Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';

import { ReportingApi } from '@reportportal/agent-js-playwright';

const suiteName = 'Attributes and description repoting';
const suiteName = 'Attributes and description reporting';

test.describe(suiteName, () => {
test.describe(suiteName, () => {
// set description to the suite
ReportingApi.setDescription(
'This suite contains tests with attributes and description provided via ReportingApi',
suiteName,
);
// add attributes to the suite
ReportingApi.addAttributes([
{
key: 'feature',
value: 'attributes',
},
{
key: 'feature',
value: 'description',
},
], suiteName);
ReportingApi.addAttributes([
{
value: 'demo',
},
], suiteName);

test('should be passed, should have the correct attributes and description', async ({ page, browserName }) => {
ReportingApi.addAttributes(
[
{
key: 'feature',
value: 'attributes',
},
{
key: 'feature',
value: 'description',
},
],
suiteName,
);
ReportingApi.addAttributes(
[
{
value: 'demo',
},
],
suiteName,
);

test('should be passed, should have the correct attributes and description', async ({
page,
browserName,
}) => {
// set description to the test
ReportingApi.setDescription('This test just expects Playwright website contains "Playwright" word in the title');
ReportingApi.setDescription(
'This test just expects Playwright website contains "Playwright" word in the title',
);
// add attributes to the test
ReportingApi.addAttributes([
{
Expand All @@ -43,4 +55,44 @@ test.describe(suiteName, () => {
await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
});

test('@tag should be passed with one static attribute reported from the beginning of the title', async ({
page,
browserName,
}) => {
// set description to the test
ReportingApi.setDescription(
'This test just expects to open Playwright website with no tags in the start of the test title',
);
// add attributes to the test
ReportingApi.addAttributes([
{
key: 'browser',
value: browserName,
},
]);

await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
});

test('should be passed with one static attribute reported from the end of the title @tag', async ({
page,
browserName,
}) => {
// set description to the test
ReportingApi.setDescription(
'This test just expects to open Playwright website with no tags in the end of the test title',
);
// add attributes to the test
ReportingApi.addAttributes([
{
key: 'browser',
value: browserName,
},
]);

await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
});
});