Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6775301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:53:27+00:00 2026-05-26T15:53:27+00:00

I’m making a small test framework that uses the JavaScript module pattern for UI

  • 0

I’m making a small test framework that uses the JavaScript module pattern for UI Automation testing on iOS. However, I seem to be getting odd results based on #import and extending modules.

I have the base test module called Tester-Module.js:

(function() {
  var Tester = this.Tester = {};

  Tester.setUp = function() {
    UIALogger.logMessage('Regular SetUp()');
  }
}).call(this);

If I import this module in my test case, it works fine. Here’s the test file tester.js (tester.js is the file I import in Instruments):

#import "./Tester-Module.js"

// Prints 'Regular SetUp()'
Tester.setUp();

However, if I try to extend the Tester-Module.js module in another module file, I cannot reference the Tester object. Tester-Extension.js extends the Tester module defined in Tester-Module.js:

#import "./Tester-Module.js"

// Outputs:
// Exception raised while running script:
// ReferenceError: Can't find variable: Tester\n
Tester.setUp = function() {
  UIALogger.logMessage('Overwritten SetUp()');
}

And the updated test case file tester.js:

#import "./Tester-Extension.js"

// Exception is thrown before this
Tester.setUp();

My hopefully related questions are:

  • Why can I not reference the Tester object inside Tester-Extension.js, but can in tester.js?

  • What is the #import macro doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:53:27+00:00Added an answer on May 26, 2026 at 3:53 pm

    After some more searching and testing, it looks like using #import in each module file — similar to require in Node.js — is not supported with the UI Automation framework.

    The work around is to include a header file that imports every module and then just import that in the test case. Using the example above, the header file would look like:

    // Tester-Header.js
    #import "./Tester-Module.js"
    #import "./Tester-Extension.js"
    

    And the test file would simply import the header file like so:

    #import "./Tester-Header.js"
    
    // Prints "Overwritten SetUp()"
    Tester.setUp();
    

    The Mother May UI BDD framework has a more extensive example of a header file and importing the header file into a test file. Disclosure: I wrote the framework and originally asked this question in order to make the framework more modular.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.