qase-javascript-commons 2.0.6 → 2.0.8

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/changelog.md CHANGED
@@ -1,3 +1,15 @@
1
+ # qase-javascript-commons@2.0.8
2
+
3
+ ## What's new
4
+
5
+ Fixed an issue with creating a test run with environment when the reporter ignored the `environment` parameter in the configuration.
6
+
7
+ # qase-javascript-commons@2.0.7
8
+
9
+ ## What's new
10
+
11
+ Fixed an issue with creating a defect for failed tests when the reporter ignored the `defect` parameter in the configuration.
12
+
1
13
  # qase-javascript-commons@2.0.6
2
14
 
3
15
  ## What's new
@@ -24,7 +24,7 @@ exports.configValidationSchema = {
24
24
  nullable: true,
25
25
  },
26
26
  environment: {
27
- type: ['string', 'number'],
27
+ type: 'string',
28
28
  nullable: true,
29
29
  },
30
30
  captureLogs: {
@@ -5,7 +5,7 @@ export type EnvType = {
5
5
  [EnvEnum.mode]?: `${ModeEnum}`;
6
6
  [EnvEnum.fallback]?: `${ModeEnum}`;
7
7
  [EnvEnum.debug]?: boolean;
8
- [EnvEnum.environment]?: string | number;
8
+ [EnvEnum.environment]?: string;
9
9
  [EnvEnum.captureLogs]?: boolean;
10
10
  [EnvTestOpsEnum.project]?: string;
11
11
  [EnvTestOpsEnum.uploadAttachments]?: boolean;
@@ -25,7 +25,7 @@ exports.envValidationSchema = {
25
25
  nullable: true,
26
26
  },
27
27
  [env_enum_1.EnvEnum.environment]: {
28
- type: ['string', 'number'],
28
+ type: 'string',
29
29
  nullable: true,
30
30
  },
31
31
  [env_enum_1.EnvEnum.captureLogs]: {
@@ -23,7 +23,7 @@ export type OptionsType = {
23
23
  fallback?: `${ModeEnum}` | undefined;
24
24
  captureLogs?: boolean | undefined;
25
25
  debug?: boolean | undefined;
26
- environment?: string | number | undefined;
26
+ environment?: string | undefined;
27
27
  testops?: (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType) | undefined;
28
28
  report?: RecursivePartial<AdditionalReportOptionsType> | undefined;
29
29
  };
package/dist/qase.js CHANGED
@@ -252,7 +252,7 @@ class QaseReporter {
252
252
  const { frameworkPackage, frameworkName, reporterName, environment, report = {}, testops = {}, } = options;
253
253
  switch (mode) {
254
254
  case options_1.ModeEnum.testops: {
255
- const { api: { token, headers, ...api } = {}, project, run: { title, description, ...run } = {}, plan = {}, batch = {}, useV2, uploadAttachments, } = testops;
255
+ const { api: { token, headers, ...api } = {}, project, run: { title, description, ...run } = {}, plan = {}, batch = {}, useV2, defect, uploadAttachments, } = testops;
256
256
  if (!token) {
257
257
  throw new Error(`Either "testops.api.token" parameter or "${env_1.EnvApiEnum.token}" environment variable is required in "testops" mode`);
258
258
  }
@@ -278,12 +278,13 @@ class QaseReporter {
278
278
  plan,
279
279
  batch,
280
280
  useV2,
281
- }, apiClient, typeof environment === 'number' ? environment : undefined);
281
+ defect,
282
+ }, apiClient, environment);
282
283
  }
283
284
  case options_1.ModeEnum.report: {
284
285
  const localOptions = report.connections?.[writer_1.DriverEnum.local];
285
286
  const writer = new writer_1.FsWriter(localOptions);
286
- return new reporters_1.ReportReporter(this.logger, writer, typeof environment === 'number' ? environment.toString() : environment, testops.run?.id);
287
+ return new reporters_1.ReportReporter(this.logger, writer, environment, testops.run?.id);
287
288
  }
288
289
  case options_1.ModeEnum.off:
289
290
  throw new disabled_exception_1.DisabledException();
@@ -97,7 +97,7 @@ export declare class TestOpsReporter extends AbstractReporter {
97
97
  * @param {QaseApiInterface} api
98
98
  * @param {number} environment
99
99
  */
100
- constructor(logger: LoggerInterface, options: TestOpsOptionsType, api: QaseApiInterface, environment?: number);
100
+ constructor(logger: LoggerInterface, options: TestOpsOptionsType, api: QaseApiInterface, environment?: string);
101
101
  /**
102
102
  * @returns {Promise<void>}
103
103
  */
@@ -79,7 +79,20 @@ class TestOpsReporter extends abstract_reporter_1.AbstractReporter {
79
79
  return;
80
80
  }
81
81
  this.logger.logDebug('Create test run');
82
- const { result } = await this.createRun(this.run.title, this.run.description, this.environment);
82
+ let environmentId;
83
+ if (this.environment != undefined) {
84
+ try {
85
+ const { data } = await this.api.environment.getEnvironments(this.projectCode, 100);
86
+ const env = data.result?.entities?.find((env) => env.slug === this.environment);
87
+ if (env) {
88
+ environmentId = env.id;
89
+ }
90
+ }
91
+ catch (error) {
92
+ throw new qase_error_1.QaseError('Cannot get environments', { cause: error });
93
+ }
94
+ }
95
+ const { result } = await this.createRun(this.run.title, this.run.description, environmentId);
83
96
  if (!result?.id) {
84
97
  throw new Error('Cannot create run.');
85
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qase-javascript-commons",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Qase JS Reporters",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",