Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Template expressions escape hatch #93

Open
lawik opened this issue Jun 15, 2021 · 2 comments
Open

Suggestion: Template expressions escape hatch #93

lawik opened this issue Jun 15, 2021 · 2 comments

Comments

@lawik
Copy link
Contributor

lawik commented Jun 15, 2021

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.

@dsheiko
Copy link
Owner

dsheiko commented Aug 13, 2021

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 #95 ?

@lawik
Copy link
Contributor Author

lawik commented Aug 13, 2021

Looks great and should take care of noth, yeah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants