testcafe-reporter-qase 2.0.1 → 2.0.2

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,9 @@
1
+ # qase-testcafe@2.0.2
2
+
3
+ ## What's new
4
+
5
+ Improved error collection. The error stack trace contains more useful debugging information: browser, code, etc.
6
+
1
7
  # qase-testcafe@2.0.1
2
8
 
3
9
  ## What's new
package/dist/factory.d.ts CHANGED
@@ -7,6 +7,6 @@ export declare const factory: (options: TestcafeQaseOptionsType) => {
7
7
  noColors: boolean;
8
8
  reportTaskStart: () => void;
9
9
  reportFixtureStart: () => void;
10
- reportTestDone: (name: string, testRunInfo: TestRunInfoType, meta: Record<string, string>) => Promise<void>;
10
+ reportTestDone(name: string, testRunInfo: TestRunInfoType, meta: Record<string, string>): Promise<void>;
11
11
  reportTaskDone: () => Promise<void>;
12
12
  };
package/dist/factory.js CHANGED
@@ -16,8 +16,12 @@ const factory = (options) => {
16
16
  reportFixtureStart: () => {
17
17
  /* empty */
18
18
  },
19
- reportTestDone: async (name, testRunInfo, meta) => {
20
- await reporter.reportTestDone(name, testRunInfo, meta);
19
+ async reportTestDone(name, testRunInfo, meta) {
20
+ return reporter.reportTestDone(name, testRunInfo, meta,
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
+ // @ts-expect-error Inject testrail error formatting method with bound context
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
24
+ this.formatError.bind(this));
21
25
  },
22
26
  reportTaskDone: async () => {
23
27
  await reporter.reportTaskDone();
@@ -11,10 +11,11 @@ interface TestRunErrorFormattableAdapterType {
11
11
  screenshotPath: string;
12
12
  testRunId: string;
13
13
  testRunPhase: string;
14
+ type: string;
14
15
  code?: string;
15
16
  isTestCafeError?: boolean;
16
17
  callsite?: CallsiteRecordType;
17
- errMsg?: string;
18
+ errMsg: string;
18
19
  diff?: boolean;
19
20
  id?: string;
20
21
  }
@@ -53,12 +54,6 @@ export declare class TestcafeQaseReporter {
53
54
  * @private
54
55
  */
55
56
  private static getStatus;
56
- /**
57
- * @param {TestRunErrorFormattableAdapterType[]} errors
58
- * @returns {Error}
59
- * @private
60
- */
61
- private static transformErrors;
62
57
  /**
63
58
  * @param {ScreenshotType[]} screenshots
64
59
  * @returns {Attachment[]}
@@ -83,8 +78,9 @@ export declare class TestcafeQaseReporter {
83
78
  * @param {string} title
84
79
  * @param {TestRunInfoType} testRunInfo
85
80
  * @param {Record<string, string>} meta
81
+ * @param formatError
86
82
  */
87
- reportTestDone: (title: string, testRunInfo: TestRunInfoType, meta: Record<string, string>) => Promise<void>;
83
+ reportTestDone: (title: string, testRunInfo: TestRunInfoType, meta: Record<string, string>, formatError: (error: any, prefix: string) => string) => Promise<void>;
88
84
  /**
89
85
  * @returns {Promise<void>}
90
86
  */
package/dist/reporter.js CHANGED
@@ -30,22 +30,6 @@ class TestcafeQaseReporter {
30
30
  }
31
31
  return qase_javascript_commons_1.TestStatusEnum.passed;
32
32
  }
33
- /**
34
- * @param {TestRunErrorFormattableAdapterType[]} errors
35
- * @returns {Error}
36
- * @private
37
- */
38
- static transformErrors(errors) {
39
- const [errorMessages, errorStacks] = errors.reduce(([messages, stacks], error) => {
40
- const stack = error.callsite?.stackFrames?.map((line) => String(line)) ?? [];
41
- messages.push(error.errMsg ?? 'Error');
42
- stacks.push(stack.join('\n'));
43
- return [messages, stacks];
44
- }, [[], []]);
45
- const error = new Error(errorMessages.join('\n\n'));
46
- error.stack = errorStacks.join('\n\n');
47
- return error;
48
- }
49
33
  /**
50
34
  * @param {ScreenshotType[]} screenshots
51
35
  * @returns {Attachment[]}
@@ -80,9 +64,14 @@ class TestcafeQaseReporter {
80
64
  * @param {string} title
81
65
  * @param {TestRunInfoType} testRunInfo
82
66
  * @param {Record<string, string>} meta
67
+ * @param formatError
83
68
  */
84
- this.reportTestDone = async (title, testRunInfo, meta) => {
85
- const error = TestcafeQaseReporter.transformErrors(testRunInfo.errs);
69
+ this.reportTestDone = async (title, testRunInfo, meta, formatError) => {
70
+ const errorLog = testRunInfo.errs
71
+ .map((error, index) => formatError(error, `${index + 1} `).replace(
72
+ // eslint-disable-next-line no-control-regex
73
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''))
74
+ .join('\n');
86
75
  const metadata = this.getMeta(meta);
87
76
  await this.reporter.addTestResult({
88
77
  author: null,
@@ -91,11 +80,11 @@ class TestcafeQaseReporter {
91
80
  start_time: null,
92
81
  end_time: null,
93
82
  duration: testRunInfo.durationMs,
94
- stacktrace: error.stack ?? null,
83
+ stacktrace: errorLog,
95
84
  thread: null,
96
85
  },
97
86
  fields: metadata[metadataEnum.fields],
98
- message: error.message,
87
+ message: errorLog ? errorLog.split('\n')[0] ?? '' : '',
99
88
  muted: false,
100
89
  params: metadata[metadataEnum.parameters],
101
90
  group_params: metadata[metadataEnum.groupParameters],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testcafe-reporter-qase",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Qase TMS TestCafe Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",