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:
all-tests.js:
#import "tab-dates.js"
#import "tab-temperatures.js"
tab-dates.js:
#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");
});
Both of these live in the same directory, and are imported into an automation trace file that also lives in the same directory.
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:
Script threw an uncaught JavaScript error: Can't find variable: test on line 8 of tab-dates.js
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'.
As far as I can tell, chaining imports is supposed to work -- I mean, this is the entirety of tuneup.js (https://github.com/alexvollmer/tuneup_js):
#import "assertions.js"
#import "lang-ext.js"
#import "uiautomation-ext.js"
#import "screen.js"
#import "test.js"
#import "image_assertion.js"
So I have the weird situation that
- tab-dates.js imports tuneup.js imports test.js => OK
- all-tests.js imports tab-dates.js imports tuneup.js imports test.js => NOT OK
What's going on?