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 8474377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:36:37+00:00 2026-06-10T17:36:37+00:00

I am unable to get jasmine to load my custom javascript file, even though

  • 0

I am unable to get jasmine to load my custom javascript file, even though it works perfectly in the browser. I’ve reduced the javascript to the minimum to avoid any possibility of errors and I still get a failing test on the simplest thing.

Custom ARB.js file:

$(document).ready(function() {
  alert('typeof ARB: ' + typeof ARB);
    });
ARB = {};
ARB.VERSION = "V1.01.00 2012-08-24";

jasmine configuration file snippet (I’m on Rails 3.0.9):

src_files:
  - "public/javascripts/**/*.js"
  - "public/javascripts/ARB.js"

This test:

  it('should define the custom javascript functions', function() {
    expect(typeof ARB).toEqual('object');
    });

fails with:

Expected 'undefined' to equal 'object'.

jQuery gets loaded and so does my application.js file. When running jasmine, I get no alert message, but I do when I run my app.

What am I missing?

UPDATE: If I remove the $(document).ready function, jasmine passes all the tests – what’s that all about?

  • 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-06-10T17:36:38+00:00Added an answer on June 10, 2026 at 5:36 pm

    shioyama gave me the pointer that I needed to figure this out: my custom ARB.js file was getting loaded before the jquery files so it didn’t have access to the $(document).ready function. What I had to do was explicitly spell out the order in which my javascript files were to be loaded. Here’s what I put in my jasmine config file at /spec/javascripts/support/jasmine.yml:

    src_files:
      - "public/javascripts/**/jquery.js"
      - "public/javascripts/**/jq*.js"
      - "public/javascripts/**/application.js"
      - "app/assets/javascripts/**/*.js"
      - "public/javascripts/ARB.js"
    

    I first force the main jquery.js file to load, then all the other jquery files, then application.js, then any other javascript files that are located in the assets directory, and finally my custom javascript file.

    This works for me because I’m still on Rails 3.0.9 and starting the migration to 3.1+ and the asset pipeline.

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

Sidebar

Related Questions

I get unable to open database file when executing rc = sqlite3_open(test.db, &db); ??
I'm unable to get this jquery statement to work on page load but it
I am unable to get a Javascript callback to work with gmaps4_rails when the
I renamed the class classBattle to Game and not I get Unable to load
I'm unable to get a working .htaccess that should accept clean URLs to load
I'm unable to get the height of a page in javascript when the page
I'm unable to get trace log file for WCF service on server. The file
I am completely unable to get a WMF file onto a PDF using iTextSharp.
I'm unable to get unobtrusive validation to work using custom viewModels representing abstractions of
I am unable to get the correct title for this, please change the title

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.