allure-cucumberjs
Advanced tools
Comparing version 2.0.0-beta.17 to 2.0.0-beta.18
@@ -45,7 +45,7 @@ "use strict"; | ||
attachment(name, content, options) { | ||
const file = this.reporter.writeAttachment(content, options); | ||
const file = this.runtime.writeAttachment(content, options); | ||
this.currentExecutable.addAttachment(name, options, file); | ||
} | ||
testAttachment(name, content, options) { | ||
const file = this.reporter.writeAttachment(content, options); | ||
const file = this.runtime.writeAttachment(content, options); | ||
this.currentTest.addAttachment(name, options, file); | ||
@@ -66,7 +66,3 @@ } | ||
get currentExecutable() { | ||
const result = this.reporter.currentStep || this.reporter.currentTest; | ||
if (result === null) { | ||
throw new Error("No executable!"); | ||
} | ||
return result; | ||
throw new Error("No executable!"); | ||
} | ||
@@ -81,3 +77,2 @@ get currentTest() { | ||
const allureStep = this.currentExecutable.startStep(name); | ||
this.reporter.pushStep(allureStep); | ||
return new WrappedStep(this.reporter, allureStep); | ||
@@ -94,3 +89,2 @@ } | ||
const step = this.step.startStep(name); | ||
this.reporter.pushStep(step); | ||
return new WrappedStep(this.reporter, step); | ||
@@ -107,3 +101,2 @@ } | ||
endStep() { | ||
this.reporter.popStep(); | ||
this.step.endStep(); | ||
@@ -110,0 +103,0 @@ } |
@@ -1,7 +0,4 @@ | ||
/// <reference types="node" /> | ||
import { Allure, AllureGroup, AllureRuntime, AllureStep, AllureTest, AttachmentOptions, ContentType, ExecutableItemWrapper } from "allure-js-commons"; | ||
import { World as CucumberWorld, Formatter } from "cucumber"; | ||
import { GherkinDocument } from "./events/GherkinDocument"; | ||
import { Result } from "./events/Result"; | ||
import { SourceLocation } from "./events/SourceLocation"; | ||
import { World as CucumberWorld, Formatter } from "@cucumber/cucumber"; | ||
import { IFormatterOptions } from "@cucumber/cucumber/lib/formatter"; | ||
import { Allure, AllureGroup, AllureRuntime, AllureTest, ExecutableItemWrapper } from "allure-js-commons"; | ||
export { Allure } from "allure-js-commons"; | ||
@@ -37,50 +34,33 @@ export interface World extends CucumberWorld { | ||
private readonly exceptionFormatter; | ||
private readonly featureMap; | ||
private readonly labels; | ||
private readonly links; | ||
private stepStack; | ||
private readonly documentMap; | ||
private readonly featureMap; | ||
private readonly scenarioMap; | ||
private readonly stepMap; | ||
private readonly testStepMap; | ||
private readonly pickleStepMap; | ||
private readonly stepDefinitionMap; | ||
private readonly testCaseTestStepsResults; | ||
private readonly pickleMap; | ||
private readonly hookMap; | ||
private readonly sourceMap; | ||
private stepStack; | ||
private readonly stepsMap; | ||
constructor(options: any, allureRuntime: AllureRuntime, config: CucumberJSAllureFormatterConfig); | ||
get currentStep(): AllureStep | null; | ||
onGherkinDocument(data: { | ||
uri: string; | ||
document: GherkinDocument; | ||
}): void; | ||
onSource(data: { | ||
uri: string; | ||
data: string; | ||
media: { | ||
encoding: string; | ||
type: string; | ||
}; | ||
}): void; | ||
onTestCaseFinished(data: { | ||
result: Result; | ||
} & SourceLocation): void; | ||
onTestCasePrepared(data: { | ||
steps: SourceLocation[]; | ||
} & SourceLocation): void; | ||
onTestCaseStarted(data: SourceLocation): void; | ||
onTestStepAttachment(data: { | ||
index: number; | ||
data: string; | ||
media: { | ||
type: string; | ||
}; | ||
testCase: SourceLocation; | ||
}): void; | ||
onTestStepFinished(data: { | ||
index: number; | ||
result: Result; | ||
testCase: SourceLocation; | ||
}): void; | ||
onTestStepStarted(data: { | ||
index: number; | ||
testCase: SourceLocation; | ||
}): void; | ||
popStep(): void; | ||
pushStep(step: AllureStep): void; | ||
writeAttachment(content: Buffer | string, options: ContentType | string | AttachmentOptions): string; | ||
private setException; | ||
private readonly testCaseMap; | ||
private readonly testCaseStartedMap; | ||
private readonly allureSteps; | ||
constructor(options: IFormatterOptions, allureRuntime: AllureRuntime, config: CucumberJSAllureFormatterConfig); | ||
private parseEnvelope; | ||
private onGherkinDocument; | ||
private onScenario; | ||
private onPickle; | ||
private onTestCase; | ||
private onTestCaseStarted; | ||
private onAttachment; | ||
private onTestCaseFinished; | ||
private onHook; | ||
private onSource; | ||
private onTestStepStarted; | ||
private onTestStepFinished; | ||
private convertStatus; | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CucumberJSAllureFormatter = exports.CucumberJSAllureFormatterConfig = exports.Allure = void 0; | ||
const cucumber_1 = require("@cucumber/cucumber"); | ||
const messages = __importStar(require("@cucumber/messages")); | ||
const messages_1 = require("@cucumber/messages"); | ||
const allure_js_commons_1 = require("allure-js-commons"); | ||
const cucumber_1 = require("cucumber"); | ||
const CucumberAllureInterface_1 = require("./CucumberAllureInterface"); | ||
const Example_1 = require("./events/Example"); | ||
const SourceLocation_1 = require("./events/SourceLocation"); | ||
const utilities_1 = require("./utilities"); | ||
var allure_js_commons_2 = require("allure-js-commons"); | ||
@@ -23,15 +41,31 @@ Object.defineProperty(exports, "Allure", { enumerable: true, get: function () { return allure_js_commons_2.Allure; } }); | ||
this.currentTest = null; | ||
this.stepStack = []; | ||
this.documentMap = new Map(); | ||
this.featureMap = new Map(); | ||
this.scenarioMap = new Map(); | ||
this.stepMap = new Map(); | ||
this.testStepMap = new Map(); | ||
this.pickleStepMap = new Map(); | ||
this.stepDefinitionMap = new Map(); | ||
this.testCaseTestStepsResults = new Map(); | ||
this.pickleMap = new Map(); | ||
this.hookMap = new Map(); | ||
this.sourceMap = new Map(); | ||
this.stepStack = []; | ||
this.stepsMap = new Map(); | ||
options.eventBroadcaster | ||
.on("source", this.onSource.bind(this)) | ||
.on("gherkin-document", this.onGherkinDocument.bind(this)) | ||
.on("test-case-prepared", this.onTestCasePrepared.bind(this)) | ||
.on("test-case-started", this.onTestCaseStarted.bind(this)) | ||
.on("test-step-started", this.onTestStepStarted.bind(this)) | ||
.on("test-step-attachment", this.onTestStepAttachment.bind(this)) | ||
.on("test-step-finished", this.onTestStepFinished.bind(this)) | ||
.on("test-case-finished", this.onTestCaseFinished.bind(this)); | ||
this.testCaseMap = new Map(); | ||
this.testCaseStartedMap = new Map(); | ||
this.allureSteps = new Map(); | ||
this.convertStatus = (status) => { | ||
switch (status) { | ||
case messages_1.TestStepResultStatus.FAILED: | ||
return allure_js_commons_1.Status.FAILED; | ||
case messages_1.TestStepResultStatus.PASSED: | ||
return allure_js_commons_1.Status.PASSED; | ||
case messages_1.TestStepResultStatus.SKIPPED: | ||
case messages_1.TestStepResultStatus.PENDING: | ||
return allure_js_commons_1.Status.SKIPPED; | ||
default: | ||
return undefined; | ||
} | ||
}; | ||
options.eventBroadcaster.on("envelope", this.parseEnvelope.bind(this)); | ||
this.labels = config.labels || {}; | ||
@@ -55,252 +89,215 @@ this.links = config.links || {}; | ||
} | ||
get currentStep() { | ||
if (this.stepStack.length > 0) { | ||
return this.stepStack[this.stepStack.length - 1]; | ||
parseEnvelope(envelope) { | ||
if (envelope.gherkinDocument) { | ||
this.onGherkinDocument(envelope.gherkinDocument); | ||
} | ||
return null; | ||
else if (envelope.pickle) { | ||
this.onPickle(envelope.pickle); | ||
} | ||
else if (envelope.testCase) { | ||
this.onTestCase(envelope.testCase); | ||
} | ||
else if (envelope.testCaseStarted) { | ||
this.onTestCaseStarted(envelope.testCaseStarted); | ||
} | ||
else if (envelope.testCaseFinished) { | ||
this.onTestCaseFinished(envelope.testCaseFinished); | ||
} | ||
else if (envelope.attachment) { | ||
this.onAttachment(envelope.attachment); | ||
} | ||
else if (envelope.hook) { | ||
this.onHook(envelope.hook); | ||
} | ||
else if (envelope.source) { | ||
this.onSource(envelope.source); | ||
} | ||
else if (envelope.testStepStarted) { | ||
this.onTestStepStarted(envelope.testStepStarted); | ||
} | ||
else if (envelope.testStepFinished) { | ||
this.onTestStepFinished(envelope.testStepFinished); | ||
} | ||
} | ||
onGherkinDocument(data) { | ||
data.document.caseMap = new Map(); | ||
data.document.stepMap = new Map(); | ||
if (data.document.feature !== undefined) { | ||
for (const test of data.document.feature.children || []) { | ||
test.stepMap = new Map(); | ||
if (test.type === "Background") { | ||
data.document.stepMap = new Map(); | ||
for (const step of test.steps) { | ||
step.isBackground = true; | ||
data.document.stepMap.set(step.location.line, step); | ||
} | ||
} | ||
else { | ||
for (const step of test.steps) { | ||
test.stepMap.set(step.location.line, step); | ||
} | ||
} | ||
if (test.type === "ScenarioOutline") { | ||
for (const example of (0, Example_1.examplesToSensibleFormat)(test.examples || [])) { | ||
const copy = Object.assign({}, test); | ||
copy.example = example; | ||
data.document.caseMap.set(example.line, copy); | ||
} | ||
} | ||
else { | ||
data.document.caseMap.set(test.location.line, test); | ||
} | ||
var _a, _b; | ||
if (data.uri) { | ||
this.documentMap.set(data.uri, data); | ||
} | ||
(_b = (_a = data.feature) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.forEach((fc) => { | ||
if (fc.scenario) { | ||
this.onScenario(fc.scenario); | ||
} | ||
} | ||
this.featureMap.set(data.uri, data.document); | ||
}); | ||
} | ||
onSource(data) { | ||
this.sourceMap.set(data.uri, data.data.split(/\n/)); | ||
onScenario(data) { | ||
this.scenarioMap.set(data.id, data); | ||
data.steps.forEach((step) => this.stepMap.set(step.id, step)); | ||
} | ||
onTestCaseFinished(data) { | ||
if (this.currentTest === null || this.currentGroup === null) { | ||
throw new Error("No current test info"); | ||
} | ||
this.currentTest.status = (0, utilities_1.statusTextToAllure)(data.result.status); | ||
this.currentTest.stage = (0, utilities_1.statusTextToStage)(data.result.status); | ||
this.setException(this.currentTest, data.result.exception); | ||
this.currentTest.endTest(); | ||
this.currentGroup.endGroup(); | ||
onPickle(data) { | ||
this.pickleMap.set(data.id, data); | ||
data.steps.forEach((ps) => this.pickleStepMap.set(ps.id, ps)); | ||
} | ||
onTestCasePrepared(data) { | ||
this.stepsMap.clear(); | ||
this.stepsMap.set(SourceLocation_1.SourceLocation.toKey(data), data.steps); | ||
this.currentBefore = null; | ||
this.currentAfter = null; | ||
onTestCase(data) { | ||
this.testCaseMap.set(data.id, data); | ||
data.testSteps.forEach((ts) => this.testStepMap.set(ts.id, ts)); | ||
} | ||
onTestCaseStarted(data) { | ||
const feature = this.featureMap.get(data.sourceLocation.uri); | ||
if (feature === undefined || feature.feature === undefined) { | ||
throw new Error("Unknown feature"); | ||
var _a, _b, _c, _d, _e; | ||
const testCase = this.testCaseMap.get(data.testCaseId); | ||
if (!testCase) { | ||
console.error("onTestCaseStarted", "test case not found", data); | ||
return; | ||
} | ||
const test = feature.caseMap === undefined ? undefined : feature.caseMap.get(data.sourceLocation.line); | ||
if (test === undefined) { | ||
throw new Error("Unknown scenario"); | ||
const pickle = this.pickleMap.get(testCase.pickleId); | ||
if (!pickle) { | ||
console.error("onTestCaseStarted", "pickle not found", data); | ||
return; | ||
} | ||
this.currentGroup = this.allureRuntime.startGroup(); | ||
this.currentTest = this.currentGroup.startTest((0, utilities_1.applyExample)(test.name || "Unnamed test", test.example)); | ||
const info = { | ||
uri: data.sourceLocation.uri, | ||
f: feature.feature.name, | ||
t: test.name, | ||
a: null, | ||
}; | ||
if (test.example !== undefined) { | ||
info.a = test.example.arguments; | ||
for (const prop in test.example.arguments) { | ||
if (!test.example.arguments[prop]) { | ||
continue; | ||
} | ||
this.currentTest.addParameter(prop, test.example.arguments[prop]); | ||
const doc = this.documentMap.get(pickle.uri); | ||
const scenarioId = (_a = pickle === null || pickle === void 0 ? void 0 : pickle.astNodeIds) === null || _a === void 0 ? void 0 : _a[0]; | ||
const scenario = this.scenarioMap.get(scenarioId); | ||
this.testCaseStartedMap.set(data.id, data); | ||
this.testCaseTestStepsResults.set(data.id, []); | ||
this.currentTest = new allure_js_commons_1.AllureTest(this.allureRuntime, Date.now()); | ||
this.currentTest.name = pickle.name; | ||
(_b = this.currentTest) === null || _b === void 0 ? void 0 : _b.addLabel(allure_js_commons_1.LabelName.LANGUAGE, "javascript"); | ||
(_c = this.currentTest) === null || _c === void 0 ? void 0 : _c.addLabel(allure_js_commons_1.LabelName.FRAMEWORK, "cucumberjs"); | ||
if (doc === null || doc === void 0 ? void 0 : doc.feature) { | ||
this.currentTest.addLabel(allure_js_commons_1.LabelName.FEATURE, doc.feature.name); | ||
} | ||
if (scenario) { | ||
(_d = this.currentTest) === null || _d === void 0 ? void 0 : _d.addLabel(allure_js_commons_1.LabelName.SUITE, scenario.name); | ||
} | ||
if ((_e = pickle.tags) === null || _e === void 0 ? void 0 : _e.length) { | ||
pickle.tags.forEach((tag) => { | ||
var _a; | ||
(_a = this.currentTest) === null || _a === void 0 ? void 0 : _a.addLabel(allure_js_commons_1.LabelName.TAG, tag.name); | ||
}); | ||
} | ||
pickle.steps.forEach((ps) => { | ||
const { argument } = ps; | ||
if (!this.currentTest || !(argument === null || argument === void 0 ? void 0 : argument.dataTable)) { | ||
return; | ||
} | ||
const csvDataTable = argument.dataTable.rows.reduce((acc, row) => `${acc + row.cells.map((cell) => cell.value).join(",")}\n`, ""); | ||
const attachmentFilename = this.allureRuntime.writeAttachment(csvDataTable, "text/csv"); | ||
this.currentTest.addAttachment("Data table", { | ||
contentType: "text/csv", | ||
}, attachmentFilename); | ||
}); | ||
if (!scenario) { | ||
return; | ||
} | ||
this.currentTest.historyId = (0, utilities_1.hash)(JSON.stringify(info)); | ||
this.currentTest.addLabel(allure_js_commons_1.LabelName.THREAD, `${process.pid}`); | ||
this.currentTest.fullName = `${data.sourceLocation.uri}:${feature.feature.name}:${test.name || "unknown"}`; | ||
this.currentTest.addLabel(allure_js_commons_1.LabelName.FEATURE, feature.feature.name); | ||
this.currentTest.description = (0, utilities_1.stripIndent)(test.description || ""); | ||
for (const tag of [...(test.tags || []), ...feature.feature.tags]) { | ||
this.currentTest.addLabel(allure_js_commons_1.LabelName.TAG, tag.name); | ||
for (const label in this.labels) { | ||
if (!this.labels[label]) { | ||
continue; | ||
} | ||
for (const reg of this.labels[label]) { | ||
const match = tag.name.match(reg); | ||
if (match != null && match.length > 1) { | ||
this.currentTest.addLabel(label, match[1]); | ||
} | ||
} | ||
if (scenario.examples.length === 0) { | ||
return; | ||
} | ||
scenario.examples.forEach((example) => { | ||
var _a; | ||
if (!this.currentTest) { | ||
return; | ||
} | ||
if (this.links.issue) { | ||
for (const reg of this.links.issue.pattern) { | ||
const match = tag.name.match(reg); | ||
if (match != null && match.length > 1) { | ||
this.currentTest.addIssueLink(this.links.issue.urlTemplate.replace("%s", match[1]), match[1]); | ||
} | ||
} | ||
const csvDataTableHeader = ((_a = example === null || example === void 0 ? void 0 : example.tableHeader) === null || _a === void 0 ? void 0 : _a.cells.map((cell) => cell.value).join(",")) || ""; | ||
const csvDataTableBody = (example === null || example === void 0 ? void 0 : example.tableBody.map((row) => row.cells.map((cell) => cell.value).join(",")).join("\n")) || | ||
""; | ||
if (!csvDataTableHeader && !csvDataTableBody) { | ||
return; | ||
} | ||
if (this.links.tms) { | ||
for (const reg of this.links.tms.pattern) { | ||
const match = tag.name.match(reg); | ||
if (match != null && match.length > 1) { | ||
this.currentTest.addTmsLink(this.links.tms.urlTemplate.replace("%s", match[1]), match[1]); | ||
} | ||
} | ||
} | ||
} | ||
const csvDataTable = `${csvDataTableHeader}\n${csvDataTableBody}\n`; | ||
const attachmentFilename = this.allureRuntime.writeAttachment(csvDataTable, "text/csv"); | ||
this.currentTest.addAttachment("Examples", { | ||
contentType: "text/csv", | ||
}, attachmentFilename); | ||
}); | ||
} | ||
onTestStepAttachment(data) { | ||
if (this.currentStep === null) { | ||
throw new Error("There is no step to add attachment to"); | ||
onAttachment(data) { | ||
if (!this.currentTest) { | ||
return; | ||
} | ||
const type = data.media.type; | ||
let content = data.data; | ||
if ([allure_js_commons_1.ContentType.JPEG, allure_js_commons_1.ContentType.PNG, allure_js_commons_1.ContentType.WEBM].includes(type)) { | ||
content = Buffer.from(content, "base64"); | ||
if (!data) { | ||
console.error("onAttachment", "attachment can't be empty"); | ||
return; | ||
} | ||
const file = this.allureRuntime.writeAttachment(content, { contentType: type }); | ||
this.currentStep.addAttachment("attached", type, file); | ||
const { fileName = "attachment", body, mediaType } = data; | ||
const attachmentFilename = this.allureRuntime.writeAttachment(body, mediaType); | ||
this.currentTest.addAttachment(fileName, { | ||
contentType: mediaType, | ||
}, attachmentFilename); | ||
} | ||
onTestStepFinished(data) { | ||
const currentStep = this.currentStep; | ||
if (currentStep === null) { | ||
throw new Error("No current step defined"); | ||
onTestCaseFinished(data) { | ||
if (!this.currentTest) { | ||
console.error("onTestCaseFinished", "current test not found", data); | ||
return; | ||
} | ||
currentStep.status = (0, utilities_1.statusTextToAllure)(data.result.status); | ||
currentStep.stage = (0, utilities_1.statusTextToStage)(data.result.status); | ||
this.setException(currentStep, data.result.exception); | ||
currentStep.endStep(); | ||
this.popStep(); | ||
} | ||
onTestStepStarted(data) { | ||
const location = (this.stepsMap.get(SourceLocation_1.SourceLocation.toKey(data.testCase)) || [])[data.index]; | ||
const feature = this.featureMap.get(data.testCase.sourceLocation.uri); | ||
if (feature === undefined) { | ||
throw new Error("Unknown feature"); | ||
const testCaseStarted = this.testCaseStartedMap.get(data.testCaseStartedId); | ||
if (!testCaseStarted) { | ||
console.error("onTestCaseFinished", "testCaseStarted event not found", data); | ||
return; | ||
} | ||
const test = feature.caseMap === undefined | ||
? undefined | ||
: feature.caseMap.get(data.testCase.sourceLocation.line); | ||
if (test === undefined) { | ||
throw new Error("Unknown scenario"); | ||
const testCase = this.testCaseMap.get(testCaseStarted.testCaseId); | ||
if (!testCase) { | ||
console.error("onTestCaseFinished", "testCase not found", data); | ||
return; | ||
} | ||
let step; | ||
if (location.sourceLocation !== undefined && feature.stepMap !== undefined) { | ||
step = | ||
test.stepMap.get(location.sourceLocation.line) || | ||
feature.stepMap.get(location.sourceLocation.line); | ||
const pickle = this.pickleMap.get(testCase.pickleId); | ||
if (!pickle) { | ||
console.error("onTestCaseFinished", "pickle not found", data); | ||
return; | ||
} | ||
else { | ||
if (location.actionLocation === undefined) { | ||
location.actionLocation = { | ||
uri: "unknown", | ||
line: -1, | ||
}; | ||
} | ||
step = { | ||
location: { line: -1 }, | ||
text: `${location.actionLocation.uri}:${location.actionLocation.line}`, | ||
keyword: "", | ||
const testStepResults = this.testCaseTestStepsResults.get(testCaseStarted.id); | ||
if (testStepResults === null || testStepResults === void 0 ? void 0 : testStepResults.length) { | ||
const worstTestStepResult = messages.getWorstTestStepResult(testStepResults); | ||
this.currentTest.status = this.convertStatus(worstTestStepResult.status); | ||
this.currentTest.statusDetails = { | ||
message: worstTestStepResult.message, | ||
}; | ||
} | ||
if (step === undefined) { | ||
throw new Error("Unknown step"); | ||
else { | ||
this.currentTest.status = allure_js_commons_1.Status.PASSED; | ||
} | ||
let stepText = (0, utilities_1.applyExample)(`${step.keyword || ""}${step.text || "unknown"}`, test.example); | ||
const isAfter = this.afterHooks.find(({ uri, line }) => { | ||
if (location.actionLocation === undefined) { | ||
return false; | ||
} | ||
return uri === location.actionLocation.uri && line === location.actionLocation.line; | ||
}); | ||
const isBefore = this.beforeHooks.find(({ uri, line }) => { | ||
if (location.actionLocation === undefined) { | ||
return false; | ||
} | ||
return uri === location.actionLocation.uri && line === location.actionLocation.line; | ||
}); | ||
if (step.isBackground) { | ||
if (this.currentBefore === null) { | ||
this.currentBefore = this.currentGroup.addBefore(); | ||
} | ||
this.currentTest.endTest(Date.now()); | ||
} | ||
onHook(data) { | ||
this.hookMap.set(data.id, data); | ||
} | ||
onSource(data) { | ||
if (data.uri) { | ||
this.sourceMap.set(data.uri, data); | ||
} | ||
else if (isBefore) { | ||
if (this.currentBefore === null) { | ||
this.currentBefore = this.currentGroup.addBefore(); | ||
} | ||
stepText = `Before: ${isBefore.code.name || step.text || "unknown"}`; | ||
} | ||
onTestStepStarted(data) { | ||
if (!this.currentTest) { | ||
return; | ||
} | ||
else if (isAfter) { | ||
if (this.currentAfter === null) { | ||
this.currentAfter = this.currentGroup.addAfter(); | ||
} | ||
stepText = `After: ${isAfter.code.name || step.text || "unknown"}`; | ||
const testStep = this.testStepMap.get(data.testStepId); | ||
if (!testStep) { | ||
console.error("onTestStepStarted", "can't find step", data); | ||
return; | ||
} | ||
else { | ||
if (this.currentBefore !== null) { | ||
this.currentBefore = null; | ||
if (testStep.pickleStepId) { | ||
const ps = this.pickleStepMap.get(testStep.pickleStepId); | ||
if (!ps) { | ||
return; | ||
} | ||
if (this.currentAfter !== null) { | ||
this.currentAfter = null; | ||
} | ||
const keyword = ps.astNodeIds | ||
.map((astNodeId) => this.stepMap.get(astNodeId)) | ||
.map((step) => step === null || step === void 0 ? void 0 : step.keyword) | ||
.find((kw) => kw !== undefined) || ""; | ||
const allureStep = this.currentTest.startStep(keyword + ps.text, Date.now()); | ||
this.allureSteps.set(data.testStepId, allureStep); | ||
} | ||
const allureStep = (this.currentAfter || this.currentBefore || this.currentTest).startStep(stepText); | ||
this.pushStep(allureStep); | ||
if (step.argument !== undefined) { | ||
if (step.argument.content !== undefined) { | ||
const file = this.allureRuntime.writeAttachment(step.argument.content, { | ||
contentType: allure_js_commons_1.ContentType.TEXT, | ||
}); | ||
allureStep.addAttachment("Text", allure_js_commons_1.ContentType.TEXT, file); | ||
} | ||
if (step.argument.rows !== undefined) { | ||
const file = this.allureRuntime.writeAttachment(step.argument.rows | ||
.map((row) => row.cells.map((cell) => cell.value.replace(/\t/g, " ")).join("\t")) | ||
.join("\n"), { contentType: allure_js_commons_1.ContentType.TSV }); | ||
allureStep.addAttachment("Table", allure_js_commons_1.ContentType.TSV, file); | ||
} | ||
} | ||
} | ||
popStep() { | ||
this.stepStack.pop(); | ||
} | ||
pushStep(step) { | ||
this.stepStack.push(step); | ||
} | ||
writeAttachment(content, options) { | ||
return this.allureRuntime.writeAttachment(content, options); | ||
} | ||
setException(target, exception) { | ||
if (exception !== undefined) { | ||
if (typeof exception === "string") { | ||
target.detailsMessage = this.exceptionFormatter(exception); | ||
} | ||
else { | ||
target.detailsMessage = this.exceptionFormatter(exception.message || "Error.message === undefined"); | ||
target.detailsTrace = exception.stack || ""; | ||
} | ||
onTestStepFinished(data) { | ||
var _a; | ||
(_a = this.testCaseTestStepsResults.get(data.testCaseStartedId)) === null || _a === void 0 ? void 0 : _a.push(data.testStepResult); | ||
if (!this.currentTest) { | ||
return; | ||
} | ||
const allureStep = this.allureSteps.get(data.testStepId); | ||
if (!allureStep) { | ||
return; | ||
} | ||
allureStep.detailsMessage = data.testStepResult.message; | ||
allureStep.status = this.convertStatus(data.testStepResult.status); | ||
allureStep.endStep(Date.now()); | ||
} | ||
@@ -307,0 +304,0 @@ } |
{ | ||
"name": "allure-cucumberjs", | ||
"version": "2.0.0-beta.17", | ||
"version": "2.0.0-beta.18", | ||
"description": "Allure Cucumber.JS integration", | ||
@@ -15,11 +15,10 @@ "license": "Apache-2.0", | ||
"clean": "rimraf ./dist ./out", | ||
"lint": "eslint ./src ./features ./index.ts --ext .ts", | ||
"lint:fix": "eslint --fix ./src ./features ./index.ts --ext .ts", | ||
"lint": "eslint ./src ./index.ts --ext .ts", | ||
"lint:fix": "eslint --fix ./src ./index.ts --ext .ts", | ||
"compile": "tsc", | ||
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean", | ||
"test": "cucumber-js --require ./dist/features/step_definitions/ --require ./dist/features/support/ --format ./dist/features/support/report.js:./dist/dummy.txt" | ||
"test": "nyc ts-node --project test/tsconfig.json test/runner.ts" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.11", | ||
"@types/cucumber": "^6.0.1", | ||
"@types/chai": "^4.2.21", | ||
"@types/fs-extra": "^9.0.1", | ||
@@ -30,8 +29,10 @@ "@types/glob": "^7.1.4", | ||
"@types/verror": "^1.10.3", | ||
"chai": "^4.2.0", | ||
"allure-mocha": "2.0.0-beta.18", | ||
"chai": "^4.3.4", | ||
"chai-like": "^1.1.1", | ||
"cucumber": "^6.0.5", | ||
"eslint": "^7.32.0", | ||
"fs-extra": "^10.0.0", | ||
"glob": "^7.1.6", | ||
"glob": "^7.1.7", | ||
"mocha": "^9.1.1", | ||
"nyc": "^15.1.0", | ||
"path": "^0.12.7", | ||
@@ -45,3 +46,8 @@ "prettier": "^2.3.2", | ||
"dependencies": { | ||
"allure-js-commons": "2.0.0-beta.17" | ||
"@cucumber/cucumber": "^8.3.1", | ||
"@cucumber/gherkin": "^24.0.0", | ||
"@cucumber/gherkin-streams": "^5.0.1", | ||
"@cucumber/gherkin-utils": "^8.0.0", | ||
"@cucumber/messages": "^19.1.2", | ||
"allure-js-commons": "2.0.0-beta.18" | ||
}, | ||
@@ -48,0 +54,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50876
6
20
12
512
1
+ Added@cucumber/cucumber@^8.3.1
+ Added@cucumber/gherkin@^24.0.0
+ Added@cucumber/messages@^19.1.2
+ Added@babel/runtime@7.26.7(transitive)
+ Added@colors/colors@1.5.0(transitive)
+ Added@cucumber/ci-environment@9.1.0(transitive)
+ Added@cucumber/cucumber@8.11.1(transitive)
+ Added@cucumber/cucumber-expressions@16.1.1(transitive)
+ Added@cucumber/gherkin@24.1.025.0.226.0.327.0.0(transitive)
+ Added@cucumber/gherkin-streams@5.0.1(transitive)
+ Added@cucumber/gherkin-utils@8.0.28.0.6(transitive)
+ Added@cucumber/html-formatter@20.2.1(transitive)
+ Added@cucumber/message-streams@4.0.1(transitive)
+ Added@cucumber/messages@19.1.421.0.122.0.024.1.0(transitive)
+ Added@cucumber/tag-expressions@5.0.1(transitive)
+ Added@teppeis/multimaps@2.0.03.0.0(transitive)
+ Added@types/lodash@4.17.15(transitive)
+ Added@types/uuid@8.3.49.0.19.0.8(transitive)
+ Addedallure-js-commons@2.0.0-beta.18(transitive)
+ Addedansi-regex@4.1.15.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedany-promise@1.3.0(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedassertion-error-formatter@3.0.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcapital-case@1.0.4(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedclass-transformer@0.5.1(transitive)
+ Addedcli-table3@0.6.3(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@11.1.09.1.09.4.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddiff@4.0.2(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addederror-stack-parser@2.1.4(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedextsprintf@1.4.1(transitive)
+ Addedfigures@3.2.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglobal-dirs@3.0.1(transitive)
+ Addedhas-ansi@4.0.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@2.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-installed-globally@0.4.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedknuth-shuffle-seeded@1.0.6(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash-es@4.17.21(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedlodash.mergewith@4.6.2(transitive)
+ Addedlower-case@2.0.2(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedluxon@3.2.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addedmz@2.7.0(transitive)
+ Addednanoclone@0.2.1(transitive)
+ Addedno-case@3.0.4(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpad-right@0.2.2(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedproperty-expr@2.0.6(transitive)
+ Addedreflect-metadata@0.1.130.2.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedregexp-match-indices@1.0.2(transitive)
+ Addedregexp-tree@0.1.27(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-from@5.0.0(transitive)
+ Addedresolve-pkg@2.0.0(transitive)
+ Addedseed-random@2.2.0(transitive)
+ Addedsemver@7.3.8(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedstackframe@1.3.4(transitive)
+ Addedstring-argv@0.3.2(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.08.1.1(transitive)
+ Addedthenify@3.3.1(transitive)
+ Addedthenify-all@1.6.0(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedtoposort@2.0.2(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedupper-case-first@2.0.2(transitive)
+ Addedutil-arity@1.1.0(transitive)
+ Addeduuid@9.0.09.0.1(transitive)
+ Addedverror@1.10.1(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxmlbuilder@15.1.1(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyaml@1.10.2(transitive)
+ Addedyup@0.32.11(transitive)
- Removedallure-js-commons@2.0.0-beta.17(transitive)