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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:14:54+00:00 2026-06-09T07:14:54+00:00

I am having a timing issue with my tests. I am using the event

  • 0

I am having a timing issue with my tests. I am using the event aggregator to raise events and the problem is that my specs are completing before the code gets to an event that is raised. I need the specs to run after the evented code has ran.

For example, I am creating a layout and then raising an event:

  DocumentManager.addInitializer(function(){
    DocumentManager.layout = new Layout();

    DocumentManager.layout.on("show", function(){
      DocumentManager.vent.trigger("layout:rendered");
    });

    DocumentManager.content.show(DocumentManager.layout)
  }); 

I then create another view after the layout has been created:

  DocumentManager.vent.on("layout:rendered", function(){
    Documents.folders = new Documents.Folders();

    Documents.folders.reset(window._rootFolder);    

    Documents.treeRoot = new Documents.TreeRoot({
      collection: Documents.folders
    });

    DocumentManager.layout.treeView.show(Documents.treeRoot);

    DocumentManager.vent.trigger("folder:added");
  });

The problem is that my specs finish before this code is ran:

describe 'battlebox', ->
  describe 'versioned documents', ->
    describe 'empty root and no files', ->
      beforeEach ->
        loadFixtures "battlebox.html"
        DocumentManager.start()
        window._rootFolder = Test.Factory.BattleBox.emptyRoot()

      it "should create a root folder", ->
        expect(DocumentManager.Documents.folders.length).toEqual 1

My options are to either trigger the event from the test or refactor the code out of the “layout:rendered” event handler into a method which I “setup” and call from my test.

I am curious if anyone has a better idea?

  • 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-09T07:14:58+00:00Added an answer on June 9, 2026 at 7:14 am

    If the it is running before the beforeEach has finished, then there is some code in your setup that is running asynchronously. You’ll have to use Jasmine’s async capabilities to make this work. https://github.com/pivotal/jasmine/wiki/Asynchronous-specs

    Also – you might want to split your test up in to smaller pieces. Since you have an event that is triggered to facilitate the rendering of the Folders, split the test here. Have one test show that the initializer is setting up the layout correctly. Then have another test that shows the Folders are rendering correctly. You can make the second test work by directly triggering the “layout:rendered” event in your test.

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

Sidebar

Related Questions

I'm having a problem closing my database before an attempt to delete the file.
My issue is that I am using a metaclass to wrap certain class methods
The problem im having is that I have a table that when a user
Having trouble with each function... Will try to explain by example... In my code,
Having issue with slider navigation. Works perfectly fine when there are no other unordered
Having trouble accessing javascript code in a mixed html/js ajax response. jQuery ajax doc
I am very new to javascript and I am having issues with timing out
ok it seems like a simple problem, but i am having problem I have
I've come across a fairly obscure problem having to do with measuring a document's
I've seen this problem many places, that is to say the problem with programmatically

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.