<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paradiesvogel7 on Medium]]></title>
        <description><![CDATA[Stories by Paradiesvogel7 on Medium]]></description>
        <link>https://medium.com/@paradiesvogel7?source=rss-20d815c2af65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xkVS3rb30WmGNZnlJcUnDQ.png</url>
            <title>Stories by Paradiesvogel7 on Medium</title>
            <link>https://medium.com/@paradiesvogel7?source=rss-20d815c2af65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:36:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paradiesvogel7/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[End-to-End Testing in React Native with Maestro: Handling Test Data]]></title>
            <link>https://medium.com/@paradiesvogel7/end-to-end-testing-in-react-native-with-maestro-handling-test-data-1a382b34bfc6?source=rss-20d815c2af65------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a382b34bfc6</guid>
            <category><![CDATA[mobile-testing]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[test-data]]></category>
            <dc:creator><![CDATA[Paradiesvogel7]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 09:53:58 GMT</pubDate>
            <atom:updated>2025-09-05T15:33:06.528Z</atom:updated>
            <content:encoded><![CDATA[<p>End-to-End testing is essential for mobile apps to reliably validate real user flows. Maestro stands out with lightweight YAML files, quick setup, and minimal configuration overhead.</p><p>But one tricky part quickly surfaced: <strong>handling test data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qbvrUSoO-kqyI9G3pntBg.png" /></figure><h3>The Test Data Problem</h3><p>Many flows require dynamic data like a new user with a unique email, a login token, or structured fixtures.</p><p>Maestro comes with built-in commands like inputRandomPersonName, inputRandomNumber, inputRandomText and inputRandomEmail. These are great for simple cases such as generating a random name or email.</p><p>However, as soon as you need more specific data for example a TOTP code, structured objects, or API-driven data the built-ins reach their limits. That’s where the runScript step becomes essential.</p><h3>The Limitation of Rhino &amp; switching to GraalJS</h3><p>By default, Maestro v1 used the <strong>Rhino JS engine </strong>for runScript<strong>. </strong>This works for simple scripts but is restrictive for anything requiring modern JavaScript features or libraries. For example, Rhino does not support:</p><ul><li>Import statements</li><li>Npm packages</li><li>Modern ES Syntax</li></ul><blockquote>Note: Since <strong>Maestro v2</strong>, GraalJS is the <strong>default engine</strong>, so no additional configuration is needed if you use one of the newer versions.</blockquote><p>The good news: You can configure Maestro to use the <strong>GraalJS </strong>engine instead. With GraalJS, you get access to modern syntax and can even use bundled npm libraries. Set the following environment variable when running your tests to enable GraalJS:</p><pre>MAESTRO_USE_GRAALJS=true</pre><h3>How to solve the Problem</h3><p>To get a solution for this I had to think about it for a while and came across two possible solutions to fix this issue.</p><h3>1. Bundled Scripts</h3><p>My first approach was writing standalone JS files and <strong>bundle/compile</strong> them so Maestro can execute them with GraalJS.</p><p><strong>Example to generate a TOTP Code:</strong></p><p>First write your JS Code with the functionallity you need and set the return value to the global output variable from maestro.</p><pre>// generateTotp.js<br>const OTPAuth = require(&#39;otpauth&#39;);<br><br>const defaultOptions = {<br>  algorithm: &#39;SHA1&#39;,<br>  digits: 6,<br>  period: 30<br>};<br><br>function generateTotp() {<br>  const secret = MAESTRO_TOTP_SECRET;<br>  if (!secret) throw new Error(&#39;OTP secret is required.&#39;);<br><br>  const totp = new OTPAuth.TOTP({<br>    ...defaultOptions,<br>    secret: OTPAuth.Secret.fromBase32(secret)<br>  });<br><br>  return totp.generate();<br>}<br><br>output.totp = generateTotp();</pre><p>Create a webpack config to transform the script:</p><pre>// webpack.config.js<br>const path = require(&#39;path&#39;);<br><br>module.exports = {<br>  entry: &#39;./generateTotp.js&#39;,<br>  output: {<br>    path: path.resolve(__dirname, &#39;lib&#39;),<br>    filename: &#39;generateTotp.js&#39;<br>  },<br>  module: {<br>    rules: [<br>      {<br>        test: /\.js$/,<br>        use: &#39;babel-loader&#39;<br>      }<br>    ]<br>  },<br>  mode: &#39;production&#39;<br>};</pre><p>And execute it:</p><pre>webpack --config webpack.config.js</pre><p>Then call it inside a Maestro flow:</p><pre>appId: com.example.app<br>---<br>- tapOn: &quot;Code&quot;<br>- runScript: ./lib/generateTotp.js<br>- inputText: ${output.totp}<br>- tapOn: &quot;Verify&quot;</pre><p>This allows you to get a single file with all the stuff you need inside to use it during the e2e test. To get this bundled/compiled file you just need to run webpack before starting maestro.</p><h3>2. HTTP Requests</h3><p>Another option is to perform <strong>HTTP requests. </strong>Maestro provides a built-in API for this (<a href="https://docs.maestro.dev/advanced/javascript/make-http-s-requests">see docs</a>).</p><p>This allows you to fetch dynamic data from external APIs right inside a runScript block.</p><p><strong>Example to fetch localized Test Data:</strong></p><pre>// fetchCity.js<br>const response = http.get(&quot;https://my-api.com/random-city?locale=en&quot;);<br>output.city = response.body.city;</pre><p>Call it the same way inside your maestro flow:</p><pre>appId: com.example.app<br>---<br>- tapOn: &quot;City&quot;<br>- runScript: fetchCity.js<br>- inputText: ${output.city}<br>- tapOn: &quot;Continue&quot;</pre><p>With this you can consume external or dynamic data directly within the running maestro test.</p><h3>Conclusion</h3><p>Maestro brings a lot of joy to E2E testing for React Native apps. But you need a clear test data strategy from the start. For me, the two most reliable approaches are:</p><ol><li><strong>GraalJS with bundled scripts (Webpack): </strong>When you need advanced logic and npm libraries.</li><li><strong>HTTP requests inside scripts:</strong> When your tests rely on external or dynamically generated data.</li></ol><p>My recommendation: Use the built-in random commands for simple scenarios and fall back on bundled scripts or HTTP requests for more complex cases like TOTP codes or API-backed data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a382b34bfc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>