Skip to content

Commit

Permalink
fix: return correct test result status
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Jul 17, 2024
1 parent e68d6be commit 78c0ff9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/adapters/test-result/testplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, isAssertViewError, isImageDiffError, isNoRefImageError, wrapLinkByTag} from '../../common-utils';
import {
ErrorDetails,
TestplaneSuite,
Expand All @@ -32,7 +32,7 @@ export const getStatus = (eventName: ValueOf<Testplane['events']>, 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 isAssertViewError(testResult.err) ? TestStatus.FAIL : TestStatus.ERROR;
} else if (eventName === events.TEST_BEGIN) {
return TestStatus.RUNNING;
}
Expand Down
18 changes: 17 additions & 1 deletion test/unit/lib/adapters/test-result/testplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 78c0ff9

Please sign in to comment.