Skip to content

Commit c21d18e

Browse files
authored
update model and api (via allure-framework#25)
1 parent d5aef12 commit c21d18e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+849
-1309
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ rules:
3535
arrow-spacing: error
3636
no-confusing-arrow: error
3737
no-var: error
38-
object-shorthand: [error, consistent-as-needed]
38+
object-shorthand: [warn, consistent-as-needed]
3939
prefer-const: error
4040
prefer-destructuring: warn
4141
prefer-rest-params: warn

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"pack": "lerna exec -- npm pack"
1818
},
1919
"devDependencies": {
20-
"@types/node": "^10.12.18",
20+
"@types/node": "^11.13.6",
2121
"allure-commandline": "^2.9.0",
22-
"lerna": "^3.10.6",
22+
"lerna": "^3.13.3",
2323
"npm-run-all": "^4.1.5",
2424
"rimraf": "^2.6.3",
25-
"typescript": "^3.4.5",
26-
"eslint": "^5.12.1",
27-
"@typescript-eslint/eslint-plugin": "^1.0.0",
28-
"@typescript-eslint/parser": "^1.0.0"
25+
"typescript": "^3.4.4",
26+
"eslint": "^5.16.0",
27+
"@typescript-eslint/eslint-plugin": "^1.7.0",
28+
"@typescript-eslint/parser": "^1.7.0",
29+
"nyc": "^14.0.0"
2930
}
3031
}

packages/allure-cucumberjs/features/support/chai-partial.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function ChaiPartial(_chai: any, utils: any) {
3232
if (object.length < expected.length) {
3333
return false;
3434
}
35-
3635
return expected.every((exp: any) => object.some((obj: any) => partial(obj, exp)));
3736
}
3837

packages/allure-cucumberjs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export {
2-
AllureInterface, World, CucumberJSAllureFormatter, CucumberJSAllureFormatterConfig
2+
Allure, World, CucumberJSAllureFormatter, CucumberJSAllureFormatterConfig
33
}
44
from "./src/CucumberJSAllureReporter";
55
export {
Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,39 @@
11
import {
2-
AllureInterface,
2+
Allure,
33
AllureStep,
44
AllureTest,
55
ContentType,
66
ExecutableItemWrapper,
77
GlobalInfoWriter,
88
isPromise,
99
LabelName,
10-
Severity
10+
Severity, Status, StepInterface
1111
} from "allure-js-commons";
1212
import { CucumberJSAllureFormatter } from "./CucumberJSAllureReporter";
1313

14-
export class CucumberAllureInterface extends AllureInterface {
14+
export class CucumberAllureInterface extends Allure {
1515
constructor(private readonly reporter: CucumberJSAllureFormatter) {
1616
super();
1717
}
1818

19-
private get currentExecutable(): ExecutableItemWrapper {
19+
protected get currentExecutable(): ExecutableItemWrapper {
2020
const result = this.reporter.currentStep || this.reporter.currentTest;
2121
if (result === null) throw new Error("No executable!");
2222
return result;
2323
}
2424

25-
private get currentTest(): AllureTest {
25+
protected get currentTest(): AllureTest {
2626
if (this.reporter.currentTest === null) throw new Error("No test running!");
2727
return this.reporter.currentTest;
2828
}
2929

30-
setDescription(text: string) {
31-
this.currentExecutable.description = text;
32-
this.currentExecutable.descriptionHtml = text;
33-
}
34-
35-
setTestDescription(text: string) {
36-
this.currentTest.description = text;
37-
this.currentTest.descriptionHtml = text;
38-
}
39-
40-
setFlaky() {
41-
this.currentExecutable.detailsFlaky = true;
42-
}
43-
44-
setKnown() {
45-
this.currentExecutable.detailsKnown = true;
46-
}
47-
48-
setMuted() {
49-
this.currentExecutable.detailsMuted = true;
50-
}
51-
52-
addOwner(owner: string) {
53-
this.currentTest.addLabel(LabelName.OWNER, owner);
54-
}
55-
56-
setSeverity(severity: Severity) {
57-
this.currentTest.addLabel(LabelName.SEVERITY, severity);
58-
}
59-
60-
addIssue(issue: string) {
61-
this.currentTest.addLabel(LabelName.ISSUE, issue);
62-
}
63-
64-
addTag(tag: string) {
65-
this.currentTest.addLabel(LabelName.TAG, tag);
66-
}
67-
68-
addTestType(type: string) {
69-
this.currentTest.addLabel(LabelName.TEST_TYPE, type);
70-
}
71-
72-
addLink(name: string, url: string, type?: string) {
73-
this.currentTest.addLink(name, url, type);
74-
}
75-
7630
private startStep(name: string): WrappedStep {
7731
const allureStep: AllureStep = this.currentExecutable.startStep(name);
7832
this.reporter.pushStep(allureStep);
7933
return new WrappedStep(this.reporter, allureStep);
8034
}
8135

82-
step<T>(name: string, body: () => any): any {
36+
step<T>(name: string, body: (step: StepInterface) => any): any {
8337
const wrappedStep = this.startStep(name);
8438
let result;
8539
try {
@@ -103,6 +57,10 @@ export class CucumberAllureInterface extends AllureInterface {
10357
}
10458
}
10559

60+
logStep(name: string, status?: Status): void {
61+
this.step(name, () => {}); // todo status
62+
}
63+
10664
attachment(name: string, content: Buffer | string, type: ContentType) {
10765
const file = this.reporter.writeAttachment(content, type);
10866
this.currentExecutable.addAttachment(name, type, file);
@@ -142,7 +100,7 @@ export class WrappedStep {
142100
this.step.endStep();
143101
}
144102

145-
run<T>(body: () => T): T {
103+
run<T>(body: (step: StepInterface) => T): T {
146104
return this.step.wrap(body)();
147105
}
148106
}

packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Formatter, World as CucumberWorld } from "cucumber";
22
import {
33
AllureGroup,
4-
AllureInterface,
4+
Allure,
55
AllureRuntime,
66
AllureStep,
77
AllureTest,
@@ -26,10 +26,10 @@ import {
2626
stripIndent
2727
} from "./utilities";
2828

29-
export { AllureInterface } from "allure-js-commons";
29+
export { Allure } from "allure-js-commons";
3030

3131
export interface World extends CucumberWorld {
32-
allure: AllureInterface;
32+
allure: Allure;
3333
}
3434

3535
export class CucumberJSAllureFormatterConfig {
@@ -54,7 +54,7 @@ export class CucumberJSAllureFormatter extends Formatter {
5454
currentBefore: ExecutableItemWrapper | null = null;
5555
currentAfter: ExecutableItemWrapper | null = null;
5656

57-
public readonly allureInterface: AllureInterface;
57+
public readonly allureInterface: Allure;
5858

5959
constructor(options: any, private readonly allureRuntime: AllureRuntime,
6060
config: CucumberJSAllureFormatterConfig) {
@@ -142,7 +142,7 @@ export class CucumberJSAllureFormatter extends Formatter {
142142
throw new Error("Unknown scenario");
143143
}
144144

145-
this.currentGroup = this.allureRuntime.startGroup("");
145+
this.currentGroup = this.allureRuntime.startGroup();
146146
this.currentTest =
147147
this.currentGroup.startTest(applyExample(test.name || "Unnamed test", test.example));
148148

packages/allure-jasmine/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export {
55
AllureConfig,
66
ContentType,
77
Severity,
8-
AllureInterface,
8+
Allure,
99
GlobalInfoWriter,
1010
ExecutorInfo,
1111
Category

packages/allure-jasmine/package.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,35 @@
1515
"build": "npm run lint && npm run compile",
1616
"prepublishOnly": "npm run clean && npm run build",
1717
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean",
18-
"runTest": "jasmine ./dist/test/*.js",
19-
"runTestDebug": "node $NODE_DEBUG_OPTION ./node_modules/jasmine/bin/jasmine ./dist/test/*.js",
18+
"runTest": "nyc jasmine ./dist/test/*.test.js",
19+
"runTestDebug": "node $NODE_DEBUG_OPTION ./node_modules/.bin/jasmine ./dist/test/*.js",
2020
"test": "rimraf ./out ; npm run runTest ; npm run generate-report"
2121
},
2222
"devDependencies": {
23-
"@types/jasmine": "^3.3.7",
24-
"jasmine": "^3.3.1"
23+
"@types/jasmine": "^3.3.12",
24+
"jasmine": "^3.4.0"
2525
},
2626
"dependencies": {
2727
"allure-js-commons": "^2.0.0-beta.3"
28+
},
29+
"nyc": {
30+
"check-coverage": false,
31+
"lines": 85,
32+
"statements": 85,
33+
"functions": 85,
34+
"branches": 75,
35+
"extension": [
36+
".ts"
37+
],
38+
"include": [
39+
"**/src/**/*"
40+
],
41+
"reporter": [
42+
"lcov",
43+
"text"
44+
],
45+
"all": true,
46+
"report-dir": "./out/coverage",
47+
"temp-dir": "./out/.nyc"
2848
}
2949
}

packages/allure-jasmine/src/JasmineAllureReporter.ts

Lines changed: 14 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-undef */
22
import {
3-
AllureGroup, AllureRuntime, AllureStep, AllureTest, ContentType, ExecutableItemWrapper,
4-
isPromise, LabelName, Severity, Stage, Status, AllureInterface, GlobalInfoWriter
3+
AllureGroup, IAllureRuntime, AllureStep, AllureTest, ContentType, ExecutableItemWrapper,
4+
isPromise, LabelName, Severity, Stage, Status, GlobalInfoWriter, Allure, StepInterface
55
} from "allure-js-commons";
66
import FailedExpectation = jasmine.FailedExpectation;
77

@@ -22,7 +22,7 @@ export class JasmineAllureReporter implements jasmine.CustomReporter {
2222
private stepStack: AllureStep[] = [];
2323
private runningExecutable: ExecutableItemWrapper | null = null;
2424

25-
constructor(private readonly runtime: AllureRuntime) {
25+
constructor(private readonly runtime: IAllureRuntime) {
2626
this.installHooks();
2727
}
2828

@@ -37,7 +37,7 @@ export class JasmineAllureReporter implements jasmine.CustomReporter {
3737
return currentGroup;
3838
}
3939

40-
getInterface(): AllureInterface {
40+
getInterface(): Allure {
4141
return new JasmineAllureInterface(this);
4242
}
4343

@@ -238,62 +238,19 @@ export class JasmineAllureReporter implements jasmine.CustomReporter {
238238
}
239239

240240

241-
export class JasmineAllureInterface extends AllureInterface {
241+
export class JasmineAllureInterface extends Allure {
242242
constructor(private readonly reporter: JasmineAllureReporter) {
243243
super();
244244
}
245245

246-
private get currentExecutable(): ExecutableItemWrapper {
246+
protected get currentExecutable(): ExecutableItemWrapper {
247247
return this.reporter.currentStep
248248
|| this.reporter.currentExecutable
249249
|| this.reporter.currentTest;
250250
}
251251

252-
setDescription(text: string) {
253-
this.currentExecutable.description = text;
254-
this.currentExecutable.descriptionHtml = text;
255-
}
256-
257-
setFlaky() {
258-
this.currentExecutable.detailsFlaky = true;
259-
}
260-
261-
setKnown() {
262-
this.currentExecutable.detailsKnown = true;
263-
}
264-
265-
setMuted() {
266-
this.currentExecutable.detailsMuted = true;
267-
}
268-
269-
addOwner(owner: string) {
270-
if (this.reporter.currentTest === null) throw new Error("No test running!");
271-
this.reporter.currentTest.addLabel(LabelName.OWNER, owner);
272-
}
273-
274-
setSeverity(severity: Severity) {
275-
if (this.reporter.currentTest === null) throw new Error("No test running!");
276-
this.reporter.currentTest.addLabel(LabelName.SEVERITY, severity);
277-
}
278-
279-
addIssue(issue: string) {
280-
if (this.reporter.currentTest === null) throw new Error("No test running!");
281-
this.reporter.currentTest.addLabel(LabelName.ISSUE, issue);
282-
}
283-
284-
addTag(tag: string) {
285-
if (this.reporter.currentTest === null) throw new Error("No test running!");
286-
this.reporter.currentTest.addLabel(LabelName.TAG, tag);
287-
}
288-
289-
addTestType(type: string) {
290-
if (this.reporter.currentTest === null) throw new Error("No test running!");
291-
this.reporter.currentTest.addLabel(LabelName.TEST_TYPE, type);
292-
}
293-
294-
addLink(name: string, url: string, type?: string) {
295-
if (this.reporter.currentTest === null) throw new Error("No test running!");
296-
this.reporter.currentTest.addLink(name, url, type);
252+
protected get currentTest(): AllureTest {
253+
return this.reporter.currentTest;
297254
}
298255

299256
private startStep(name: string): WrappedStep {
@@ -302,7 +259,7 @@ export class JasmineAllureInterface extends AllureInterface {
302259
return new WrappedStep(this.reporter, allureStep);
303260
}
304261

305-
step<T>(name: string, body: () => any): any {
262+
step<T>(name: string, body: (step: StepInterface) => any): any {
306263
const wrappedStep = this.startStep(name);
307264
let result;
308265
try {
@@ -326,21 +283,15 @@ export class JasmineAllureInterface extends AllureInterface {
326283
}
327284
}
328285

286+
logStep(name: string, status?: Status): void {
287+
this.step(name, () => {}); // todo status
288+
}
289+
329290
attachment(name: string, content: Buffer | string, type: ContentType) {
330291
const file = this.reporter.writeAttachment(content, type);
331292
this.currentExecutable.addAttachment(name, type, file);
332293
}
333294

334-
addParameter(name: string, value: string): void {
335-
if (this.reporter.currentTest === null) throw new Error("No test running!");
336-
this.reporter.currentTest.addParameter(name, value);
337-
}
338-
339-
addLabel(name: string, value: string): void {
340-
if (this.reporter.currentTest === null) throw new Error("No test running!");
341-
this.reporter.currentTest.addLabel(name, value);
342-
}
343-
344295
getGlobalInfoWriter(): GlobalInfoWriter {
345296
return this.reporter.getGlobalInfoWriter();
346297
}
@@ -362,7 +313,7 @@ class WrappedStep { // needed?
362313
this.step.endStep();
363314
}
364315

365-
run<T>(body: () => T): T {
316+
run<T>(body: (step: StepInterface) => T): T {
366317
return this.step.wrap(body)();
367318
}
368319
}

0 commit comments

Comments
 (0)