qase-javascript-commons 2.5.0 → 2.5.1
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 +6 -0
- package/dist/utils/test-status-utils.js +15 -4
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -14,7 +14,7 @@ function determineTestStatus(error, originalStatus) {
|
|
|
14
14
|
return mapOriginalStatus(originalStatus);
|
|
15
15
|
}
|
|
16
16
|
// Check if it's an assertion error
|
|
17
|
-
if (isAssertionError(error)) {
|
|
17
|
+
if (isAssertionError(error, originalStatus)) {
|
|
18
18
|
return test_execution_1.TestStatusEnum.failed;
|
|
19
19
|
}
|
|
20
20
|
// For all other errors, return invalid
|
|
@@ -23,16 +23,19 @@ function determineTestStatus(error, originalStatus) {
|
|
|
23
23
|
/**
|
|
24
24
|
* Checks if error is an assertion error
|
|
25
25
|
* @param error - Error object
|
|
26
|
+
* @param originalStatus - Original test status from test runner
|
|
26
27
|
* @returns boolean - true if assertion error
|
|
27
28
|
*/
|
|
28
|
-
function isAssertionError(error) {
|
|
29
|
+
function isAssertionError(error, originalStatus) {
|
|
29
30
|
const errorMessage = error.message.toLowerCase();
|
|
30
31
|
const errorStack = error.stack?.toLowerCase() || '';
|
|
32
|
+
const normalizedOriginalStatus = originalStatus.toLowerCase();
|
|
31
33
|
// Common assertion error patterns
|
|
32
34
|
const assertionPatterns = [
|
|
33
35
|
'expect',
|
|
34
36
|
'assert',
|
|
35
37
|
'matcher',
|
|
38
|
+
'objectcontaining',
|
|
36
39
|
'assertion',
|
|
37
40
|
'expected',
|
|
38
41
|
'actual',
|
|
@@ -77,6 +80,14 @@ function isAssertionError(error) {
|
|
|
77
80
|
const nonAssertionPatternsWithoutTimeout = nonAssertionPatterns.filter(pattern => pattern !== 'timeout');
|
|
78
81
|
const hasNonAssertionPattern = nonAssertionPatternsWithoutTimeout.some(pattern => errorMessage.includes(pattern) || errorStack.includes(pattern));
|
|
79
82
|
if (hasNonAssertionPattern) {
|
|
83
|
+
const hasAssertionContext = assertionPatterns.some(pattern => errorMessage.includes(pattern) || errorStack.includes(pattern));
|
|
84
|
+
const isRunnerFailed = normalizedOriginalStatus === 'failed' || normalizedOriginalStatus === 'timedout' || normalizedOriginalStatus === 'interrupted';
|
|
85
|
+
const isSyntaxError = errorMessage.includes('syntaxerror') || errorStack.includes('syntaxerror');
|
|
86
|
+
// When runner reported failure and error has assertion context (expect, ObjectContaining, diff),
|
|
87
|
+
// treat as Failed. Exception: SyntaxError (e.g. "Unexpected token") contains "expected" as false positive.
|
|
88
|
+
if (isRunnerFailed && hasAssertionContext && !isSyntaxError) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
80
91
|
return false;
|
|
81
92
|
}
|
|
82
93
|
// For timeout errors without expect, treat as invalid
|
|
@@ -99,6 +110,7 @@ function isAssertionError(error) {
|
|
|
99
110
|
* @returns TestStatusEnum
|
|
100
111
|
*/
|
|
101
112
|
function mapOriginalStatus(originalStatus) {
|
|
113
|
+
// Keys must be lowercase to match normalizedStatus (case-insensitive matching)
|
|
102
114
|
const statusMap = {
|
|
103
115
|
'passed': test_execution_1.TestStatusEnum.passed,
|
|
104
116
|
'failed': test_execution_1.TestStatusEnum.failed,
|
|
@@ -107,10 +119,9 @@ function mapOriginalStatus(originalStatus) {
|
|
|
107
119
|
'pending': test_execution_1.TestStatusEnum.skipped,
|
|
108
120
|
'todo': test_execution_1.TestStatusEnum.disabled,
|
|
109
121
|
'focused': test_execution_1.TestStatusEnum.passed,
|
|
110
|
-
'
|
|
122
|
+
'timedout': test_execution_1.TestStatusEnum.failed,
|
|
111
123
|
'interrupted': test_execution_1.TestStatusEnum.failed,
|
|
112
124
|
};
|
|
113
|
-
// Convert to lowercase for case-insensitive matching
|
|
114
125
|
const normalizedStatus = originalStatus.toLowerCase();
|
|
115
126
|
return statusMap[normalizedStatus] || test_execution_1.TestStatusEnum.skipped;
|
|
116
127
|
}
|