@@ -3,6 +3,7 @@ import {LogEventStatus, LogEventType, RETRY_KEY} from '../../constants/internal'
33import { assertValueIsDefined } from '../asserts' ;
44import { getFullPackConfig } from '../config' ;
55import { E2edError } from '../error' ;
6+ import { generalLog } from '../generalLog' ;
67import { getDurationWithUnits } from '../getDurationWithUnits' ;
78import { logAndGetLogEvent } from '../log' ;
89import { setReadonlyProperty } from '../object' ;
@@ -33,18 +34,19 @@ export const createExpectMethod = (
3334 const { assertionTimeout} = getFullPackConfig ( ) ;
3435
3536 const timeout = assertionTimeout + additionalAssertionTimeoutInMs ;
36- const message = getAssertionMessage === undefined ? key : getAssertionMessage ( ...args ) ;
37+ const assertionMessage = getAssertionMessage === undefined ? key : getAssertionMessage ( ...args ) ;
38+ const message = `Assert: ${ this . description } ` ;
3739
3840 const selectorPropertyRetryData = (
3941 this . actualValue as { [ RETRY_KEY ] ?: SelectorPropertyRetryData }
4042 ) ?. [ RETRY_KEY ] ;
4143
4244 const printedValue = isThenable ( this . actualValue ) ? '<Thenable>' : this . actualValue ;
4345 const logEvent = logAndGetLogEvent (
44- `Assert: ${ this . description } ` ,
46+ message ,
4547 {
4648 actualValue : printedValue ,
47- assertion : wrapStringForLogs ( `value ${ valueToString ( printedValue ) } ${ message } ` ) ,
49+ assertion : wrapStringForLogs ( `value ${ valueToString ( printedValue ) } ${ assertionMessage } ` ) ,
4850 assertionArguments : args ,
4951 selector :
5052 selectorPropertyRetryData ?. selector . description ??
@@ -79,29 +81,36 @@ export const createExpectMethod = (
7981 } ) ;
8082
8183 return assertionPromise . then ( ( { actualValue, additionalLogFields, error} ) => {
82- Object . assign ( payload , {
84+ const additionalPayload = {
8385 ...additionalLogFields ,
8486 error : error ?. message === undefined ? undefined : removeStyleFromString ( error . message ) ,
8587 logEventStatus : error ? LogEventStatus . Failed : LogEventStatus . Passed ,
86- } ) ;
88+ } ;
89+
90+ Object . assign ( payload , additionalPayload ) ;
8791
8892 return addTimeoutToPromise ( Promise . resolve ( actualValue ) , timeout , timeoutError )
8993 . then (
9094 ( value ) => {
91- Object . assign ( payload , {
92- actualValue : value ,
93- assertion : wrapStringForLogs ( `value ${ valueToString ( value ) } ${ message } ` ) ,
94- } ) ;
95+ Object . assign (
96+ payload ,
97+ Object . assign ( additionalPayload , {
98+ actualValue : value ,
99+ assertion : wrapStringForLogs ( `value ${ valueToString ( value ) } ${ assertionMessage } ` ) ,
100+ } ) ,
101+ ) ;
95102
96103 setReadonlyProperty ( logEvent , 'endTime' , Date . now ( ) as UtcTimeInMs ) ;
97104 } ,
98105 ( actualValueResolveError : Error ) => {
99- Object . assign ( payload , { actualValueResolveError} ) ;
106+ Object . assign ( payload , Object . assign ( additionalPayload , { actualValueResolveError} ) ) ;
100107
101108 setReadonlyProperty ( logEvent , 'endTime' , Date . now ( ) as UtcTimeInMs ) ;
102109 } ,
103110 )
104111 . then ( ( ) => {
112+ generalLog ( `Assert "${ this . description } " completed` , additionalPayload ) ;
113+
105114 if ( error ) {
106115 throw error ;
107116 }
0 commit comments