Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Called start() outside of a test context #143

Closed
green-arrow opened this issue Feb 19, 2015 · 11 comments
Closed

Called start() outside of a test context #143

green-arrow opened this issue Feb 19, 2015 · 11 comments

Comments

@green-arrow
Copy link

Not sure if this belongs here or somewhere else, but I'm running into this error while using ember-qunit 0.2.8. When running tests in ember-cli, I'm getting a JSHint global error:

JSHint - views: global failure
Uncaught Error: Called start() outside of a test context while already started
Source: http://localhost:4200/assets/test-support.js:2559

Any suggestions for troubleshooting this?

@ghost
Copy link

ghost commented Mar 17, 2015

Having the same problem after I upgraded to ember-cli 0.2.0 and ember 1.10.

@achan
Copy link

achan commented Mar 26, 2015

This happened to me upgrading ember-cli from 0.1.12 to 0.2.0. Same results with 0.2.1.

My tests will intermittently fail. Either they fail because my requests haven't resolved yet and the callback in andThen is never called, or they fail with this issue and my requests end up resolving and andThen callbacks are fired.

Here are a few other discussions about this issue:
http://discuss.emberjs.com/t/weird-behaviour-in-test-runner-after-update-to-1-10-0-1-15-combo/7318
http://discuss.emberjs.com/t/test-failures-after-upgrading-from-0-1-12-to-0-2-0/7523

Any suggestions?

@achan
Copy link

achan commented Mar 28, 2015

More followup: I've moved all existing tests out of my project except for a single acceptance test and am still (intermittently) getting the same error.

@cellis
Copy link

cellis commented Aug 5, 2015

Just want to post this, in case anyone else has this problem.

If you are using CoffeeScript, you must return null from beforeEach and afterEach, or the tests will hang. Perhaps before/afterEach can return promises that qunit expects to resolve before continuing? Whatever the case, just make sure you add null at the end so the last statement isn't returned, like so:

# tests/unit/index-test.coffee
`
import Ember from 'ember'
import { module, test } from 'qunit'
import startApp from '../helpers/start-app'
`
App = null
module 'index',
  beforeEach: ->
    App = startApp()
    null

  afterEach: ->
    Ember.run(App, App.destroy)
    null

test "true is true", (assert)->
  assert.expect(1)
  visit('/')
  andThen ->
    assert.equal(true, true, "true is true")

Without returning null, you will get an error like:

✘ Promise rejected during true is true: Called start() outside of a test context while already started

Error: assertion outside test context, in     at http://localhost:7357/assets/test-support.js:3708
    at http://localhost:7357/assets/test-support.js:3733
    at http://localhost:7357/assets/test-support.js:4370

while running your tests.

@rwjblue
Copy link
Member

rwjblue commented Aug 5, 2015

Perhaps before/afterEach can return promises that qunit expects to resolve before continuing

Yep, exactly.

@workmanw
Copy link

We too have this issue. I'm not sure if we have a lingering timer, or are doing some wrong, or what. But I've not had any luck tracing this down. Any suggestions?

@taras
Copy link

taras commented Sep 15, 2016

I just started coming across this as well.

@dknutsen
Copy link

dknutsen commented Sep 23, 2016

If it helps anyone, we just started having this issue and in our case it was caused by ember-cli-blanket which is currently broken with qunit >= 2.2.2. See the blanket issue for details.

This issue was also hiding/breaking the "Module" dropdown on the localhost:4200/tests page, which was weird.

The temporary solution, as an alternative to removing blanket entirely, is to change autostart to false in the blanket options.

@workmanw
Copy link

workmanw commented Dec 1, 2016

@dknutsen Man, thank you for that. You just saved me hours of digging.

@dknutsen
Copy link

dknutsen commented Dec 1, 2016

@workmanw yeah it took me a long time to narrow it down, glad I could spare someone else that pain

@Turbo87
Copy link
Member

Turbo87 commented Oct 14, 2017

closing due to inactivity

@Turbo87 Turbo87 closed this as completed Oct 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants