allure-jasmine
Advanced tools
Comparing version 2.0.0-beta.9 to 2.0.0-beta.11
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Allure = exports.Severity = exports.ContentType = exports.AllureConfig = exports.AllureRuntime = exports.JasmineConsoleReporter = exports.JasmineAllureReporter = void 0; | ||
exports.Allure = exports.Severity = exports.ContentType = exports.AllureRuntime = exports.JasmineConsoleReporter = exports.JasmineAllureReporter = void 0; | ||
var JasmineAllureReporter_1 = require("./src/JasmineAllureReporter"); | ||
@@ -10,3 +10,2 @@ Object.defineProperty(exports, "JasmineAllureReporter", { enumerable: true, get: function () { return JasmineAllureReporter_1.JasmineAllureReporter; } }); | ||
Object.defineProperty(exports, "AllureRuntime", { enumerable: true, get: function () { return allure_js_commons_1.AllureRuntime; } }); | ||
Object.defineProperty(exports, "AllureConfig", { enumerable: true, get: function () { return allure_js_commons_1.AllureConfig; } }); | ||
Object.defineProperty(exports, "ContentType", { enumerable: true, get: function () { return allure_js_commons_1.ContentType; } }); | ||
@@ -13,0 +12,0 @@ Object.defineProperty(exports, "Severity", { enumerable: true, get: function () { return allure_js_commons_1.Severity; } }); |
/// <reference types="node" /> | ||
/// <reference types="jasmine" /> | ||
import { AllureGroup, AllureRuntime, AllureStep, AllureTest, AttachmentOptions, ContentType, ExecutableItemWrapper, Status, Allure, StepInterface, IAllureConfig } from "allure-js-commons"; | ||
import { Allure, AllureConfig, AllureGroup, AllureRuntime, AllureStep, AllureTest, AttachmentOptions, ContentType, ExecutableItemWrapper, Status, StepInterface } from "allure-js-commons"; | ||
export declare class JasmineAllureReporter implements jasmine.CustomReporter { | ||
@@ -11,4 +11,3 @@ private groupStack; | ||
private readonly runtime; | ||
constructor(config: IAllureConfig); | ||
private getCurrentGroup; | ||
constructor(config: AllureConfig); | ||
get currentGroup(): AllureGroup; | ||
@@ -19,10 +18,8 @@ getInterface(): Allure; | ||
writeAttachment(content: Buffer | string, options: ContentType | string | AttachmentOptions): string; | ||
jasmineStarted(suiteInfo: jasmine.SuiteInfo): void; | ||
jasmineStarted(): void; | ||
suiteStarted(suite: jasmine.CustomReporterResult): void; | ||
specStarted(spec: jasmine.CustomReporterResult): void; | ||
specDone(spec: jasmine.CustomReporterResult): void; | ||
suiteDone(suite: jasmine.CustomReporterResult): void; | ||
jasmineDone(runDetails: jasmine.RunDetails): void; | ||
private findMessageAboutThrow; | ||
private findAnyError; | ||
suiteDone(): void; | ||
jasmineDone(): void; | ||
addLabel(name: string, value: string): void; | ||
@@ -32,2 +29,3 @@ pushStep(step: AllureStep): void; | ||
get currentStep(): AllureStep | null; | ||
private getCurrentGroup; | ||
private installHooks; | ||
@@ -39,8 +37,9 @@ } | ||
label(name: string, value: string): void; | ||
step<T>(name: string, body: (step: StepInterface) => T): T; | ||
logStep(name: string, status?: Status): void; | ||
attachment(name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions): void; | ||
testAttachment(name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions): void; | ||
protected get currentExecutable(): ExecutableItemWrapper; | ||
protected get currentTest(): AllureTest; | ||
private startStep; | ||
step<T>(name: string, body: (step: StepInterface) => any): any; | ||
logStep(name: string, status?: Status): void; | ||
attachment(name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions): void; | ||
} |
@@ -5,2 +5,17 @@ "use strict"; | ||
const allure_js_commons_1 = require("allure-js-commons"); | ||
const findAnyError = (expectations) => { | ||
expectations = expectations || []; | ||
if (expectations.length > 0) { | ||
return expectations[0]; | ||
} | ||
return null; | ||
}; | ||
const findMessageAboutThrow = (expectations) => { | ||
for (const e of expectations || []) { | ||
if (e.matcherName === "") { | ||
return e; | ||
} | ||
} | ||
return null; | ||
}; | ||
var SpecStatus; | ||
@@ -25,11 +40,7 @@ (function (SpecStatus) { | ||
} | ||
getCurrentGroup() { | ||
if (this.groupStack.length === 0) | ||
return null; | ||
return this.groupStack[this.groupStack.length - 1]; | ||
} | ||
get currentGroup() { | ||
const currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error("No active group"); | ||
} | ||
return currentGroup; | ||
@@ -41,4 +52,5 @@ } | ||
get currentTest() { | ||
if (this.runningTest === null) | ||
if (this.runningTest === null) { | ||
throw new Error("No active test"); | ||
} | ||
return this.runningTest; | ||
@@ -52,4 +64,3 @@ } | ||
} | ||
jasmineStarted(suiteInfo) { | ||
} | ||
jasmineStarted() { } | ||
suiteStarted(suite) { | ||
@@ -63,4 +74,5 @@ const name = suite.description; | ||
let currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error("No active suite"); | ||
} | ||
currentGroup = currentGroup.startGroup("Test wrapper"); | ||
@@ -70,4 +82,5 @@ this.groupStack.push(currentGroup); | ||
const allureTest = currentGroup.startTest(name); | ||
if (this.runningTest != null) | ||
if (this.runningTest != null) { | ||
throw new Error("Test is starting before other ended!"); | ||
} | ||
this.runningTest = allureTest; | ||
@@ -94,4 +107,5 @@ allureTest.fullName = spec.fullName; | ||
const currentTest = this.runningTest; | ||
if (currentTest === null) | ||
if (currentTest === null) { | ||
throw new Error("specDone while no test is running"); | ||
} | ||
if (this.stepStack.length > 0) { | ||
@@ -107,4 +121,5 @@ console.error("Allure reporter issue: step stack is not empty on specDone"); | ||
} | ||
if (spec.status === SpecStatus.PENDING || spec.status === SpecStatus.DISABLED | ||
|| spec.status === SpecStatus.EXCLUDED) { | ||
if (spec.status === SpecStatus.PENDING || | ||
spec.status === SpecStatus.DISABLED || | ||
spec.status === SpecStatus.EXCLUDED) { | ||
currentTest.status = allure_js_commons_1.Status.SKIPPED; | ||
@@ -124,4 +139,3 @@ currentTest.stage = allure_js_commons_1.Stage.PENDING; | ||
} | ||
const exceptionInfo = this.findMessageAboutThrow(spec.failedExpectations) | ||
|| this.findAnyError(spec.failedExpectations); | ||
const exceptionInfo = findMessageAboutThrow(spec.failedExpectations) || findAnyError(spec.failedExpectations); | ||
if (exceptionInfo !== null) { | ||
@@ -136,3 +150,3 @@ currentTest.detailsMessage = exceptionInfo.message; | ||
} | ||
suiteDone(suite) { | ||
suiteDone() { | ||
if (this.runningTest !== null) { | ||
@@ -142,4 +156,5 @@ console.error("Allure reporter issue: running test on suiteDone"); | ||
const currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error("No active suite"); | ||
} | ||
currentGroup.endGroup(); | ||
@@ -149,16 +164,3 @@ this.groupStack.pop(); | ||
} | ||
jasmineDone(runDetails) { } | ||
findMessageAboutThrow(expectations) { | ||
for (const e of expectations || []) { | ||
if (e.matcherName === "") | ||
return e; | ||
} | ||
return null; | ||
} | ||
findAnyError(expectations) { | ||
expectations = expectations || []; | ||
if (expectations.length > 0) | ||
return expectations[0]; | ||
return null; | ||
} | ||
jasmineDone() { } | ||
addLabel(name, value) { | ||
@@ -176,6 +178,13 @@ if (this.labelStack.length) { | ||
get currentStep() { | ||
if (this.stepStack.length > 0) | ||
if (this.stepStack.length > 0) { | ||
return this.stepStack[this.stepStack.length - 1]; | ||
} | ||
return null; | ||
} | ||
getCurrentGroup() { | ||
if (this.groupStack.length === 0) { | ||
return null; | ||
} | ||
return this.groupStack[this.groupStack.length - 1]; | ||
} | ||
installHooks() { | ||
@@ -187,5 +196,5 @@ const reporter = this; | ||
const jasmineAfterEach = eval("global.afterEach"); | ||
function makeWrapperAll(wrapped, fun) { | ||
return function (action, timeout) { | ||
wrapped(function (done) { | ||
const makeWrapperAll = (wrapped, fun) => { | ||
return (action, timeout) => { | ||
wrapped((done) => { | ||
reporter.runningExecutable = fun(); | ||
@@ -204,6 +213,8 @@ let ret; | ||
if (allure_js_commons_1.isPromise(ret)) { | ||
ret.then(() => { | ||
ret | ||
.then(() => { | ||
reporter.runningExecutable = null; | ||
done(); | ||
}).catch(e => { | ||
}) | ||
.catch((e) => { | ||
reporter.runningExecutable = null; | ||
@@ -219,3 +230,3 @@ done.fail(e); | ||
}; | ||
} | ||
}; | ||
const wrapperBeforeAll = makeWrapperAll(jasmineBeforeAll, () => reporter.currentGroup.addBefore()); | ||
@@ -245,13 +256,2 @@ const wrapperAfterAll = makeWrapperAll(jasmineAfterAll, () => reporter.currentGroup.addAfter()); | ||
} | ||
get currentExecutable() { | ||
return this.reporter.currentStep || this.reporter.currentExecutable || this.reporter.currentTest; | ||
} | ||
get currentTest() { | ||
return this.reporter.currentTest; | ||
} | ||
startStep(name) { | ||
const allureStep = this.currentExecutable.startStep(name); | ||
this.reporter.pushStep(allureStep); | ||
return new WrappedStep(this.reporter, allureStep); | ||
} | ||
step(name, body) { | ||
@@ -264,2 +264,3 @@ const wrappedStep = this.startStep(name); | ||
catch (err) { | ||
wrappedStep.setError(err); | ||
wrappedStep.endStep(); | ||
@@ -270,6 +271,9 @@ throw err; | ||
const promise = result; | ||
return promise.then(a => { | ||
return promise | ||
.then((a) => { | ||
wrappedStep.endStep(); | ||
return a; | ||
}).catch(e => { | ||
}) | ||
.catch((e) => { | ||
wrappedStep.setError(e); | ||
wrappedStep.endStep(); | ||
@@ -285,3 +289,5 @@ throw e; | ||
logStep(name, status) { | ||
this.step(name, () => { }); | ||
const step = this.startStep(name); | ||
step.setStatus(status); | ||
step.endStep(); | ||
} | ||
@@ -292,2 +298,17 @@ attachment(name, content, options) { | ||
} | ||
testAttachment(name, content, options) { | ||
const file = this.reporter.writeAttachment(content, options); | ||
this.currentTest.addAttachment(name, options, file); | ||
} | ||
get currentExecutable() { | ||
return (this.reporter.currentStep || this.reporter.currentExecutable || this.reporter.currentTest); | ||
} | ||
get currentTest() { | ||
return this.reporter.currentTest; | ||
} | ||
startStep(name) { | ||
const allureStep = this.currentExecutable.startStep(name); | ||
this.reporter.pushStep(allureStep); | ||
return new WrappedStep(this.reporter, allureStep); | ||
} | ||
} | ||
@@ -305,2 +326,10 @@ exports.JasmineAllureInterface = JasmineAllureInterface; | ||
} | ||
setStatus(status) { | ||
this.step.status = status; | ||
} | ||
setError(error) { | ||
this.step.status = allure_js_commons_1.Status.FAILED; | ||
this.step.detailsMessage = error.message; | ||
this.step.detailsTrace = error.stack; | ||
} | ||
endStep() { | ||
@@ -307,0 +336,0 @@ this.reporter.popStep(); |
{ | ||
"name": "allure-jasmine", | ||
"version": "2.0.0-beta.9", | ||
"version": "2.0.0-beta.11", | ||
"description": "Allure Jasmine integration", | ||
@@ -12,4 +12,4 @@ "license": "Apache-2.0", | ||
"clean": "rimraf ./dist ./out", | ||
"lint": "eslint ./src ./test ./index.ts --ext .ts", | ||
"lint-fix": "eslint ./src ./test ./index.ts --ext .ts --fix", | ||
"lint": "eslint ./src ./index.ts --ext .ts", | ||
"lint:fix": "eslint ./src ./index.ts --ext .ts --fix", | ||
"compile": "tsc", | ||
@@ -28,3 +28,3 @@ "build": "npm run lint && npm run compile", | ||
"dependencies": { | ||
"allure-js-commons": "^2.0.0-beta.9" | ||
"allure-js-commons": "^2.0.0-beta.11" | ||
}, | ||
@@ -51,3 +51,3 @@ "nyc": { | ||
}, | ||
"gitHead": "2debbad94a8a7c5d8c88f74413ec44433a4664a8" | ||
"gitHead": "b4fbc98075d36c9e62f7950b12086fc78266be11" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40174
405