@@ -5,13 +5,13 @@ const container = require('./container');
55const event = require ( './event' ) ;
66const Step = require ( './step' ) ;
77const { truth } = require ( './assert/truth' ) ;
8- const { isAsyncFunction } = require ( './utils' ) ;
8+ const { isAsyncFunction, humanizeFunction } = require ( './utils' ) ;
99
1010function element ( purpose , locator , fn ) {
1111 if ( ! fn ) {
1212 fn = locator ;
1313 locator = purpose ;
14- purpose = `element ( ${ fn . toString ( ) } )` ;
14+ purpose = 'first element' ;
1515 }
1616
1717 const step = prepareStep ( purpose , locator , fn ) ;
@@ -29,7 +29,7 @@ function eachElement(purpose, locator, fn) {
2929 if ( ! fn ) {
3030 fn = locator ;
3131 locator = purpose ;
32- purpose = ` each element ( ${ fn . toString ( ) } )` ;
32+ purpose = 'for each element' ;
3333 }
3434
3535 const step = prepareStep ( purpose , locator , fn ) ;
@@ -58,7 +58,7 @@ function eachElement(purpose, locator, fn) {
5858}
5959
6060function expectElement ( locator , fn ) {
61- const step = prepareStep ( ` expect element to be ( ${ fn . toString ( ) } )` , locator , fn ) ;
61+ const step = prepareStep ( ' expect element to be' , locator , fn ) ;
6262 if ( ! step ) return ;
6363
6464 return executeStep ( step , async ( ) => {
@@ -72,7 +72,7 @@ function expectElement(locator, fn) {
7272}
7373
7474function expectAnyElement ( locator , fn ) {
75- const step = prepareStep ( ` expect any element to be ( ${ fn . toString ( ) } )` , locator , fn ) ;
75+ const step = prepareStep ( ' expect any element to be' , locator , fn ) ;
7676 if ( ! step ) return ;
7777
7878 return executeStep ( step , async ( ) => {
@@ -94,7 +94,7 @@ function expectAnyElement(locator, fn) {
9494}
9595
9696function expectAllElements ( locator , fn ) {
97- const step = prepareStep ( ` expect all elements to be ( ${ fn . toString ( ) } )` , locator , fn ) ;
97+ const step = prepareStep ( ' expect all elements' , locator , fn ) ;
9898 if ( ! step ) return ;
9999
100100 return executeStep ( step , async ( ) => {
@@ -105,7 +105,7 @@ function expectAllElements(locator, fn) {
105105 for ( const el of els ) {
106106 output . debug ( `checking element #${ i } : ${ el } ` ) ;
107107 const result = await fn ( el ) ;
108- const assertion = truth ( `element #${ i } of (${ locator } )` , fn . toString ( ) ) ;
108+ const assertion = truth ( `element #${ i } of (${ locator } )` , humanizeFunction ( fn ) ) ;
109109 assertion . assert ( result ) ;
110110 i ++ ;
111111 }
@@ -134,7 +134,11 @@ function prepareStep(purpose, locator, fn) {
134134 throw new Error ( 'Async function should be passed into each element' ) ;
135135 }
136136
137- const step = new Step ( helper , `${ purpose } within "${ locator } "` ) ;
137+ const isAssertion = purpose . startsWith ( 'expect' ) ;
138+
139+ const step = new Step ( helper , `${ purpose } within "${ locator } " ${ isAssertion ? 'to be' : 'to' } ` ) ;
140+ step . setActor ( 'EL' ) ;
141+ step . setArguments ( [ humanizeFunction ( fn ) ] ) ;
138142 step . helperMethod = '_locate' ;
139143
140144 return step ;
0 commit comments