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 20, 2024
1 parent bf0c1d6 commit 5763ffb
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, hasUnrelatedToScreenshotsErrors, 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 hasUnrelatedToScreenshotsErrors(testResult.err!) ? TestStatus.ERROR : TestStatus.FAIL;

Check warning on line 35 in lib/adapters/test-result/testplane.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Forbidden non-null assertion

Check warning on line 35 in lib/adapters/test-result/testplane.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Forbidden non-null assertion

Check warning on line 35 in lib/adapters/test-result/testplane.ts

View workflow job for this annotation

GitHub Actions / build (22.4)

Forbidden non-null assertion
} 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 5763ffb

Please sign in to comment.