Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Using with QUnit? #3

Closed
lolmaus opened this issue Apr 18, 2015 · 6 comments
Closed

Using with QUnit? #3

lolmaus opened this issue Apr 18, 2015 · 6 comments

Comments

@lolmaus
Copy link

lolmaus commented Apr 18, 2015

Is it possible to use ember-cli-chai with QUnit?

If yes, it is confusing how it is supposed to be used. QUnit provides its own assert function. Should i not use the QUnit's one? Should i use both? Does Chai's assert provide QUnit's features like assert.expect(), assert.async()?

Please expand the readme with answers to those questions and some example code.

@mattmcmanus
Copy link

+1

@jonathanKingston
Copy link
Member

Due to naming issues with QUnit and Chai, you may need to use as in the import statement.

This seems to work for all the use cases you have mentioned.

import { moduleForModel, test } from 'ember-qunit';
import { assert as cassert } from 'chai';

moduleForModel('thing', 'Unit | Model | thing', {
  // Specify the other units that are required for this test.
  needs: []
});

test('it exists', function(assert) {
  var model = this.subject();
  // var store = this.store();
  cassert.ok(!!model);
  assert.ok(!!model);
});

Sorry for the delay with this.

@jonathanKingston
Copy link
Member

@mattmcmanus or @lolmaus let me know if you have issues and I can then update the documentation.

@lolmaus
Copy link
Author

lolmaus commented Sep 22, 2015

Hey @jonathanKingston, I've tried it and found a problem: Chai correctly reports failed assertions to QUnit (though the output is far from being expressive), but it does not report successful assertions. They do not appear on the list and do not increment the assertion counter.

Even worse, if you only have Chai assertions in a test block, QUnit would report:

Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.

@justin-hackin
Copy link

I suggest a big warning at the top of the README to inform others that this is not compatible with standard ember tests. No qunit compatibility = a bunch of wasted time in vain hopes of incorporating chai yummyness... best of wishes on making this more useful :)

@lolmaus
Copy link
Author

lolmaus commented Oct 8, 2015

So I implemented this instead: https://github.com/lolmaus/ember-cli-custom-assertions-collection

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants