Note that there are some explanatory texts on larger screens.

plurals
  1. POChaining #imports in UIAutomation javascript
    text
    copied!<p>I'm trying to break up my UIAutomation test scripts into chunks, to make it possible to run them one piece at a time or all together. So I have a structure:</p> <p>all-tests.js:</p> <pre><code>#import "tab-dates.js" #import "tab-temperatures.js" </code></pre> <p>tab-dates.js:</p> <pre><code>#import "../../../Libraries/tuneup_js/tuneup.js" #import "dpl_assertions.js" var target = UIATarget.localTarget(); var app = target.frontMostApp(); test("Verify date view is shown", function() { assertEquals(tabBar.selectedButton().name(), "Date"); }); </code></pre> <p>Both of these live in the same directory, and are imported into an automation trace file that also lives in the same directory.</p> <p>When I run tab-dates.js directly, everything is fine. tuneup.js is found, path is correct, test passes. But when I try to run all-tests.js, I get:</p> <blockquote> <p>Script threw an uncaught JavaScript error: Can't find variable: test on line 8 of tab-dates.js</p> </blockquote> <p>It's not a straight path problem, because if I edit the script to break the path I get a different error that explicitly says 'file not found'.</p> <p>As far as I can tell, chaining imports is <strong>supposed</strong> to work -- I mean, this is the entirety of tuneup.js (<a href="https://github.com/alexvollmer/tuneup_js" rel="nofollow">https://github.com/alexvollmer/tuneup_js</a>):</p> <pre><code>#import "assertions.js" #import "lang-ext.js" #import "uiautomation-ext.js" #import "screen.js" #import "test.js" #import "image_assertion.js" </code></pre> <p>So I have the weird situation that </p> <ul> <li>tab-dates.js imports tuneup.js imports test.js => OK</li> <li>all-tests.js imports tab-dates.js imports tuneup.js imports test.js => NOT OK</li> </ul> <p>What's going on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload