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

How did you handle "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions."? #9

Open
iamdtang opened this issue Nov 20, 2017 · 3 comments

Comments

@iamdtang
Copy link

Hey Alex,

Have you used Test Double's verifying invocation feature in your Ember tests? Since td.verify() is meant to be an assertion, you end up getting an error like "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions." if you don't call a method off of the provided assert. Just curious if you found any clever ways around this. 🙂

@iamdtang
Copy link
Author

iamdtang commented Nov 21, 2017

I ended up doing something like this in my own project. What do you think about adding it to this? I'd be happy to send a PR.

import td from 'testdouble';
import QUnit from 'qunit';

export default td;

export function verify(...args) {
  td.verify.apply(this, args);
  QUnit.assert.ok(true);
};

@alexblom
Copy link
Member

alexblom commented Mar 6, 2018

Hi @skaterdav85 this looks reasonable to me, but perhaps somebody else can chime in. Most of my usage for td has been in ember-cordova/corber where we're not using QUnit.

@alexlafroscia
Copy link
Contributor

alexlafroscia commented Apr 5, 2018

I build ember-cli-testdouble-qunit for this purpose. It sets up an assert.verify function that you can use

test('called a function', function(assert) {
  const stub = td.function();
  stub('foo');

  assert.verify(stub('foo'));
});

You can check it out here: https://github.com/alexlafroscia/testdouble-qunit/tree/master/packages/ember-cli-testdouble-qunit

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

3 participants