allure-mocha 2.0.0-beta.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2019 Qameta Software
189
+ Copyright 2019-2021 Qameta Software
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -7,16 +7,18 @@ This project implements Allure integration with Mocha framework.
7
7
  ```bash
8
8
  npm i allure-mocha mocha --save-dev
9
9
  ```
10
+
10
11
  or via yarn:
12
+
11
13
  ```bash
12
14
  yarn add allure-mocha mocha --dev
13
15
  ```
14
16
 
15
17
  Note that it's recommended to add the following dependencies as well for better user experience:
16
18
 
17
- - typescript
18
- - mocha-typescript
19
- - source-map-support
19
+ - typescript
20
+ - mocha-typescript
21
+ - source-map-support
20
22
 
21
23
  ## Usage
22
24
 
@@ -32,19 +34,42 @@ Or pass the same value via commandline / scripts:
32
34
  mocha -R allure-mocha
33
35
  ```
34
36
 
35
- If you want to provide extra information, such as steps and attachments, import the `allure` object
37
+ If you want to provide extra information, such as steps and attachments, import the `allure` object
36
38
  into your code:
37
39
 
38
40
  ```javascript
39
- // es-modules
40
- import { allure } from 'allure-mocha/runtime';
41
- // or commonjs
42
- const { allure } = require('allure-mocha/runtime');
41
+ const allureMocha = require("allure-mocha/runtime");
42
+
43
+ it("is a test", () => {
44
+ allureMocha.allure.epic("Some info");
45
+ });
46
+ ```
47
+
48
+ ### Parameters usage
49
+
50
+ ```ts
51
+ import { allure } from "allure-mocha/runtime";
52
+
53
+ it("is a test", () => {
54
+ allureMocha.allure.parameter("parameterName", "parameterValue");
55
+ });
56
+ ```
57
+
58
+ Also addParameter takes an third optional parameter with the hidden and excluded options:
59
+ `mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden` entirely hide parameter from report
60
+
61
+ `excluded: true` - excludes parameter from the history
43
62
 
44
- it('is a test', () => {
45
- allure.epic('Some info');
63
+ ```ts
64
+ import { allure } from "allure-mocha/runtime";
65
+
66
+ it("is a test", () => {
67
+ allureMocha.allure.parameter("parameterName", "parameterValue", {
68
+ mode: "hidden",
69
+ excluded: true,
70
+ });
46
71
  });
47
- ```
72
+ ```
48
73
 
49
74
  ## Decorators Support
50
75
 
@@ -52,8 +77,4 @@ To make tests more readable and avoid explicit API calls, you can use a special
52
77
 
53
78
  ## Examples
54
79
 
55
- See [mocha-allure2-example](https://github.com/sskorol/mocha-allure2-example) project, which is already configured to use latest Allure 2 features with decorators support.
56
-
57
- ## Thanks
58
-
59
- [@srg-kostyrko](https://github.com/srg-kostyrko) for help and assistance.
80
+ [mocha-allure-example](https://github.com/vovsemenv/mocha-allure-example) - minimal setup for using mocha with allure
@@ -1,12 +1,13 @@
1
1
  /// <reference types="node" />
2
- import { AllureGroup, AllureRuntime, AllureStep, AllureTest, ContentType, ExecutableItemWrapper } from "allure-js-commons";
2
+ import { AllureGroup, AllureRuntime, AllureStep, AllureTest, AttachmentOptions, ContentType, ExecutableItemWrapper } from "allure-js-commons";
3
3
  import { MochaAllure } from "./MochaAllure";
4
4
  export declare class AllureReporter {
5
5
  private readonly allureRuntime;
6
+ currentExecutable: ExecutableItemWrapper | null;
7
+ private cwd;
6
8
  private suites;
7
9
  private steps;
8
10
  private runningTest;
9
- currentExecutable: ExecutableItemWrapper | null;
10
11
  constructor(allureRuntime: AllureRuntime);
11
12
  getImplementation(): MochaAllure;
12
13
  get currentSuite(): AllureGroup | null;
@@ -15,16 +16,17 @@ export declare class AllureReporter {
15
16
  set currentTest(test: AllureTest | null);
16
17
  startSuite(suiteName: string): void;
17
18
  endSuite(): void;
18
- startHook(title: string): void;
19
+ startHook(hook: Mocha.Hook): void;
19
20
  endHook(error?: Error): void;
20
21
  startCase(test: Mocha.Test): void;
21
22
  passTestCase(test: Mocha.Test): void;
22
23
  pendingTestCase(test: Mocha.Test): void;
23
24
  failTestCase(test: Mocha.Test, error: Error): void;
24
- writeAttachment(content: Buffer | string, type: ContentType): string;
25
+ writeAttachment(content: Buffer | string, options: ContentType | string | AttachmentOptions): string;
25
26
  pushStep(step: AllureStep): void;
26
27
  popStep(): void;
27
28
  pushSuite(suite: AllureGroup): void;
28
29
  popSuite(): void;
30
+ private getSuitePath;
29
31
  private endTest;
30
32
  }
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AllureReporter = void 0;
4
+ const path_1 = require("path");
4
5
  const allure_js_commons_1 = require("allure-js-commons");
5
- const crypto_1 = require("crypto");
6
6
  const MochaAllure_1 = require("./MochaAllure");
7
7
  class AllureReporter {
8
8
  constructor(allureRuntime) {
9
9
  this.allureRuntime = allureRuntime;
10
+ this.currentExecutable = null;
11
+ this.cwd = process.cwd();
10
12
  this.suites = [];
11
13
  this.steps = [];
12
14
  this.runningTest = null;
13
- this.currentExecutable = null;
14
15
  }
15
16
  getImplementation() {
16
17
  return new MochaAllure_1.MochaAllure(this, this.allureRuntime);
@@ -41,14 +42,18 @@ class AllureReporter {
41
42
  this.popSuite();
42
43
  }
43
44
  }
44
- startHook(title) {
45
+ startHook(hook) {
45
46
  const suite = this.currentSuite;
46
- if (suite && title && title.indexOf("before") !== -1) {
47
+ const title = hook.title;
48
+ if (suite && title && title.includes("before")) {
47
49
  this.currentExecutable = suite.addBefore();
48
50
  }
49
- else if (suite && title && title.indexOf("after") !== -1) {
51
+ else if (suite && title && title.includes("after")) {
50
52
  this.currentExecutable = suite.addAfter();
51
53
  }
54
+ if (this.currentExecutable) {
55
+ this.currentExecutable.name = title;
56
+ }
52
57
  }
53
58
  endHook(error) {
54
59
  if (this.currentExecutable) {
@@ -63,17 +68,24 @@ class AllureReporter {
63
68
  }
64
69
  }
65
70
  startCase(test) {
71
+ var _a;
66
72
  if (this.currentSuite === null) {
67
73
  throw new Error("No active suite");
68
74
  }
75
+ const testPath = (_a = test.file) === null || _a === void 0 ? void 0 : _a.replace(this.cwd, "");
69
76
  this.currentTest = this.currentSuite.startTest(test.title);
70
77
  this.currentTest.fullName = test.title;
71
- this.currentTest.historyId = crypto_1.createHash("md5")
72
- .update(test.fullTitle())
73
- .digest("hex");
78
+ this.currentTest.historyId = (0, allure_js_commons_1.md5)(test.fullTitle());
74
79
  this.currentTest.stage = allure_js_commons_1.Stage.RUNNING;
80
+ if (testPath) {
81
+ const normalizedTestPath = (0, path_1.normalize)(testPath || "")
82
+ .replace(/^\//, "")
83
+ .split("/")
84
+ .filter((item) => item !== (0, path_1.basename)(testPath));
85
+ this.currentTest.addLabel(allure_js_commons_1.LabelName.PACKAGE, normalizedTestPath.join("."));
86
+ }
75
87
  if (test.parent) {
76
- const [parentSuite, suite, ...subSuites] = test.parent.titlePath();
88
+ const [parentSuite, suite, ...subSuites] = this.getSuitePath(test);
77
89
  if (parentSuite) {
78
90
  this.currentTest.addLabel(allure_js_commons_1.LabelName.PARENT_SUITE, parentSuite);
79
91
  }
@@ -108,8 +120,8 @@ class AllureReporter {
108
120
  const status = error.name === "AssertionError" ? allure_js_commons_1.Status.FAILED : allure_js_commons_1.Status.BROKEN;
109
121
  this.endTest(status, { message: error.message, trace: error.stack });
110
122
  }
111
- writeAttachment(content, type) {
112
- return this.allureRuntime.writeAttachment(content, type);
123
+ writeAttachment(content, options) {
124
+ return this.allureRuntime.writeAttachment(content, options);
113
125
  }
114
126
  pushStep(step) {
115
127
  this.steps.push(step);
@@ -123,6 +135,17 @@ class AllureReporter {
123
135
  popSuite() {
124
136
  this.suites.pop();
125
137
  }
138
+ getSuitePath(test) {
139
+ const path = [];
140
+ let currentSuite = test.parent;
141
+ while (currentSuite) {
142
+ if (currentSuite.title) {
143
+ path.unshift(currentSuite.title);
144
+ }
145
+ currentSuite = currentSuite.parent;
146
+ }
147
+ return path;
148
+ }
126
149
  endTest(status, details) {
127
150
  if (this.currentTest === null) {
128
151
  throw new Error("endTest while no test is running");
@@ -1 +1 @@
1
- {"version":3,"file":"AllureReporter.js","sourceRoot":"","sources":["../src/AllureReporter.ts"],"names":[],"mappings":";;;AAAA,yDAW2B;AAC3B,mCAAoC;AACpC,+CAA4C;AAE5C,MAAa,cAAc;IAMzB,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QALjD,WAAM,GAAkB,EAAE,CAAC;QAC3B,UAAK,GAAiB,EAAE,CAAC;QACzB,gBAAW,GAAsB,IAAI,CAAC;QACvC,sBAAiB,GAAiC,IAAI,CAAC;IAG9D,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,yBAAW,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7E,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1E,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW,CAAC,IAAuB;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAEM,UAAU,CAAC,SAAiB;QACjC,MAAM,KAAK,GAAgC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa,CAAC;QACnF,MAAM,KAAK,GAAgB,KAAK,CAAC,UAAU,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC,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A4B,IAAI,CAAC,MAAM,CAAC;QAExD,OAAO,YAAY,EAAE;YACnB,IAAI,YAAY,CAAC,KAAK,EAAE;gBACtB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;aAClC;YAED,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,OAAO,CAAC,MAAc,EAAE,OAAuB;QACrD,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QAED,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,OAAO,CAAC;SAC1C;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,yBAAK,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AA9LD,wCA8LC"}
@@ -1,15 +1,15 @@
1
1
  /// <reference types="node" />
2
- import { Allure, AllureRuntime, AllureTest, ContentType, ExecutableItemWrapper, Status, StepInterface } from "allure-js-commons";
2
+ import { Allure, AllureRuntime, AllureTest, AttachmentOptions, ContentType, ExecutableItemWrapper, Status, StepInterface } from "allure-js-commons";
3
3
  import { AllureReporter } from "./AllureReporter";
4
4
  export declare class MochaAllure extends Allure {
5
5
  private readonly reporter;
6
6
  constructor(reporter: AllureReporter, runtime: AllureRuntime);
7
- get currentExecutable(): ExecutableItemWrapper;
8
- set currentExecutable(executable: ExecutableItemWrapper);
7
+ protected get currentExecutable(): ExecutableItemWrapper;
8
+ protected set currentExecutable(executable: ExecutableItemWrapper);
9
9
  step<T>(name: string, body: (step: StepInterface) => any): any;
10
10
  logStep(name: string, status?: Status): void;
11
- attachment(name: string, content: Buffer | string, type: ContentType): void;
12
- testAttachment(name: string, content: Buffer | string, type: ContentType): void;
13
- get currentTest(): AllureTest;
11
+ attachment(name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions): void;
12
+ testAttachment(name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions): void;
13
+ protected get currentTest(): AllureTest;
14
14
  private startStep;
15
15
  }
@@ -28,14 +28,14 @@ class MochaAllure extends allure_js_commons_1.Allure {
28
28
  wrappedStep.endStep();
29
29
  throw err;
30
30
  }
31
- if (allure_js_commons_1.isPromise(result)) {
31
+ if ((0, allure_js_commons_1.isPromise)(result)) {
32
32
  const promise = result;
33
33
  return promise
34
- .then(a => {
34
+ .then((a) => {
35
35
  wrappedStep.endStep();
36
36
  return a;
37
37
  })
38
- .catch(e => {
38
+ .catch((e) => {
39
39
  wrappedStep.endStep();
40
40
  throw e;
41
41
  });
@@ -44,16 +44,15 @@ class MochaAllure extends allure_js_commons_1.Allure {
44
44
  return result;
45
45
  }
46
46
  logStep(name, status) {
47
- this.step(name, () => {
48
- });
47
+ this.step(name, () => { });
49
48
  }
50
- attachment(name, content, type) {
51
- const file = this.reporter.writeAttachment(content, type);
52
- this.currentExecutable.addAttachment(name, type, file);
49
+ attachment(name, content, options) {
50
+ const file = this.reporter.writeAttachment(content, options);
51
+ this.currentExecutable.addAttachment(name, options, file);
53
52
  }
54
- testAttachment(name, content, type) {
55
- const file = this.reporter.writeAttachment(content, type);
56
- this.currentTest.addAttachment(name, type, file);
53
+ testAttachment(name, content, options) {
54
+ const file = this.reporter.writeAttachment(content, options);
55
+ this.currentTest.addAttachment(name, options, file);
57
56
  }
58
57
  get currentTest() {
59
58
  if (this.reporter.currentTest === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"MochaAllure.js","sourceRoot":"","sources":["../src/MochaAllure.ts"],"names":[],"mappings":";;;AAAA,yDAU2B;AAE3B,+CAA4C;AAE5C,MAAa,WAAY,SAAQ,0BAAM;IACrC,YAA6B,QAAwB,EAAE,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AE,GAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEM,UAAU,CACf,IAAY,EACZ,OAAwB,EACxB,OAAiD;QAEjD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAEM,cAAc,CACnB,IAAY,EACZ,OAAwB,EACxB,OAAiD;QAEjD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,IAAc,WAAW;QACvB,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACnC,CAAC;IAEO,SAAS,CAAC,IAAY;QAC5B,MAAM,UAAU,GAAe,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACnC,OAAO,IAAI,yBAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;CACF;AA7ED,kCA6EC"}
@@ -1,11 +1,14 @@
1
1
  import * as Mocha from "mocha";
2
2
  import { MochaAllure } from "./MochaAllure";
3
3
  export declare let allure: MochaAllure;
4
+ declare type ParallelRunner = Mocha.Runner & {
5
+ linkPartialObjects?: (val: boolean) => ParallelRunner;
6
+ };
4
7
  export declare class MochaAllureReporter extends Mocha.reporters.Base {
5
- readonly runner: Mocha.Runner;
8
+ readonly runner: ParallelRunner;
6
9
  readonly opts: Mocha.MochaOptions;
7
10
  private coreReporter;
8
- constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions);
11
+ constructor(runner: ParallelRunner, opts: Mocha.MochaOptions);
9
12
  private onSuite;
10
13
  private onSuiteEnd;
11
14
  private onTest;
@@ -15,3 +18,4 @@ export declare class MochaAllureReporter extends Mocha.reporters.Base {
15
18
  private onHookStart;
16
19
  private onHookEnd;
17
20
  }
21
+ export {};
@@ -14,32 +14,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.MochaAllureReporter = exports.allure = void 0;
23
- const Mocha = __importStar(require("mocha"));
24
23
  const allure_js_commons_1 = require("allure-js-commons");
24
+ const Mocha = __importStar(require("mocha"));
25
25
  const AllureReporter_1 = require("./AllureReporter");
26
+ const { EVENT_SUITE_BEGIN, EVENT_SUITE_END, EVENT_TEST_BEGIN, EVENT_TEST_END, EVENT_TEST_PASS, EVENT_TEST_FAIL, EVENT_TEST_PENDING, EVENT_HOOK_BEGIN, EVENT_HOOK_END, } = Mocha.Runner.constants;
26
27
  class MochaAllureReporter extends Mocha.reporters.Base {
27
28
  constructor(runner, opts) {
28
29
  super(runner, opts);
29
30
  this.runner = runner;
30
31
  this.opts = opts;
31
- const allureConfig = Object.assign({ resultsDir: "allure-results" }, opts.reporterOptions);
32
+ const { resultsDir = "allure-results" } = opts.reporterOptions || {};
33
+ const allureConfig = Object.assign(Object.assign({}, opts.reporterOptions), { resultsDir });
32
34
  this.coreReporter = new AllureReporter_1.AllureReporter(new allure_js_commons_1.AllureRuntime(allureConfig));
33
35
  exports.allure = this.coreReporter.getImplementation();
34
- this.runner
35
- .on("suite", this.onSuite.bind(this))
36
- .on("suite end", this.onSuiteEnd.bind(this))
37
- .on("test", this.onTest.bind(this))
38
- .on("pass", this.onPassed.bind(this))
39
- .on("fail", this.onFailed.bind(this))
40
- .on("pending", this.onPending.bind(this))
41
- .on("hook", this.onHookStart.bind(this))
42
- .on("hook end", this.onHookEnd.bind(this));
36
+ if (runner.linkPartialObjects) {
37
+ runner.linkPartialObjects(true);
38
+ }
39
+ runner
40
+ .on(EVENT_SUITE_BEGIN, this.onSuite.bind(this))
41
+ .on(EVENT_SUITE_END, this.onSuiteEnd.bind(this))
42
+ .on(EVENT_TEST_BEGIN, this.onTest.bind(this))
43
+ .on(EVENT_TEST_PASS, this.onPassed.bind(this))
44
+ .on(EVENT_TEST_FAIL, this.onFailed.bind(this))
45
+ .on(EVENT_TEST_PENDING, this.onPending.bind(this))
46
+ .on(EVENT_HOOK_BEGIN, this.onHookStart.bind(this))
47
+ .on(EVENT_HOOK_END, this.onHookEnd.bind(this));
43
48
  }
44
49
  onSuite(suite) {
45
50
  this.coreReporter.startSuite(suite.fullTitle());
@@ -60,10 +65,11 @@ class MochaAllureReporter extends Mocha.reporters.Base {
60
65
  this.coreReporter.pendingTestCase(test);
61
66
  }
62
67
  onHookStart(hook) {
63
- this.coreReporter.startHook(hook.title);
68
+ this.coreReporter.startHook(hook);
64
69
  }
65
70
  onHookEnd(hook) {
66
- this.coreReporter.endHook(hook.error());
71
+ var _a;
72
+ this.coreReporter.endHook((_a = hook === null || hook === void 0 ? void 0 : hook.error) === null || _a === void 0 ? void 0 : _a.call(hook));
67
73
  }
68
74
  }
69
75
  exports.MochaAllureReporter = MochaAllureReporter;
@@ -1 +1 @@
1
- {"version":3,"file":"MochaAllureReporter.js","sourceRoot":"","sources":["../src/MochaAllureReporter.ts"],"names":[],"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C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,OAAO,CAAC,KAAkB;QAChC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,IAAgB;QAC7B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAEO,QAAQ,CAAC,IAAgB;QAC/B,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAEO,QAAQ,CAAC,IAAgB,EAAE,KAAY;QAC7C,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEO,SAAS,CAAC,IAAgB;QAChC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW,CAAC,IAAgB;QAClC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAEO,SAAS,CAAC,IAAgB;;QAChC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,+CAAX,IAAI,CAAW,CAAC,CAAC;IAC7C,CAAC;CACF;AA7DD,kDA6DC"}
package/package.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "allure-mocha",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0",
4
4
  "description": "Allure Mocha integration",
5
5
  "license": "Apache-2.0",
6
- "author": "Sergey Korol <serhii.s.korol@gmail.com>",
7
- "repository": "https://github.com/allure-framework/allure-js",
6
+ "author": {
7
+ "name": "Qameta Software",
8
+ "email": "allure@qameta.io",
9
+ "url": "https://qameta.io/"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/allure-framework/allure-js.git",
14
+ "directory": "packages/allure-mocha"
15
+ },
8
16
  "keywords": [
9
17
  "mocha",
10
18
  "typescript",
@@ -15,37 +23,40 @@
15
23
  "scripts": {
16
24
  "clean": "rimraf ./dist ./out",
17
25
  "compile": "tsc",
18
- "prepublishOnly": "npm run clean && npm run build",
19
- "build": "npm run lint && npm run compile",
20
26
  "generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean",
21
27
  "allure-report": "allure serve ./out/allure-results",
28
+ "test:compile": "nyc ts-node --project test/tsconfig.json",
22
29
  "test": "nyc ts-node --project test/tsconfig.json test/runner.ts",
23
30
  "coverage": "codecov",
24
- "lint": "eslint ./src ./test --ext .ts",
25
- "lint-fix": "eslint ./src ./test ./index.ts --ext .ts --fix"
31
+ "lint": "eslint ./src --ext .ts",
32
+ "lint:fix": "eslint ./src --ext .ts --fix"
26
33
  },
27
34
  "devDependencies": {
28
- "@testdeck/mocha": "0.1.0",
35
+ "@testdeck/mocha": "0.1.2",
29
36
  "@types/chai": "^4.2.11",
30
- "@types/mocha": "^7.0.2",
37
+ "@types/glob": "^8.0.0",
38
+ "@types/mocha": "^9.0.0",
39
+ "@types/node": "^16.7.8",
31
40
  "chai": "^4.2.0",
32
41
  "codecov": "^3.6.5",
33
- "dotenv": "^8.2.0",
34
- "fs-jetpack": "^2.2.3",
35
- "mocha": "^8.1.1",
36
- "mocha-multi": "^1.1.3",
42
+ "fs-jetpack": "^4.1.0",
43
+ "glob": "^8.0.0",
44
+ "mocha": "^9.1.3",
45
+ "mocha-multi-reporters": "^1.5.1",
37
46
  "nyc": "^15.0.1",
38
- "prettier": "^2.0.5",
39
- "source-map-support": "^0.5.19"
47
+ "rimraf": "^3.0.2",
48
+ "source-map-support": "^0.5.19",
49
+ "ts-node": "^10.2.1",
50
+ "typescript": "^4.4.2"
40
51
  },
41
52
  "dependencies": {
42
- "allure-js-commons": "^2.0.0-beta.8"
53
+ "allure-js-commons": "2.0.0"
43
54
  },
44
55
  "peerDependencies": {
45
56
  "mocha": ">=6.2.x"
46
57
  },
47
58
  "nyc": {
48
- "check-coverage": true,
59
+ "check-coverage": false,
49
60
  "lines": 80,
50
61
  "statements": 80,
51
62
  "functions": 75,
@@ -66,5 +77,9 @@
66
77
  "report-dir": "./out/coverage",
67
78
  "temp-dir": "./out/.nyc"
68
79
  },
69
- "gitHead": "96cb18546ac2ad3797beb1ce51d7f45ef5a0676c"
70
- }
80
+ "files": [
81
+ "dist",
82
+ "runtime.js",
83
+ "runtime.d.ts"
84
+ ]
85
+ }
package/runtime.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { MochaAllure } from "./dist/MochaAllure";
2
2
  export { MochaAllureReporter } from "./dist/MochaAllureReporter";
3
- export { allure } from './dist/MochaAllureReporter';
3
+ export { allure } from "./dist/MochaAllureReporter";
package/runtime.js CHANGED
@@ -9,23 +9,23 @@ const _MochaAllure = require("./dist/MochaAllure");
9
9
  const _MochaAllureReporter = require("./dist/MochaAllureReporter");
10
10
 
11
11
  Object.defineProperty(exports, "__esModule", {
12
- value: true
12
+ value: true,
13
13
  });
14
14
  Object.defineProperty(module.exports, "MochaAllure", {
15
15
  enumerable: true,
16
16
  get: function () {
17
17
  return _MochaAllure.MochaAllure;
18
- }
18
+ },
19
19
  });
20
20
  Object.defineProperty(module.exports, "allure", {
21
21
  enumerable: true,
22
22
  get: function () {
23
23
  return _MochaAllureReporter.allure;
24
- }
24
+ },
25
25
  });
26
26
  Object.defineProperty(module.exports, "MochaAllureReporter", {
27
27
  enumerable: true,
28
28
  get: function () {
29
29
  return _MochaAllureReporter.MochaAllureReporter;
30
- }
30
+ },
31
31
  });