jest-allure2
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -0,1 +1,8 @@ | ||
## [1.2.3](https://github.com/ryparker/jest-allure2/compare/v1.2.2...v1.2.3) (2020-07-22) | ||
### Bug Fixes | ||
* **types:** fixed global type declaration ([a57f7f6](https://github.com/ryparker/jest-allure2/commit/a57f7f6e46612f00bafd2f25273c209c2bcc719c)) | ||
# [1.1.0](https://github.com/ryparker/jest-allure/compare/v1.0.5...v1.1.0) (2020-05-04) | ||
@@ -10,4 +17,1 @@ | ||
## 1.0.4 (2020-05-04) | ||
export { registerAllure } from './setup'; | ||
export { JasmineAllureReporter, JasmineAllureInterface, WrappedStep } from './reporter'; | ||
export * from 'allure-js-commons'; |
@@ -15,3 +15,7 @@ "use strict"; | ||
Object.defineProperty(exports, "registerAllure", { enumerable: true, get: function () { return setup_1.registerAllure; } }); | ||
var reporter_1 = require("./reporter"); | ||
Object.defineProperty(exports, "JasmineAllureReporter", { enumerable: true, get: function () { return reporter_1.JasmineAllureReporter; } }); | ||
Object.defineProperty(exports, "JasmineAllureInterface", { enumerable: true, get: function () { return reporter_1.JasmineAllureInterface; } }); | ||
Object.defineProperty(exports, "WrappedStep", { enumerable: true, get: function () { return reporter_1.WrappedStep; } }); | ||
__exportStar(require("allure-js-commons"), exports); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
/// <reference types="jasmine" /> | ||
import { Allure, AllureGroup, AllureRuntime, AllureStep, AllureTest, ContentType, ExecutableItemWrapper, IAllureConfig, Status, StepInterface } from 'allure-js-commons'; | ||
@@ -19,3 +18,3 @@ export declare type Attachment = { | ||
private stepStack; | ||
private isSuite; | ||
private get isSuite(); | ||
private readonly runtime; | ||
@@ -29,6 +28,4 @@ constructor(config: JAllureConfig); | ||
jasmineStarted(_suiteInfo: jasmine.SuiteInfo): 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; | ||
@@ -51,6 +48,18 @@ addLabel(name: string, value: string): void; | ||
attachment(name: string, content: Buffer | string, type: ContentType): void; | ||
parameter(name: string, value: string): void; | ||
label(name: string, value: string): void; | ||
private startStep; | ||
startStep(name: string): WrappedStep; | ||
protected get currentExecutable(): ExecutableItemWrapper; | ||
protected get currentTest(): AllureTest; | ||
} | ||
export declare class WrappedStep { | ||
private readonly reporter; | ||
private readonly step; | ||
constructor(reporter: JasmineAllureReporter, step: AllureStep); | ||
startStep(name: string): WrappedStep; | ||
attach(name: string, content: Buffer | string, type: ContentType): void; | ||
param(name: string, value: string): void; | ||
logStep(status: Status): void; | ||
run<T>(body: (step: StepInterface) => T): T; | ||
endStep(): void; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JasmineAllureInterface = exports.JasmineAllureReporter = void 0; | ||
exports.WrappedStep = exports.JasmineAllureInterface = exports.JasmineAllureReporter = void 0; | ||
const allure_js_commons_1 = require("allure-js-commons"); | ||
@@ -28,3 +28,2 @@ const path_1 = __importDefault(require("path")); | ||
this.stepStack = []; | ||
this.isSuite = false; | ||
this.config = config; | ||
@@ -34,2 +33,5 @@ this.runtime = new allure_js_commons_1.AllureRuntime(config); | ||
} | ||
get isSuite() { | ||
return false; | ||
} | ||
getInterface() { | ||
@@ -40,9 +42,11 @@ return new JasmineAllureInterface(this, this.runtime); | ||
const currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error('No active group'); | ||
} | ||
return currentGroup; | ||
} | ||
get currentTest() { | ||
if (this.runningTest === null) | ||
if (this.runningTest === null) { | ||
throw new Error('No active test'); | ||
} | ||
return this.runningTest; | ||
@@ -57,14 +61,15 @@ } | ||
jasmineStarted(_suiteInfo) { | ||
console.log(`Jest Worker #${process.env.JEST_WORKER_ID} has started.`); | ||
// Console.log(`Jest Worker #${process.env.JEST_WORKER_ID} has started.`) | ||
} | ||
suiteStarted(suite) { | ||
// SuiteStarted is only triggered when a test is nested in a describe block | ||
this.isSuite = true; | ||
// Group all specs of describe block together using wrapper. | ||
const name = suite.description; | ||
const group = (this.getCurrentGroup() || this.runtime).startGroup(name); | ||
this.groupStack.push(group); | ||
this.labelStack.push([]); | ||
} | ||
// SuiteStarted(suite: jasmine.CustomReporterResult): void { | ||
// // SuiteStarted is only triggered when a test is nested in a describe block | ||
// this.isSuite = true | ||
// // Group all specs of describe block together using wrapper. | ||
// const name = suite.description | ||
// const group = (this.getCurrentGroup() ?? this.runtime).startGroup(name) | ||
// this.groupStack.push(group) | ||
// this.labelStack.push([]) | ||
// } | ||
specStarted(spec) { | ||
var _a; | ||
let specPathArray = []; | ||
@@ -75,5 +80,7 @@ // Special behavior if test is not using describe blocks | ||
const { testPath } = spec; | ||
specPathArray = projectDir ? path_1.default.relative(projectDir, testPath).split('/') : testPath.split('/'); | ||
specPathArray = projectDir ? | ||
path_1.default.relative(projectDir, testPath).split('/') : | ||
testPath.split('/'); | ||
if (specPathArray.length > 0) { | ||
const group = (this.getCurrentGroup() || this.runtime).startGroup(specPathArray[0]); | ||
const group = ((_a = this.getCurrentGroup()) !== null && _a !== void 0 ? _a : this.runtime).startGroup(specPathArray[0]); | ||
this.groupStack.push(group); | ||
@@ -85,4 +92,5 @@ this.labelStack.push([]); | ||
let currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error('No active suite'); | ||
} | ||
// Wrapper to hold beforeEach/afterEach | ||
@@ -95,4 +103,5 @@ currentGroup = currentGroup.startGroup('Test wrapper'); | ||
// Check context for invalid state | ||
if (this.runningTest !== null) | ||
if (this.runningTest !== null) { | ||
throw new Error('Test is starting before other ended!'); | ||
} | ||
// Set context state | ||
@@ -128,4 +137,5 @@ this.runningTest = allureTest; | ||
// Capture Jest worker thread for timeline report | ||
if (process.env.JEST_WORKER_ID) | ||
if (process.env.JEST_WORKER_ID) { | ||
this.addLabel(allure_js_commons_1.LabelName.THREAD, `${process.env.JEST_WORKER_ID}`); | ||
} | ||
// Recursively add labels to the test instance | ||
@@ -139,7 +149,12 @@ for (const labels of this.labelStack) { | ||
specDone(spec) { | ||
if (this.runningTest === null) | ||
var _a, _b, _c, _d, _e; | ||
if (this.runningTest === null) { | ||
throw new Error('specDone while no test is running'); | ||
} | ||
const currentTest = this.runningTest; | ||
// Console.log('specDone currentTest:', JSON.stringify(currentTest, null, 2)) | ||
// If steps were not finished before the spec finished, then notify and clear stepStack. | ||
if (this.stepStack.length > 0) { | ||
// Console.error('this.stepStack:', this.stepStack) | ||
console.error('this.stepStack:', JSON.stringify(this.stepStack, null, 2)); | ||
console.error('Allure reporter issue: step stack is not empty on specDone'); | ||
@@ -149,3 +164,4 @@ for (const step of this.stepStack.reverse()) { | ||
step.stage = allure_js_commons_1.Stage.INTERRUPTED; | ||
step.detailsMessage = 'Test ended unexpectedly before step could complete.'; | ||
step.detailsMessage = | ||
'Test ended unexpectedly before step could complete.'; | ||
step.endStep(); | ||
@@ -168,16 +184,13 @@ } | ||
} | ||
if (spec.status === SpecStatus.PENDING || | ||
spec.status === SpecStatus.DISABLED || | ||
spec.status === SpecStatus.EXCLUDED || | ||
spec.status === SpecStatus.TODO) { | ||
if ((_c = (_b = (_a = spec.status === SpecStatus.PENDING) !== null && _a !== void 0 ? _a : spec.status === SpecStatus.DISABLED) !== null && _b !== void 0 ? _b : spec.status === SpecStatus.EXCLUDED) !== null && _c !== void 0 ? _c : spec.status === SpecStatus.TODO) { | ||
currentTest.status = allure_js_commons_1.Status.SKIPPED; | ||
currentTest.stage = allure_js_commons_1.Stage.PENDING; | ||
currentTest.detailsMessage = spec.pendingReason || 'Suite disabled'; | ||
currentTest.detailsMessage = (_d = spec.pendingReason) !== null && _d !== void 0 ? _d : 'Suite disabled'; | ||
} | ||
// Capture exceptions | ||
const exceptionInfo = this.findMessageAboutThrow(spec.failedExpectations) || this.findAnyError(spec.failedExpectations); | ||
const exceptionInfo = (_e = this.findMessageAboutThrow(spec.failedExpectations)) !== null && _e !== void 0 ? _e : this.findAnyError(spec.failedExpectations); | ||
if (exceptionInfo !== null && typeof exceptionInfo.message === 'string') { | ||
let { message } = exceptionInfo; | ||
message = strip_ansi_1.default(message); | ||
currentTest.detailsMessage = message; | ||
currentTest.detailsMessage = strip_ansi_1.default(message); | ||
if (exceptionInfo.stack && typeof exceptionInfo.stack === 'string') { | ||
@@ -199,4 +212,5 @@ let { stack } = exceptionInfo; | ||
const currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
if (currentGroup === null) { | ||
throw new Error('No active suite'); | ||
} | ||
currentGroup.endGroup(); | ||
@@ -207,16 +221,13 @@ this.groupStack.pop(); | ||
} | ||
suiteDone(_suite) { | ||
if (!this.isSuite) | ||
console.error('Allure reporter issue: suiteDone called without suiteStart context.'); | ||
if (this.runningTest !== null) | ||
console.error('Allure reporter issue: A test was running on suiteDone.'); | ||
const currentGroup = this.getCurrentGroup(); | ||
if (currentGroup === null) | ||
throw new Error('No active suite.'); | ||
currentGroup.endGroup(); | ||
this.groupStack.pop(); | ||
this.labelStack.pop(); | ||
} | ||
// SuiteDone(_suite: jasmine.CustomReporterResult): void { | ||
// if (!this.isSuite) console.error('Allure reporter issue: suiteDone called without suiteStart context.') | ||
// if (this.runningTest !== null) console.error('Allure reporter issue: A test was running on suiteDone.') | ||
// const currentGroup = this.getCurrentGroup() | ||
// if (currentGroup === null) throw new Error('No active suite.') | ||
// currentGroup.endGroup() | ||
// this.groupStack.pop() | ||
// this.labelStack.pop() | ||
// } | ||
jasmineDone(_runDetails) { | ||
console.log(`Jest Worker #${process.env.JEST_WORKER_ID} has finished.`); | ||
// Console.log(`Jest Worker #${process.env.JEST_WORKER_ID} has finished.`) | ||
} | ||
@@ -235,15 +246,18 @@ addLabel(name, value) { | ||
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) | ||
if (this.groupStack.length === 0) { | ||
return null; | ||
} | ||
return this.groupStack[this.groupStack.length - 1]; | ||
} | ||
findMessageAboutThrow(expectations) { | ||
for (const expectation of expectations || []) { | ||
if (expectation.matcherName === '') | ||
for (const expectation of expectations !== null && expectations !== void 0 ? expectations : []) { | ||
if (expectation.matcherName === '') { | ||
return expectation; | ||
} | ||
} | ||
@@ -253,5 +267,6 @@ return null; | ||
findAnyError(expectations) { | ||
expectations = expectations || []; | ||
if (expectations.length > 0) | ||
expectations = expectations !== null && expectations !== void 0 ? expectations : []; | ||
if (expectations.length > 0) { | ||
return expectations[0]; | ||
} | ||
return null; | ||
@@ -283,3 +298,2 @@ } | ||
if (allure_js_commons_1.isPromise(returnValue)) { | ||
; | ||
returnValue | ||
@@ -290,3 +304,3 @@ .then(() => { | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
this.runningExecutable = null; | ||
@@ -326,7 +340,7 @@ done.fail(error); | ||
return promise | ||
.then((a) => { | ||
.then(a => { | ||
this.reporter.runningExecutable = null; | ||
return a; | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
this.reporter.runningExecutable = null; | ||
@@ -354,7 +368,7 @@ throw error; | ||
return promise | ||
.then((a) => { | ||
.then(a => { | ||
wrappedStep.endStep(); | ||
return a; | ||
}) | ||
.catch((error) => { | ||
.catch(error => { | ||
wrappedStep.endStep(); | ||
@@ -370,2 +384,3 @@ throw error; | ||
logStep(name, status, attachments) { | ||
console.log('JasmineAllureInterface status:', status); | ||
const wrappedStep = this.startStep(name); | ||
@@ -384,5 +399,5 @@ if (attachments) { | ||
} | ||
// Public parameter(name: string, value: string): void { | ||
// this.label(name, value); | ||
// } | ||
parameter(name, value) { | ||
this.label(name, value); | ||
} | ||
label(name, value) { | ||
@@ -402,3 +417,4 @@ try { | ||
get currentExecutable() { | ||
return this.reporter.currentStep || this.reporter.currentExecutable || this.reporter.currentTest; | ||
var _a, _b; | ||
return ((_b = (_a = this.reporter.currentStep) !== null && _a !== void 0 ? _a : this.reporter.currentExecutable) !== null && _b !== void 0 ? _b : this.reporter.currentTest); | ||
} | ||
@@ -429,3 +445,4 @@ get currentTest() { | ||
logStep(status) { | ||
// Return this.step.logStep(status); | ||
console.log('WrappedStep status:', status); | ||
this.step.status = status; | ||
} | ||
@@ -440,2 +457,3 @@ run(body) { | ||
} | ||
exports.WrappedStep = WrappedStep; | ||
//# sourceMappingURL=reporter.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { JasmineAllureInterface, JasmineAllureReporter } from './reporter'; | ||
@@ -8,5 +7,10 @@ import { TestResult } from 'allure-js-commons'; | ||
declare global { | ||
const allure: JasmineAllureInterface; | ||
namespace NodeJS { | ||
interface Global { | ||
allure: JasmineAllureInterface; | ||
} | ||
} | ||
} | ||
declare const registerAllure: (resultsDir?: string, projectDir?: string, environmentInfo?: {}, testMapper?: (test: TestResult) => TestResult | null) => JasmineAllureReporter; | ||
declare const registerAllure: (resultsDir?: string, projectDir?: string, environmentInfo?: {}, testMapper?: ((test: TestResult) => TestResult | null) | undefined) => JasmineAllureReporter; | ||
export { registerAllure }; | ||
export {}; |
@@ -9,9 +9,8 @@ "use strict"; | ||
testMapper, | ||
projectDir, | ||
projectDir | ||
}); | ||
jasmine.getEnv().addReporter(reporter); | ||
const allure = reporter.getInterface(); | ||
global.allure = allure; | ||
global.allure = reporter.getInterface(); | ||
if (environmentInfo) { | ||
allure.writeEnvironmentInfo(environmentInfo); | ||
global.allure.writeEnvironmentInfo(environmentInfo); | ||
} | ||
@@ -18,0 +17,0 @@ return reporter; |
105
package.json
{ | ||
"name": "jest-allure2", | ||
"version": "1.2.2", | ||
"description": "Allure Reports for jest", | ||
"version": "1.2.3", | ||
"description": "Allure 2 Reports for jest", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ryparker/jest-allure2.git" | ||
}, | ||
"files": [ | ||
"dist/**/*" | ||
"dist" | ||
], | ||
"main": "dist/index.js", | ||
"main": "dist", | ||
"types": "dist/index.d.ts", | ||
@@ -13,31 +17,16 @@ "author": "Ryan Parker", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "yarn clean && yarn build && jest --config ./__tests__/jest.config.js", | ||
"lint": "xo src/", | ||
"fix": "xo src/ --fix", | ||
"clean": "rimraf ./dist" | ||
"build": "rimraf dist && tsc", | ||
"test": "yarn clean && yarn build && jest", | ||
"lint": "xo src", | ||
"fix": "xo src --fix", | ||
"clean": "rimraf dist allure-results" | ||
}, | ||
"dependencies": { | ||
"allure-jasmine": "^2.0.0-beta.6", | ||
"allure-js-commons": "^2.0.0-beta.6", | ||
"strip-ansi": "^6.0.0" | ||
"jest": { | ||
"setupFilesAfterEnv": [ | ||
"./jest.setup.js" | ||
], | ||
"testMatch": [ | ||
"**/__tests__/**" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@types/allure-js-commons": "^0.0.1", | ||
"@types/jasmine": "^3.5.11", | ||
"@types/jest": "^26.0.0", | ||
"commitizen": "^4.1.2", | ||
"cz-conventional-changelog": "3.2.0", | ||
"eslint-plugin-jest": "^23.16.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"semantic-release": "^17.0.8", | ||
"typescript": "^3.9.5", | ||
"xo": "^0.32.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ryparker/jest-allure2.git" | ||
}, | ||
"xo": { | ||
@@ -51,9 +40,30 @@ "extends": [ | ||
], | ||
"prettier": true, | ||
"rules": { | ||
"promise/prefer-await-to-then": 1, | ||
"@typescript-eslint/prefer-readonly-parameter-types": 0, | ||
"no-eval": 0, | ||
"@typescript-eslint/no-unused-vars": 0 | ||
"@typescript-eslint/no-unused-vars": 0, | ||
"no-eval": 0 | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"pre-push": "yarn test" | ||
} | ||
}, | ||
"lint-staged": { | ||
"./src/**/*": [ | ||
"xo src --fix" | ||
] | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
"@semantic-release/git", | ||
"@semantic-release/github" | ||
] | ||
}, | ||
"config": { | ||
@@ -64,2 +74,29 @@ "commitizen": { | ||
}, | ||
"dependencies": { | ||
"allure-js-commons": "2.0.0-beta.7", | ||
"jasmine": "^3.5.0", | ||
"strip-ansi": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@types/allure-js-commons": "^0.0.1", | ||
"@types/jasmine": "^3.5.11", | ||
"@types/jest": "^26.0.5", | ||
"@types/node": "^14.0.24", | ||
"commitizen": "^4.1.2", | ||
"cz-conventional-changelog": "3.2.0", | ||
"eslint-config-xo-typescript": "^0.31.0", | ||
"eslint-plugin-jest": "^23.18.0", | ||
"husky": "^4.2.5", | ||
"jest": "^26.1.0", | ||
"lint-staged": "^10.2.11", | ||
"rimraf": "^3.0.2", | ||
"semantic-release": "^17.1.1", | ||
"typescript": "^3.9.7", | ||
"xo": "^0.32.1" | ||
}, | ||
"engines": { | ||
"node": ">= 12.x" | ||
}, | ||
"keywords": [ | ||
@@ -66,0 +103,0 @@ "jest", |
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
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
46803
550
2
8
17
+ Addedjasmine@^3.5.0
+ Addedallure-js-commons@2.0.0-beta.7(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjasmine@3.99.0(transitive)
+ Addedjasmine-core@3.99.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addeduuid@7.0.3(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedallure-jasmine@^2.0.0-beta.6
- Removedallure-jasmine@2.15.1(transitive)
- Removedallure-js-commons@2.15.1(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedcharenc@0.0.2(transitive)
- Removedcrypt@0.0.2(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedmd5@2.3.0(transitive)
- Removedstrip-ansi@5.2.0(transitive)