import { allure } from 'allure-playwright'; import { OsName } from…
- User
import { allure } from 'allure-playwright'; import { OsName } from '../enums/osName.enum'; import { Component, Epic, Feature } from '../enums/allreHelper.enum';
class AllureHelper { data(data: AllureData): void { data.os ? allure.label('os', data.os) : allure.label('os', 'Manager'); allure.label('component', data.component); allure.epic(
${data.epic}); allure.label('feature', data.feature); } }export const allureHelper = new AllureHelper();
interface AllureData { os?: OsName; feature: Feature; epic: Epic; component: Component; }
если я захочу туда прокинуть еще allure.id для каждого теста, как мне актуализировать метод, если я передаю его в хук beforeAll и beforeEach, чтобы тесты у нас были всегда с одним и тем же id и не дублировались. пример хука: test.describe.parallel('Active Response', () => { let agent: AgentList;
test.beforeAll(async () => { agent = agentService.filterAgent(await storageHelper.getAgentList(), OsName.AlmaLinux, OsVersion.AlmaLinux_8_8)[0]; allureHelper.data({ os: OsName.AlmaLinux, component: Component.API, epic: Epic.ActiveResponse, feature: Feature.ActiveResponse }); });
- Assistant
To handle the scenario where you want to pass an additional
allure.idfor each test, you can modify theAllureHelperclass and theallureHelper.data()method to accept an optionalidparameter. Here's an updated version of the code:class AllureHelper { data(data: AllureData, id?: string): void { // Set the OS label data.os ? allure.label('os', data.os) : allure.label('os', 'Manager'); // Set the component, epic, and feature labels allure.label('component', data.component); allure.epic(`${data.epic}`); allure.label('feature', data.feature); // Set the ID label if provided if (id) { allure.id(id); } } } export const allureHelper = new AllureHelper();Then, in your
beforeAllhook, you can pass theidparameter to theallureHelper.data()method to set theallure.idlabel:test.beforeAll(async () => { agent = agentService.filterAgent(await storageHelper.getAgentList(), OsName.AlmaLinux, OsVersion.AlmaLinux_8_8)[0]; const id = 'your_unique_id'; // Set your unique ID here allureHelper.data({ os: OsName.AlmaLinux, component: Component.API, epic: Epic.ActiveResponse, feature: Feature.ActiveResponse }, id); }); - User
allure id передается строкой или числом?
- Assistant
allure.idaccepts a string as its argument. Therefore, you should pass theidas a string when setting theallure.idlabel. For example:const id = 'your_unique_id'; // Set your unique ID as a string allure.id(id);
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.