qase-javascript-commons 2.0.0-beta.1 → 2.0.0-beta.10

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.
Files changed (60) hide show
  1. package/README.md +74 -97
  2. package/changelog.md +159 -0
  3. package/dist/config/config-validation-schema.js +36 -6
  4. package/dist/env/env-enum.d.ts +22 -8
  5. package/dist/env/env-enum.js +22 -6
  6. package/dist/env/env-to-config.js +10 -3
  7. package/dist/env/env-type.d.ts +9 -4
  8. package/dist/env/env-validation-schema.js +23 -4
  9. package/dist/formatter/index.d.ts +1 -0
  10. package/dist/formatter/index.js +3 -1
  11. package/dist/formatter/jsonp-formatter.d.ts +13 -0
  12. package/dist/formatter/jsonp-formatter.js +28 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +1 -0
  15. package/dist/models/attachment.d.ts +9 -0
  16. package/dist/models/attachment.js +2 -0
  17. package/dist/models/execution-sum.d.ts +6 -0
  18. package/dist/models/execution-sum.js +2 -0
  19. package/dist/models/host-data.d.ts +11 -0
  20. package/dist/models/host-data.js +2 -0
  21. package/dist/models/index.d.ts +6 -2
  22. package/dist/models/index.js +6 -4
  23. package/dist/models/report.d.ts +14 -0
  24. package/dist/models/report.js +2 -0
  25. package/dist/models/short-result.d.ts +7 -0
  26. package/dist/models/short-result.js +2 -0
  27. package/dist/models/stats.d.ts +8 -0
  28. package/dist/models/stats.js +2 -0
  29. package/dist/models/step-data.d.ts +9 -0
  30. package/dist/models/step-data.js +2 -0
  31. package/dist/models/step-execution.d.ts +11 -0
  32. package/dist/models/step-execution.js +9 -0
  33. package/dist/models/test-execution.d.ts +19 -0
  34. package/dist/models/test-execution.js +15 -0
  35. package/dist/models/test-result.d.ts +24 -20
  36. package/dist/models/test-result.js +0 -13
  37. package/dist/models/test-step.d.ts +12 -10
  38. package/dist/models/test-step.js +6 -7
  39. package/dist/options/options-type.d.ts +2 -0
  40. package/dist/qase.d.ts +54 -10
  41. package/dist/qase.js +158 -37
  42. package/dist/reporters/abstract-reporter.d.ts +23 -40
  43. package/dist/reporters/abstract-reporter.js +33 -75
  44. package/dist/reporters/index.d.ts +1 -1
  45. package/dist/reporters/report-reporter.d.ts +28 -13
  46. package/dist/reporters/report-reporter.js +160 -15
  47. package/dist/reporters/testops-reporter.d.ts +80 -37
  48. package/dist/reporters/testops-reporter.js +246 -148
  49. package/dist/utils/logger.d.ts +29 -0
  50. package/dist/utils/logger.js +121 -0
  51. package/dist/utils/mimeTypes.d.ts +5 -0
  52. package/dist/utils/mimeTypes.js +41 -0
  53. package/dist/writer/driver-enum.d.ts +7 -0
  54. package/dist/writer/driver-enum.js +9 -1
  55. package/dist/writer/fs-writer.d.ts +22 -8
  56. package/dist/writer/fs-writer.js +75 -8
  57. package/dist/writer/index.d.ts +1 -1
  58. package/dist/writer/index.js +2 -1
  59. package/dist/writer/writer-interface.d.ts +5 -2
  60. package/package.json +6 -2
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.envValidationSchema = void 0;
4
4
  const env_enum_1 = require("./env-enum");
5
5
  const options_1 = require("../options");
6
+ const writer_1 = require("../writer");
6
7
  /**
7
8
  * @type {JSONSchemaType<EnvType>}
8
9
  */
@@ -14,6 +15,11 @@ exports.envValidationSchema = {
14
15
  enum: [options_1.ModeEnum.report, options_1.ModeEnum.testops, options_1.ModeEnum.off],
15
16
  nullable: true,
16
17
  },
18
+ [env_enum_1.EnvEnum.fallback]: {
19
+ type: 'string',
20
+ enum: [options_1.ModeEnum.report, options_1.ModeEnum.testops, options_1.ModeEnum.off],
21
+ nullable: true,
22
+ },
17
23
  [env_enum_1.EnvEnum.debug]: {
18
24
  type: 'boolean',
19
25
  nullable: true,
@@ -22,6 +28,10 @@ exports.envValidationSchema = {
22
28
  type: ['string', 'number'],
23
29
  nullable: true,
24
30
  },
31
+ [env_enum_1.EnvEnum.captureLogs]: {
32
+ type: 'boolean',
33
+ nullable: true,
34
+ },
25
35
  [env_enum_1.EnvTestOpsEnum.project]: {
26
36
  type: 'string',
27
37
  nullable: true,
@@ -30,8 +40,12 @@ exports.envValidationSchema = {
30
40
  type: 'boolean',
31
41
  nullable: true,
32
42
  },
33
- [env_enum_1.EnvTestOpsEnum.baseUrl]: {
34
- type: 'string',
43
+ [env_enum_1.EnvTestOpsEnum.defect]: {
44
+ type: 'boolean',
45
+ nullable: true,
46
+ },
47
+ [env_enum_1.EnvTestOpsEnum.useV2]: {
48
+ type: 'boolean',
35
49
  nullable: true,
36
50
  },
37
51
  [env_enum_1.EnvApiEnum.token]: {
@@ -58,7 +72,11 @@ exports.envValidationSchema = {
58
72
  type: 'boolean',
59
73
  nullable: true,
60
74
  },
61
- [env_enum_1.EnvRunEnum.environment]: {
75
+ [env_enum_1.EnvPlanEnum.id]: {
76
+ type: 'number',
77
+ nullable: true,
78
+ },
79
+ [env_enum_1.EnvBatchEnum.size]: {
62
80
  type: 'number',
63
81
  nullable: true,
64
82
  },
@@ -66,8 +84,9 @@ exports.envValidationSchema = {
66
84
  type: 'string',
67
85
  nullable: true,
68
86
  },
69
- [env_enum_1.EnvLocalEnum.ext]: {
87
+ [env_enum_1.EnvLocalEnum.format]: {
70
88
  type: 'string',
89
+ enum: [writer_1.FormatEnum.json, writer_1.FormatEnum.jsonp],
71
90
  nullable: true,
72
91
  },
73
92
  },
@@ -1,2 +1,3 @@
1
1
  export { type FormatterInterface } from './formatter-interface';
2
2
  export { JsonFormatter } from './json-formatter';
3
+ export { JsonpFormatter } from './jsonp-formatter';
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonFormatter = void 0;
3
+ exports.JsonpFormatter = exports.JsonFormatter = void 0;
4
4
  var json_formatter_1 = require("./json-formatter");
5
5
  Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return json_formatter_1.JsonFormatter; } });
6
+ var jsonp_formatter_1 = require("./jsonp-formatter");
7
+ Object.defineProperty(exports, "JsonpFormatter", { enumerable: true, get: function () { return jsonp_formatter_1.JsonpFormatter; } });
@@ -0,0 +1,13 @@
1
+ import { FormatterInterface } from './formatter-interface';
2
+ export type JsonpFormatterOptionsType = {
3
+ space?: number | undefined;
4
+ };
5
+ /**
6
+ * @class JsonFormatter
7
+ * @implements FormatterInterface
8
+ */
9
+ export declare class JsonpFormatter implements FormatterInterface {
10
+ private space;
11
+ constructor(options?: JsonpFormatterOptionsType);
12
+ format(object: unknown): Promise<string>;
13
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JsonpFormatter = void 0;
7
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
8
+ /**
9
+ * @class JsonFormatter
10
+ * @implements FormatterInterface
11
+ */
12
+ class JsonpFormatter {
13
+ constructor(options = {}) {
14
+ const { space = 4 } = options;
15
+ this.space = space;
16
+ }
17
+ // eslint-disable-next-line @typescript-eslint/require-await
18
+ async format(object) {
19
+ const json = JSON.stringify(object, (key, value) => {
20
+ if (key === 'error' && value instanceof Error) {
21
+ return (0, strip_ansi_1.default)(String(value));
22
+ }
23
+ return value;
24
+ }, this.space);
25
+ return `qaseJsonp(${json});`;
26
+ }
27
+ }
28
+ exports.JsonpFormatter = JsonpFormatter;
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from './options';
7
7
  export * from './reporters';
8
8
  export * from './writer';
9
9
  export * from './utils/get-package-version';
10
+ export * from './utils/mimeTypes';
package/dist/index.js CHANGED
@@ -23,3 +23,4 @@ __exportStar(require("./options"), exports);
23
23
  __exportStar(require("./reporters"), exports);
24
24
  __exportStar(require("./writer"), exports);
25
25
  __exportStar(require("./utils/get-package-version"), exports);
26
+ __exportStar(require("./utils/mimeTypes"), exports);
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ export type Attachment = {
3
+ file_name: string;
4
+ mime_type: string;
5
+ file_path: string | null;
6
+ content: string | Buffer;
7
+ size: number;
8
+ id: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export type ExecutionSum = {
2
+ start_time: number;
3
+ end_time: number;
4
+ duration: number;
5
+ cumulative_duration: number;
6
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export type HostData = {
2
+ system: string;
3
+ node: string;
4
+ release: string;
5
+ version: string;
6
+ machine: string;
7
+ python: string;
8
+ pip: string;
9
+ node_version: string;
10
+ npm: string;
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,6 @@
1
- export { type TestResultType, TestStatusEnum as TestStatusEnum, } from './test-result';
2
- export { type TestStepType, StepStatusEnum } from './test-step';
1
+ export { type TestResultType, Relation, Suite, SuiteData } from './test-result';
2
+ export { TestExecution, TestStatusEnum } from './test-execution';
3
+ export { type TestStepType, StepType } from './test-step';
4
+ export { StepStatusEnum } from './step-execution';
5
+ export { Attachment } from './attachment';
6
+ export { Report } from './report';
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StepStatusEnum = exports.TestStatusEnum = void 0;
4
- var test_result_1 = require("./test-result");
5
- Object.defineProperty(exports, "TestStatusEnum", { enumerable: true, get: function () { return test_result_1.TestStatusEnum; } });
3
+ exports.StepStatusEnum = exports.StepType = exports.TestStatusEnum = void 0;
4
+ var test_execution_1 = require("./test-execution");
5
+ Object.defineProperty(exports, "TestStatusEnum", { enumerable: true, get: function () { return test_execution_1.TestStatusEnum; } });
6
6
  var test_step_1 = require("./test-step");
7
- Object.defineProperty(exports, "StepStatusEnum", { enumerable: true, get: function () { return test_step_1.StepStatusEnum; } });
7
+ Object.defineProperty(exports, "StepType", { enumerable: true, get: function () { return test_step_1.StepType; } });
8
+ var step_execution_1 = require("./step-execution");
9
+ Object.defineProperty(exports, "StepStatusEnum", { enumerable: true, get: function () { return step_execution_1.StepStatusEnum; } });
@@ -0,0 +1,14 @@
1
+ import { HostData } from './host-data';
2
+ import { ShortResult } from './short-result';
3
+ import { Stats } from './stats';
4
+ import { ExecutionSum } from './execution-sum';
5
+ export type Report = {
6
+ environment: string;
7
+ execution: ExecutionSum;
8
+ host_data: HostData;
9
+ results: ShortResult[];
10
+ stats: Stats;
11
+ suites: any[];
12
+ threads: string[];
13
+ title: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export type ShortResult = {
2
+ id: string;
3
+ title: string;
4
+ status: string;
5
+ duration: number;
6
+ thread: string | null;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export type Stats = {
2
+ passed: number;
3
+ failed: number;
4
+ skipped: number;
5
+ broken: number;
6
+ muted: number;
7
+ total: number;
8
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export interface StepTextData {
2
+ action: string;
3
+ expected_result: string | null;
4
+ }
5
+ export interface StepGherkinData {
6
+ keyword: string;
7
+ name: string;
8
+ line: number;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export declare enum StepStatusEnum {
2
+ passed = "passed",
3
+ failed = "failed",
4
+ blocked = "blocked"
5
+ }
6
+ export interface StepExecution {
7
+ start_time: number | null;
8
+ status: StepStatusEnum;
9
+ end_time: number | null;
10
+ duration: number | null;
11
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StepStatusEnum = void 0;
4
+ var StepStatusEnum;
5
+ (function (StepStatusEnum) {
6
+ StepStatusEnum["passed"] = "passed";
7
+ StepStatusEnum["failed"] = "failed";
8
+ StepStatusEnum["blocked"] = "blocked";
9
+ })(StepStatusEnum || (exports.StepStatusEnum = StepStatusEnum = {}));
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @enum {string}
3
+ */
4
+ export declare enum TestStatusEnum {
5
+ passed = "passed",
6
+ failed = "failed",
7
+ skipped = "skipped",
8
+ disabled = "disabled",
9
+ blocked = "blocked",
10
+ invalid = "invalid"
11
+ }
12
+ export interface TestExecution {
13
+ start_time: number | null;
14
+ status: TestStatusEnum;
15
+ end_time: number | null;
16
+ duration: number | null;
17
+ stacktrace: string | null;
18
+ thread: string | null;
19
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestStatusEnum = void 0;
4
+ /**
5
+ * @enum {string}
6
+ */
7
+ var TestStatusEnum;
8
+ (function (TestStatusEnum) {
9
+ TestStatusEnum["passed"] = "passed";
10
+ TestStatusEnum["failed"] = "failed";
11
+ TestStatusEnum["skipped"] = "skipped";
12
+ TestStatusEnum["disabled"] = "disabled";
13
+ TestStatusEnum["blocked"] = "blocked";
14
+ TestStatusEnum["invalid"] = "invalid";
15
+ })(TestStatusEnum || (exports.TestStatusEnum = TestStatusEnum = {}));
@@ -1,25 +1,29 @@
1
1
  import { TestStepType } from './test-step';
2
- /**
3
- * @enum {string}
4
- */
5
- export declare enum TestStatusEnum {
6
- passed = "passed",
7
- failed = "failed",
8
- skipped = "skipped",
9
- disabled = "disabled",
10
- blocked = "blocked",
11
- invalid = "invalid"
12
- }
2
+ import { Attachment } from './attachment';
3
+ import { TestExecution } from './test-execution';
13
4
  export type TestResultType = {
14
5
  id: string;
15
- testOpsId: number[];
16
6
  title: string;
17
- status: `${TestStatusEnum}`;
18
- suiteTitle?: string | string[] | undefined;
19
- error?: Error | undefined;
20
- startTime?: number | undefined;
21
- duration?: number | undefined;
22
- endTime?: number | undefined;
23
- steps?: TestStepType[] | undefined;
24
- attachments?: string[] | undefined;
7
+ signature: string;
8
+ run_id: number | null;
9
+ testops_id: number | number[] | null;
10
+ execution: TestExecution;
11
+ fields: Record<string, string>;
12
+ attachments: Attachment[];
13
+ steps: TestStepType[];
14
+ params: Record<string, string>;
15
+ author: string | null;
16
+ relations: Relation | null;
17
+ muted: boolean;
18
+ message: string | null;
19
+ };
20
+ export type Relation = {
21
+ suite?: Suite;
22
+ };
23
+ export type Suite = {
24
+ data: SuiteData[];
25
+ };
26
+ export type SuiteData = {
27
+ title: string;
28
+ public_id: number | null;
25
29
  };
@@ -1,15 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestStatusEnum = void 0;
4
- /**
5
- * @enum {string}
6
- */
7
- var TestStatusEnum;
8
- (function (TestStatusEnum) {
9
- TestStatusEnum["passed"] = "passed";
10
- TestStatusEnum["failed"] = "failed";
11
- TestStatusEnum["skipped"] = "skipped";
12
- TestStatusEnum["disabled"] = "disabled";
13
- TestStatusEnum["blocked"] = "blocked";
14
- TestStatusEnum["invalid"] = "invalid";
15
- })(TestStatusEnum || (exports.TestStatusEnum = TestStatusEnum = {}));
@@ -1,14 +1,16 @@
1
- export declare enum StepStatusEnum {
2
- passed = "passed",
3
- failed = "failed",
4
- blocked = "blocked"
1
+ import { StepGherkinData, StepTextData } from './step-data';
2
+ import { StepExecution } from './step-execution';
3
+ import { Attachment } from './attachment';
4
+ export declare enum StepType {
5
+ TEXT = "text",
6
+ GHERKIN = "gherkin"
5
7
  }
6
8
  export type TestStepType = {
7
9
  id: string;
8
- title: string;
9
- status: `${StepStatusEnum}`;
10
- duration?: number | undefined;
11
- error?: Error | undefined;
12
- steps?: TestStepType[] | undefined;
13
- attachments?: string[] | undefined;
10
+ step_type: StepType;
11
+ data: StepTextData | StepGherkinData;
12
+ parent_id: string | null;
13
+ execution: StepExecution;
14
+ attachments: Attachment[];
15
+ steps: TestStepType[];
14
16
  };
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StepStatusEnum = void 0;
4
- var StepStatusEnum;
5
- (function (StepStatusEnum) {
6
- StepStatusEnum["passed"] = "passed";
7
- StepStatusEnum["failed"] = "failed";
8
- StepStatusEnum["blocked"] = "blocked";
9
- })(StepStatusEnum || (exports.StepStatusEnum = StepStatusEnum = {}));
3
+ exports.StepType = void 0;
4
+ var StepType;
5
+ (function (StepType) {
6
+ StepType["TEXT"] = "text";
7
+ StepType["GHERKIN"] = "gherkin";
8
+ })(StepType || (exports.StepType = StepType = {}));
@@ -20,6 +20,8 @@ export type OptionsType = {
20
20
  frameworkName: string;
21
21
  reporterName: string;
22
22
  mode?: `${ModeEnum}` | undefined;
23
+ fallback?: `${ModeEnum}` | undefined;
24
+ captureLogs?: boolean | undefined;
23
25
  debug?: boolean | undefined;
24
26
  environment?: string | number | undefined;
25
27
  testops?: (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType) | undefined;
package/dist/qase.d.ts CHANGED
@@ -1,11 +1,17 @@
1
- import { AbstractReporter, LoggerInterface } from './reporters';
2
1
  import { OptionsType } from './options';
3
2
  import { TestResultType } from './models';
3
+ export interface ReporterInterface {
4
+ addTestResult(result: TestResultType): Promise<void>;
5
+ publish(): Promise<void>;
6
+ startTestRun(): void;
7
+ isCaptureLogs(): boolean;
8
+ }
4
9
  /**
5
10
  * @class QaseReporter
6
11
  * @implements AbstractReporter
7
12
  */
8
- export declare class QaseReporter extends AbstractReporter {
13
+ export declare class QaseReporter implements ReporterInterface {
14
+ private static instance;
9
15
  /**
10
16
  * @param {string} frameworkPackage
11
17
  * @param {string} frameworkName
@@ -15,36 +21,74 @@ export declare class QaseReporter extends AbstractReporter {
15
21
  */
16
22
  private static createHeaders;
17
23
  /**
18
- * @type {ReporterInterface}
24
+ * @type {InternalReporterInterface}
19
25
  * @private
20
26
  */
21
- private upstreamReporter?;
27
+ private readonly upstreamReporter?;
28
+ /**
29
+ * @type {InternalReporterInterface}
30
+ * @private
31
+ */
32
+ private readonly fallbackReporter?;
33
+ /**
34
+ * @type {boolean | undefined}
35
+ * @private
36
+ */
37
+ private readonly captureLogs;
22
38
  /**
23
39
  * @type {boolean}
24
40
  * @private
25
41
  */
26
42
  private disabled;
43
+ /**
44
+ * @type {boolean}
45
+ * @private
46
+ */
47
+ private useFallback;
48
+ private readonly logger;
49
+ private startTestRunOperation?;
50
+ /**
51
+ * @param {OptionsType} options
52
+ */
53
+ private constructor();
54
+ /**
55
+ * @returns {void}
56
+ */
57
+ startTestRun(): void;
27
58
  /**
28
59
  * @param {OptionsType} options
29
- * @param {LoggerInterface} logger
60
+ * @returns {QaseReporter}
30
61
  */
31
- constructor(options: OptionsType, logger?: LoggerInterface);
62
+ static getInstance(options: OptionsType): QaseReporter;
32
63
  /**
33
64
  * @param {TestResultType} result
34
65
  */
35
- addTestResult(result: TestResultType): void;
66
+ addTestResult(result: TestResultType): Promise<void>;
67
+ /**
68
+ * @param {TestResultType} result
69
+ * @private
70
+ */
71
+ private addTestResultToFallback;
72
+ /**
73
+ * @returns {boolean}
74
+ */
75
+ isCaptureLogs(): boolean;
36
76
  /**
37
77
  * @returns {Promise<void>}
38
78
  */
39
79
  publish(): Promise<void>;
80
+ /**
81
+ * @returns {Promise<void>}
82
+ */
83
+ private publishFallback;
40
84
  /**
41
85
  * @todo implement mode registry
86
+ * @param {ModeEnum} mode
42
87
  * @param {OptionsType} options
43
- * @param {LoggerInterface} logger
44
- * @returns {ReporterInterface}
88
+ * @returns {InternalReporterInterface}
45
89
  * @private
46
90
  */
47
- private createUpstreamReporter;
91
+ private createReporter;
48
92
  /**
49
93
  * @param {TestResultType} test
50
94
  * @private