mocha-qtest-mapping-reporter
Advanced tools
Comparing version 1.0.6 to 1.0.7
42
index.js
@@ -29,2 +29,5 @@ const mocha = require('mocha') | ||
const qTestConfig = getQTestConfig(options) | ||
const stateFailed = qTestConfig.stateFailed || 'FAIL' | ||
const statePassed = qTestConfig.statePassed || 'PASS' | ||
const statePending = qTestConfig.statePending || 'PENDING' | ||
@@ -102,3 +105,3 @@ if (!testSuiteId && (!parentId || !testSuiteName || !parentType)) { | ||
if (!qTestClient || !test.qTest) return | ||
test.qTest.executionLog.status = qTestConfig.statePassed || 'PASS' | ||
test.qTest.executionLog.status = statePassed | ||
}) | ||
@@ -113,3 +116,3 @@ | ||
test.qTest.executionLog.status = qTestConfig.stateFailed || 'FAIL' | ||
test.qTest.executionLog.status = stateFailed | ||
test.qTest.executionLog.note = err.stack | ||
@@ -126,2 +129,5 @@ // test.qTest.executionLog.attachments: [{ | ||
log(1) | ||
if (!qTestClient || !test.qTest) return | ||
test.qTest.executionLog.status = statePending | ||
}) | ||
@@ -150,3 +156,3 @@ | ||
testResults = [...testResults, ...getNotStartedTests(suite.parent, qTestConfig)] | ||
testResults = [...testResults, ...getNotStartedTests(suite.parent, stateFailed, statePending)] | ||
}) | ||
@@ -169,7 +175,8 @@ | ||
const failedState = qTestConfig.stateFailed || 'FAIL' | ||
// submit first passed, then pending and failed tests in the end | ||
// to avoid marking skipped or failed tests as passed | ||
testResults | ||
.sort((a, b) => a.executionLog.status === statePending ? -1 : 1) | ||
.sort((a, b) => a.executionLog.status === stateFailed ? 1 : -1) | ||
// submit failed tests in the end to avoid marking failed tests as passed | ||
testResults.sort((a, b) => a.executionLog.status === failedState ? 1 : -1) | ||
try { | ||
@@ -259,7 +266,7 @@ await getSuite | ||
* @param {Mocha.Suite} suite | ||
* @param {Object} qTestConfig | ||
* @param {string} stateFailed | ||
* @param {string} statePending | ||
* @returns {Array} | ||
*/ | ||
function getNotStartedTests (suite, qTestConfig) { | ||
const failedState = qTestConfig.stateFailed || 'FAIL' | ||
function getNotStartedTests (suite, stateFailed, statePending) { | ||
let tests = [] | ||
@@ -270,3 +277,3 @@ | ||
let test = suite.tests[i] | ||
if (test.qTest || test.state || test.pending) continue | ||
if (test.qTest || test.state) continue | ||
@@ -280,5 +287,3 @@ const testCaseId = getQTestId(test.title) | ||
exe_start_date: new Date().toISOString(), | ||
exe_end_date: new Date().toISOString(), | ||
status: failedState, | ||
note: 'Test was not started and marked as failed due to failure in before/beforeEach hook.' | ||
exe_end_date: new Date().toISOString() | ||
}, | ||
@@ -288,2 +293,9 @@ testCaseId, | ||
} | ||
if (test.pending) { | ||
test.qTest.executionLog.status = statePending | ||
test.qTest.executionLog.note = 'Test or its suite is skipped.' | ||
} else { | ||
test.qTest.executionLog.status = stateFailed | ||
test.qTest.executionLog.note = 'Test was not started and marked as failed due to failure in before/beforeEach hook.' | ||
} | ||
tests.push(test.qTest) | ||
@@ -295,3 +307,3 @@ } | ||
suite.suites.forEach(suite => { | ||
tests = [...tests, ...getNotStartedTests(suite, qTestConfig)] | ||
tests = [...tests, ...getNotStartedTests(suite, stateFailed, statePending)] | ||
}) | ||
@@ -298,0 +310,0 @@ } |
{ | ||
"name": "mocha-qtest-mapping-reporter", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Map your automated test to qTest Test Case with tag", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17862
394