From f7544a024df9bd56c94e44ac7a95506c4f200871 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Tue, 5 Mar 2019 10:40:05 +0300 Subject: [PATCH] add method "addLabel" for allure --- lib/plugin/allure.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/plugin/allure.js b/lib/plugin/allure.js index af79c1bbc..f7c9e17d5 100644 --- a/lib/plugin/allure.js +++ b/lib/plugin/allure.js @@ -1,5 +1,6 @@ const event = require('../event'); const Allure = require('allure-js-commons'); +const logger = require('../output'); const defaultConfig = { outputDir: global.output_dir, @@ -61,6 +62,16 @@ module.exports = (config) => { reporter.addAttachment(name, buffer, type); }; + this.addLabel = (name, value) => { + const currentTest = reporter.getCurrentTest(); + if (currentTest) { + currentTest.addLabel(name, value); + } else { + logger.error(`The test is not run. Please use "addLabel" for events: + "test.start", "test.before", "test.after", "test.passed", "test.failed", "test.finish"`); + } + }; + event.dispatcher.on(event.suite.before, (suite) => { reporter.startSuite(suite.fullTitle()); });