puppetry icon indicating copy to clipboard operation
puppetry copied to clipboard

Suggestion: Template expressions escape hatch

Open lawik opened this issue 3 years ago • 2 comments

Puppetry is an impressive app and it lets our test automating person do things she doesn't know enough programming to do. But sometimes we need to reach outside of the tools into using JS for things. I think template expressions could offer more here to avoid having to go deep into the JS methods and dynamic template variables.

There would be some benefit to having eval and evalAwait or something like that to allow going beyond the built-in utilities without necessarily needing to go very deep. For example, I needed to generate an iso8601 timestamp, strip a few characters. That's doable in a line of JS.

lawik avatar Jun 15 '21 06:06 lawik

Please check the last commit at https://github.com/dsheiko/puppetry/tree/dev

The syntax like exp-eval resolves into

await bs.page.goto( `${ os.version() }`, {"timeout":30000,"waitUntil":"load"} );

if you need quotation marks in it just escape them.

I believe something like ( await apiFunc() ) will serve.

Within the test body now exposed:

      fs = require( "fs" ),
      path = require( "path" ),
      os = require( "os" )

Does it satisfy the https://github.com/dsheiko/puppetry/issues/95 ?

dsheiko avatar Aug 13 '21 09:08 dsheiko

Looks great and should take care of noth, yeah!

lawik avatar Aug 13 '21 11:08 lawik