teddyzeenny / ember-mocha-adapter

A mocha adapter for ember-testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

timeout of 2000ms exceeded

ninjatronic opened this issue · comments

Thanks for making this adapter. It's eased my transition away from the pain that is doing BDD with QUnit ;)

I'm having trouble with the Async tests and I'm not entirely sure why. This may not be a bug in the adapter, but hopefully you can shed some light on it for me. (Apologies in advance for potentially stupid question.)

I have the following tests:

describe 'application', ->

  beforeEach ->
    Ember.run ->
      App.reset()

  describe 'sign-up', ->

    beforeEach ->
      visit '/sign-up'

    it 'should be navigable', ->
      App.get 'currentPath'
        .should.equal 'sign-up'

    describe 'elements', ->

      it 'should have an input element \'.email\'', ->
        find 'input.email'
          .should.exist

      it 'should have an input element \'.password\'', ->
        find 'input.password'
          .should.exist

      it 'should have an button element \'.login-btn\'', ->
        find 'button.login-btn'
          .should.exist

    describe 'successful signup', ->

      beforeEach ->
        App.Store = DS.Store.extend
          adapter: DS.FixtureAdapter.extend {}

      it 'should redirect to \'apps.index\'', ->
        fillIn 'input.email', 'badger@me.com'
        fillIn 'input.password', 'giraffe'
        click 'button.login-btn'
          .then ->
            App.get 'currentPath'
              .should.equal 'apps.index'

All of which work fine except last one. The code is obviously getting into the final test as if I set that assertion up to fail then the test fails with that message, but as it is I get:

timeout of 2000ms exceeded

Is there something I need to do with the async here to prevent this?

Thanks

I don't think it's a bug in the adapter.

It seems that the wait helper (called inside the click helper) is taking more than 2000ms to resolve. One of these checks is hanging in your tests. This might indicate a that a transition is stuck in pending, an ajax request is being triggered and taking more than 2 seconds, you are calling Ember.run.later for more than 2 seconds or recursively...

On a side note:

   beforeEach ->
        App.Store = DS.Store.extend
          adapter: DS.FixtureAdapter.extend {}

This has no effect, especially that it's called after App.reset. You might want to put it in a before hook at the top before reset or before running any tests. Also look into using App.ApplicationAdapter which is better than redefining the store.

Hope this helps!

Thanks for the pointers. Managed to track down a timeout that was being set that was longer than the test timeout. Fixed :)