From 5763ffbdf9348dfdae0bea17723507f06c4b44a3 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Thu, 18 Jul 2024 02:52:46 +0300 Subject: [PATCH] fix: return correct test result status --- lib/adapters/test-result/testplane.ts | 4 ++-- .../unit/lib/adapters/test-result/testplane.ts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/adapters/test-result/testplane.ts b/lib/adapters/test-result/testplane.ts index 3eb25b421..98efe2f4f 100644 --- a/lib/adapters/test-result/testplane.ts +++ b/lib/adapters/test-result/testplane.ts @@ -6,7 +6,7 @@ import {ValueOf} from 'type-fest'; import {getCommandsHistory} from '../../history-utils'; import {ERROR, FAIL, SUCCESS, TestStatus, UNKNOWN_SESSION_ID, UPDATED} from '../../constants'; -import {getError, hasFailedImages, isImageDiffError, isNoRefImageError, wrapLinkByTag} from '../../common-utils'; +import {getError, hasUnrelatedToScreenshotsErrors, isImageDiffError, isNoRefImageError, wrapLinkByTag} from '../../common-utils'; import { ErrorDetails, TestplaneSuite, @@ -32,7 +32,7 @@ export const getStatus = (eventName: ValueOf, events: Testp } else if (eventName === events.TEST_PENDING) { return TestStatus.SKIPPED; } else if (eventName === events.RETRY || eventName === events.TEST_FAIL) { - return hasFailedImages(testResult.assertViewResults as ImageInfoFull[]) ? TestStatus.FAIL : TestStatus.ERROR; + return hasUnrelatedToScreenshotsErrors(testResult.err!) ? TestStatus.ERROR : TestStatus.FAIL; } else if (eventName === events.TEST_BEGIN) { return TestStatus.RUNNING; } diff --git a/test/unit/lib/adapters/test-result/testplane.ts b/test/unit/lib/adapters/test-result/testplane.ts index 2144558e0..d9ff73ed8 100644 --- a/test/unit/lib/adapters/test-result/testplane.ts +++ b/test/unit/lib/adapters/test-result/testplane.ts @@ -6,14 +6,30 @@ import tmpOriginal from 'tmp'; import {TestStatus} from 'lib/constants/test-statuses'; import {ERROR_DETAILS_PATH} from 'lib/constants/paths'; -import {TestplaneTestResultAdapter, TestplaneTestResultAdapterOptions} from 'lib/adapters/test-result/testplane'; +import {TestplaneTestResultAdapter, TestplaneTestResultAdapterOptions, getStatus} from 'lib/adapters/test-result/testplane'; import {TestplaneTestResult} from 'lib/types'; import * as originalUtils from 'lib/server-utils'; import * as originalCommonUtils from 'lib/common-utils'; import * as originalTestAdapterUtils from 'lib/adapters/test-result/utils'; +import type Testplane from 'testplane'; import type {ReporterTestResult} from 'lib/adapters/test-result'; +describe('getStatus', () => { + it('should be "error" if test has both: runtime errors and assertview fails', () => { + const status = getStatus( + 'failTest', + {TEST_FAIL: 'failTest'} as Testplane['events'], + { + assertViewResults: [{}, {}], + err: {name: 'foo', message: 'bar'} + } as TestplaneTestResult + ); + + assert.equal(status, TestStatus.ERROR); + }); +}); + describe('TestplaneTestResultAdapter', () => { const sandbox = sinon.sandbox.create();