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

Click helper makes all my tests failing #14730

Closed
sarjanen opened this issue Dec 17, 2016 · 2 comments
Closed

Click helper makes all my tests failing #14730

sarjanen opened this issue Dec 17, 2016 · 2 comments

Comments

@sarjanen
Copy link

After upgrading from Ember 2.8 -> 2.9, CLI 2.8 -> 2.9 and ember-cli-qunit 2.1 -> 3.0.4 all my acceptence tests thats use the click helper with .then() is throwing some weird error. If i skip the .then() everything works like expected.

import { test } from 'qunit';
import moduleForAcceptance from 'app/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | posts');

test('visiting /logga-in', function(assert) {
  visit('/posts');

  click('.btn'').then(function() {
    assert.ok(true, 'This works');
  });
});
Assertion after the final `assert.async` was resolved@ 310 ms
Source: 	
    at Assert.ok (http://localhost:7357/assets/test-support.js:4186:10)
    at http://localhost:7357/assets/tests.js:379:14
    at isolate (http://localhost:7357/assets/vendor.js:53599:17)
    at http://localhost:7357/assets/vendor.js:53555:16
    at tryCatch (http://localhost:7357/assets/vendor.js:73026:12)
    at invokeCallback (http://localhost:7357/assets/vendor.js:73038:13)
    at publish (http://localhost:7357/assets/vendor.js:73009:7)
    at http://localhost:7357/assets/vendor.js:52488:16
This works
@pittst3r
Copy link
Contributor

pittst3r commented Dec 17, 2016

You might refactor to:

test('visiting /logga-in', function(assert) {
  visit('/posts');

  click('.btn'');
  andThen(function() {
    assert.ok(true, 'This works');
  });
});

If not you need to tell QUnit to wait for your promise to resolve before finishing the test:

test('visiting /logga-in', function(assert) {
  let done = assert.async();

  visit('/posts');

  click('.btn'').then(function() {
    assert.ok(true, 'This works');
    done();
  });
});

@sarjanen
Copy link
Author

Ah thanks! Maybe the docs should be updated to explain that you need to do this id you use the click promise.

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

2 participants