Skip to content

JavaScript extension: argument-name parsing and untested paths #5355

Open

Description

@aaltat

Describe the problem
Two gaps in JavaScript extensions (jsextension and initialize_js_extension), found while working on #5352 and #5354.

1. Argument names are probably parsed wrongly for some function shapes. Node takes the text between the first ( and the next ) of fn.toString() with /\((.*?)\)/ (extractArgumentsStringFromJavascript in node/playwright-wrapper/playwright-state.ts), and Python splits it on , and = (Browser._jskeyword_call). Likely wrong:

  • a single parameter without parentheses: exports.f = x => ...
  • a default that contains , or ): function f(a = [1, 2]), function f(a = g())
  • destructuring: function f({ selector, timeout })
  • a default that is a bare identifier: function f(t = DEFAULT) raises NameError when the keyword is generated, instead of DataError

None of these has a test. The fix might be to report unsupported shapes clearly rather than to parse them.

2. Paths without a unit test. They work today and some are exercised by acceptance tests, but nothing at the unit level stops them from changing silently:

  • logger messages reaching the Robot Framework log (response.log -> logger.info)
  • fn.rfdoc becoming the keyword documentation, and the "TODO: Add rfdoc string" text used without one
  • the generated keyword's @keyword name
  • Could not find keyword <name> for an unknown function name
  • initializeExtension in Node: no Jest test

3. LibraryComponent.call_js_keyword clashes on an argument named keyword_name. #5354 made keyword_name positional-only in Browser.call_js_keyword, but the plugin wrapper in Browser/base/librarycomponent.py still has it as an ordinary parameter. A plugin calling self.call_js_keyword("lookUp", keyword_name="Click") for function lookUp(keyword_name) gets TypeError: call_js_keyword() got multiple values for argument 'keyword_name'. Make it positional-only too.

Where tests go
Python: utest/test_js_extension_call.py has a recording gRPC stub for the generated keyword and call_js_keyword. Node: node/playwright-wrapper/__tests__/playwright-state.test.ts already tests extensionKeywordCall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions