Skip to content

eval with arrow function produces "TypeError: result is not a function" #296

@linkej-autodesk

Description

@linkej-autodesk

Repro:

playwright-cli eval "[1,2,3].map(x => x*2)"

### Error
Error: page._evaluateFunction: TypeError: result is not a function
    at UtilityScript.evaluate (<anonymous>:303:16)
    at UtilityScript.<anonymous> (<anonymous>:1:44)

Workaround: run-code "async page => await page.evaluate(() => {...})"

We need to use eval/page.evaluate a lot since we're mostly interaction with an API and not the DOM. I observed agents often trying eval, which didn't work for multiple expressions. I thought maybe that's just a limitation of the eval, and instructed the agent to use eval only for single expressions, which it did, but failed again as described above. At that point I thought it's kinda unreasonably limited :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions