import { Test } from './testTypes' ; import { Step } from '../Step' ; import { StructuredError } from '../../utils/StructuredError' ; import { NoOpTestObserver } from './TestObserver' ; import { structuredErrorToDocumentedError } from '../errors/Documentation' ; import { AnyErrorData } from '../errors/Types' ; export default class ErrorObserver extends NoOpTestObserver { async onStepError ( test , step , err ) { test . reporter . testStepError ( structuredErrorToDocumentedError ( err , test . script ) ! ) ; if ( test . settings . screenshotOnFailure ) { await test . runningBrowser ?. takeScreenshot ( ) ; } return this . next . onStepError ( test , step , err ) ; } }