@mmisty/cypress-allure-adapter
Version:
cypress allure adapter to generate allure results during tests execution (Allure TestOps compatible)
88 lines (87 loc) • 3.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.processTagsOnTestStart = void 0;
const processTagsOnTestStart = (test) => {
const tags = test === null || test === void 0 ? void 0 : test.tags;
if (!tags || tags.length === 0) {
return;
}
tags.forEach(t => {
var _a, _b, _c, _d, _e;
const tagNoAt = t.tag.slice(1);
switch (tagNoAt) {
case 'tmsWithId':
case 'tms':
case 'issueWithId':
case 'issue': {
const [urlOrId, name] = (_a = t.info) !== null && _a !== void 0 ? _a : [];
if (!urlOrId) {
const message = `tag @${tagNoAt} tag should have id: @${tagNoAt}("idOrUrl")`;
Cypress.log({ name: 'WARNING', message }).error(new Error());
break;
}
Cypress.Allure[tagNoAt](urlOrId, name);
break;
}
case 'link': {
const [urlOrId, name, type] = (_b = t.info) !== null && _b !== void 0 ? _b : [];
if (!urlOrId) {
const message = `tag @${tagNoAt} should have id or url: @${tagNoAt}("idOrUrl")`;
Cypress.log({ name: 'WARNING', message }).error(new Error());
break;
}
Cypress.Allure[tagNoAt](urlOrId, name, type);
break;
}
case 'suite':
case 'parentSuite':
case 'subSuite': {
const [singleValue] = (_c = t.info) !== null && _c !== void 0 ? _c : [];
Cypress.Allure[tagNoAt](singleValue);
break;
}
case 'epic':
case 'feature':
case 'story':
case 'allureId':
case 'language':
case 'severity':
case 'thread':
case 'fullName':
case 'lead':
case 'host':
case 'layer':
case 'browser':
case 'device':
case 'os':
case 'owner': {
const [singleValue] = (_d = t.info) !== null && _d !== void 0 ? _d : [];
if (!singleValue) {
const message = `tag @${tagNoAt} tag should have value: @${tagNoAt}("value")`;
Cypress.log({ name: 'WARNING', message }).error(new Error());
break;
}
Cypress.Allure[tagNoAt](singleValue);
break;
}
case 'label': {
const [name, value] = (_e = t.info) !== null && _e !== void 0 ? _e : [];
if (!name) {
const message = `tag @${tagNoAt} tag should have name and/or value: @${tagNoAt}("myLabel","value")`;
Cypress.log({ name: 'WARNING', message }).error(new Error());
break;
}
Cypress.Allure.label(name, value);
break;
}
default: {
const addTags = Cypress.env('allureAddNonSpecialTags');
if (addTags === 'true' || addTags === true || addTags === undefined) {
Cypress.Allure.tag(t.tag);
}
break;
}
}
});
};
exports.processTagsOnTestStart = processTagsOnTestStart;