LogoLogo
🚀 Run Maestro tests in the cloud →
  • Home
  • Star us on GitHub
  • Getting Started
    • What is Maestro?
    • Installing Maestro
      • macOS
      • Windows
      • Linux
    • Build and Install your App
      • Android
      • iOS
    • Run a Sample Flow
    • Writing Your First Flow
    • Maestro Studio
    • Running Flows on CI
  • Cloud
    • Run Maestro tests in the cloud
    • Cloud Quickstart
    • CI Integration
      • GitHub Actions
        • Maestro GitHub Action for Android
        • Maestro GitHub Action for iOS
        • Maestro GitHub Action for Flutter
      • Bitrise
      • Bitbucket Pipelines
      • CircleCI
      • Integration with any CI platform
    • Pull Request Integration
    • Cloud Reference
      • Build your app for the cloud
      • Configuring OS Version
      • Configuring device locale
      • Device timezones
      • Email Notifications
      • Slack Notifications
      • Webhook Integration
      • Managing Secrets
      • Limits
      • Reusing App Binary
      • IP Allowlist
      • System Status
  • Platform Support
    • Supported Platforms
    • Android - Views
    • Android - Jetpack Compose
    • iOS - UIKit
    • iOS - SwiftUI
    • React Native
    • Flutter
    • Web Views
    • Web (Desktop Browser)
  • Examples
    • Android contacts flow automation
    • Facebook signup flow automation
    • Advanced: Wikipedia Android
    • Page Object Model
  • CLI
    • Cloud
    • Test Suites & Reports
    • Tags
    • Record Your Flow
    • Continuous Mode
    • View Hierarchy
    • Start Device
  • API Reference
    • Commands
      • addMedia
      • assertVisible
      • assertNotVisible
      • assertTrue
      • assertWithAI
      • assertNoDefectsWithAi
      • back
      • clearKeychain
      • clearState
      • copyTextFrom
      • evalScript
      • eraseText
      • extendedWaitUntil
      • extractTextWithAI
      • hideKeyboard
      • inputText
      • killApp
      • launchApp
      • openLink
      • pressKey
      • pasteText
      • repeat
      • retry
      • runFlow
      • runScript
      • scroll
      • scrollUntilVisible
      • setAirplaneMode
      • setLocation
      • startRecording
      • stopApp
      • stopRecording
      • swipe
      • takeScreenshot
      • toggleAirplaneMode
      • tapOn
      • doubleTapOn
      • longPressOn
      • travel
      • waitForAnimationToEnd
    • Common command arguments
    • Selectors
    • Configuration
      • Workspace configuration
      • Flow configuration
      • AI configuration
  • Advanced
    • Nested Flows
    • Wait
    • Loops
    • Conditions
    • Parameters & Constants
    • JavaScript
      • Run JavaScript
      • Outputs
      • Logging
      • Access element text
      • Make HTTP requests
      • GraalJS support
      • JavaScript announcement blog
    • Specify a Device
    • Configure Permissions
    • Detect Maestro in your app
    • Configure Maestro driver timeout
    • onFlowStart / onFlowComplete hooks
    • Test in different locales
    • Structuring your test suite
  • Troubleshooting
    • Known Issues
    • Frequently Asked Questions
    • Bug Report
    • Rollback Maestro
    • Debug Output
    • HOWTOs
      • Arrange your repository for Maestro tests
      • scrollUntilVisible for fragments
  • Community
    • Contributions
    • Articles & Tutorials
    • Case Studies
    • Resources
Powered by GitBook

Read to wire into CI or scale up your testing?

  • Run Maestro tests in the cloud →
On this page

Was this helpful?

Edit on GitHub
  1. Advanced
  2. JavaScript

GraalJS support

PreviousMake HTTP requestsNextSpecify a Device

Last updated 3 months ago

Was this helpful?

It is possible to use the runtime instead of for JavaScript evaluation. GraalJS is fully ECMAScript 2022 compliant while Rhino only supports ECMAScript 5.

Right now, Rhino is the default JavaScript engine, but we intend to make GraalJS the default soon and then deprecate and remove Rhino.

.

Enable GraalJS via flow config

This only has an effect if present in the top-level flow. It is ignored when included in any subflows.

appId: com.example.app
jsEngine: graaljs
---
# The ?? operator is an example of an ES2020 feature and is not supported by Rhino
- inputText: ${null ?? 'foo'}

Enable GraalJS via environment variable

When , use the flow config above. The env var below is not supported in the cloud.

export MAESTRO_USE_GRAALJS=true
maestro test my-flow.yaml

GraalJS behavior differences

There are some differences between the new GraalJsEngine and the current RhinoJsEngine implementation that are worth noting. All of the differences below and some others are documented and tested by the GraalJsEngineTest and RhinoJsEngineTest tests.

TL;DR is that the variable scoping when using GraalJS is more consistent and understandable.

Rhino JS
GraalJS
  • Can not reuse variable names across scripts within the same Flow

  • Can reuse variable names if redeclaration lives in a subflow

  • Can access variables declared earlier in the Flow in a separate script

  • output variable is shared across all scripts

  • Variables are local to each script

  • output variable is shared across all scripts

Some examples

Case
Code sample
Rhino JS
GraalJS

Redeclaring variables across scripts

❌ Variable redeclarations throw an error

✅ Variable names can be reused across scripts

Accessing variables across scripts

✅ Variables are accessible across scripts

❌ Variables can't be accessed across scripts

Handling special characters

❌ Single backslash causes an exception

✅ Single backslash and all other special chars are handled correctly

appId: com.example.example
---
- evalScript: ${const foo = null}
- evalScript: ${const foo = null}
appId: com.example.example
---
- evalScript: ${const name = 'joe'}
- evalScript: ${name === 'joe'}
appId: com.example.app
env:
  FOO: \
---
- tapOn: Username
- inputText: ${FOO}
GraalJS
Rhino
This issue track the progress
running in the cloud