diff --git a/lib/common-utils.ts b/lib/common-utils.ts index 07f9ecdf8..1cffb41ff 100644 --- a/lib/common-utils.ts +++ b/lib/common-utils.ts @@ -5,7 +5,7 @@ import axios, {AxiosRequestConfig} from 'axios'; import {SUCCESS, FAIL, ERROR, SKIPPED, UPDATED, IDLE, RUNNING, QUEUED, TestStatus} from './constants'; import {UNCHECKED, INDETERMINATE, CHECKED} from './constants/checked-statuses'; -import {AssertViewResult, ImageData, ImageBase64, ImageInfoFull, TestError} from './types'; +import {AssertViewResult, ImageData, ImageBase64, ImageInfoFull, TestError, ImageInfoError} from './types'; import {ErrorName, ImageDiffError, NoRefImageError} from './errors'; export const getShortMD5 = (str: string): string => { return crypto.createHash('md5').update(str, 'ascii').digest('hex').substr(0, 7); @@ -87,6 +87,10 @@ export const mkTestId = (fullTitle: string, browserId: string): string => { return fullTitle + '.' + browserId; }; +export const isAssertViewError = (error?: unknown): boolean => { + return (error as {name?: string})?.name === ErrorName.ASSERT_VIEW; +}; + export const isImageDiffError = (error?: unknown): error is ImageDiffError => { return (error as {name?: string})?.name === ErrorName.IMAGE_DIFF; }; @@ -102,7 +106,7 @@ export const hasNoRefImageErrors = ({assertViewResults = []}: {assertViewResults const hasFailedImages = (result: {imagesInfo?: ImageInfoFull[]}): boolean => { const {imagesInfo = []} = result; - return imagesInfo.some((imageInfo: ImageInfoFull) => isErroredStatus(imageInfo.status) || isFailStatus(imageInfo.status)); + return imagesInfo.some((imageInfo: ImageInfoFull) => !isAssertViewError((imageInfo as ImageInfoError).error) && (isErroredStatus(imageInfo.status) || isFailStatus(imageInfo.status))); }; export const hasResultFails = (testResult: {status: TestStatus, imagesInfo?: ImageInfoFull[]}): boolean => { diff --git a/lib/errors/index.ts b/lib/errors/index.ts index b1899863b..a3acaf709 100644 --- a/lib/errors/index.ts +++ b/lib/errors/index.ts @@ -4,7 +4,8 @@ import {ValueOf} from 'type-fest'; export const ErrorName = { IMAGE_DIFF: 'ImageDiffError', - NO_REF_IMAGE: 'NoRefImageError' + NO_REF_IMAGE: 'NoRefImageError', + ASSERT_VIEW: 'AssertViewError' } as const; export type ErrorName = ValueOf; export type ErrorNames = typeof ErrorName; diff --git a/lib/image-handler.ts b/lib/image-handler.ts index 6c6bb4b57..ac808ec08 100644 --- a/lib/image-handler.ts +++ b/lib/image-handler.ts @@ -132,7 +132,7 @@ export class ImageHandler extends EventEmitter2 implements ImagesInfoFormatter { status = FAIL; } else if (isNoRefImageError(assertResult)) { status = ERROR; - error = _.pick(assertResult, ['message', 'stack']); + error = _.pick(assertResult, ['message', 'name', 'stack']); } else { status = SUCCESS; } diff --git a/lib/static/components/retry-switcher/item.jsx b/lib/static/components/retry-switcher/item.jsx index 5818fa2c4..330b1ab7a 100644 --- a/lib/static/components/retry-switcher/item.jsx +++ b/lib/static/components/retry-switcher/item.jsx @@ -4,7 +4,7 @@ import classNames from 'classnames'; import {connect} from 'react-redux'; import {get} from 'lodash'; import {ERROR} from '../../../constants/test-statuses'; -import {isFailStatus, isImageDiffError, isNoRefImageError} from '../../../common-utils'; +import {isAssertViewError, isFailStatus, isImageDiffError, isNoRefImageError} from '../../../common-utils'; class RetrySwitcherItem extends Component { static propTypes = { @@ -50,5 +50,5 @@ export default connect( )(RetrySwitcherItem); function hasScreenAndAssertErrors(status, error) { - return isFailStatus(status) && error && !isNoRefImageError(error) && !isImageDiffError(error); + return isFailStatus(status) && error && !isNoRefImageError(error) && !isImageDiffError(error) && !isAssertViewError(error); } diff --git a/lib/static/components/section/body/tabs.jsx b/lib/static/components/section/body/tabs.jsx index 0c62b740e..b3a8e2593 100644 --- a/lib/static/components/section/body/tabs.jsx +++ b/lib/static/components/section/body/tabs.jsx @@ -42,6 +42,7 @@ export default class Tabs extends Component { ? null : this._drawTab({key: errorTabId}); } + console.log(result.imageIds); const tabs = result.imageIds.map((imageId) => this._drawTab({key: imageId, imageId})); diff --git a/lib/static/components/state/state-error.jsx b/lib/static/components/state/state-error.jsx index 588df8de6..226541695 100644 --- a/lib/static/components/state/state-error.jsx +++ b/lib/static/components/state/state-error.jsx @@ -11,7 +11,7 @@ import ResizedScreenshot from './screenshot/resized'; import ErrorDetails from './error-details'; import Details from '../details'; import {ERROR_TITLE_TEXT_LENGTH} from '../../../constants/errors'; -import {isImageDiffError, isNoRefImageError} from '../../../common-utils'; +import {isAssertViewError, isImageDiffError, isNoRefImageError} from '../../../common-utils'; class StateError extends Component { static propTypes = { @@ -95,7 +95,7 @@ class StateError extends Component { } _shouldDrawErrorInfo(error) { - return !isImageDiffError(error); + return !isImageDiffError(error) && !isAssertViewError(error); } render() { diff --git a/lib/test-adapter/playwright.ts b/lib/test-adapter/playwright.ts index f5ba556e4..2f097f898 100644 --- a/lib/test-adapter/playwright.ts +++ b/lib/test-adapter/playwright.ts @@ -160,7 +160,7 @@ export class PlaywrightTestAdapter implements ReporterTestResult { result.stack = stack; } - if (message.includes('snapshot doesn\'t exist') && message.endsWith('.png.')) { + if (message.includes('snapshot doesn\'t exist') && message.includes('.png')) { result.name = ErrorName.NO_REF_IMAGE; } else if (message.includes('Screenshot comparison failed')) { result.name = ErrorName.IMAGE_DIFF; diff --git a/test/func/fixtures/hermione/failed-describe.hermione.js b/test/func/fixtures/hermione/failed-describe.hermione.js index 990ea07a8..b5c50c412 100644 --- a/test/func/fixtures/hermione/failed-describe.hermione.js +++ b/test/func/fixtures/hermione/failed-describe.hermione.js @@ -11,6 +11,12 @@ describe('failed describe', function() { await browser.assertView('header', 'header'); }); + it('test with diff', async ({browser}) => { + await browser.url(browser.options.baseUrl); + + await browser.assertView('header', 'header'); + }); + it('test with long error message', async () => { throw new Error(`long_error_message ${'0123456789'.repeat(20)}\n message content`); }); diff --git a/test/func/fixtures/hermione/screens/7357338/chrome/header.png b/test/func/fixtures/hermione/screens/7357338/chrome/header.png new file mode 100644 index 000000000..5bc4221ca Binary files /dev/null and b/test/func/fixtures/hermione/screens/7357338/chrome/header.png differ diff --git a/test/func/fixtures/playwright/tests/failed-describe.spec.ts-snapshots/header-chromium-darwin.png b/test/func/fixtures/playwright/tests/failed-describe.spec.ts-snapshots/header-chromium-darwin.png new file mode 100644 index 000000000..67940ac7d Binary files /dev/null and b/test/func/fixtures/playwright/tests/failed-describe.spec.ts-snapshots/header-chromium-darwin.png differ