Skip to content

Commit 9deaf08

Browse files
Valeria-Zimnitskayailyabrower
authored andcommitted
[chore] add component label to allure
1 parent 94838fe commit 9deaf08

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tools/testing-utils/playwright.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import AxeBuilder from '@axe-core/playwright';
22
import { voiceOverTest as voiceOverBase, nvdaTest as nvdaBase } from '@guidepup/playwright';
33
import { test as base } from '@playwright/test';
4-
import { feature, story, suite } from 'allure-js-commons';
4+
import { feature, label, story, suite } from 'allure-js-commons';
55
import type axe from 'axe-core';
66
import type { Page } from 'playwright';
77
import type { TestInfo } from 'playwright/types/test';
@@ -36,11 +36,19 @@ export const skipButtonComboboxDiscernibleErrors = (v: axe.Result) => {
3636
const beforeEachTests = async ({}, use: () => Promise<void>, testInfo: TestInfo) => {
3737
const filePathParts = testInfo.file.split('/');
3838

39-
const testsIndex = filePathParts.findIndex((part) => part === '__tests__');
39+
let component = 'unknown-component';
4040

41-
const component = testsIndex > 0 ? filePathParts[testsIndex - 1] : 'unknown-component';
41+
const semcoreIndex = filePathParts.findLastIndex((part) => part === 'semcore');
42+
if (semcoreIndex >= 0 && semcoreIndex + 2 < filePathParts.length) {
43+
const potentialComponent = filePathParts[semcoreIndex + 1];
44+
const potentialTests = filePathParts[semcoreIndex + 2];
45+
if (potentialTests === '__tests__') {
46+
component = potentialComponent;
47+
}
48+
}
4249

4350
feature(component);
51+
label('Component', component);
4452

4553
if (testInfo.titlePath.length > 2) {
4654
story(testInfo.titlePath[1]);

0 commit comments

Comments
 (0)