A few seconds.

ember-sinon

Ember CLI addon for sinon.js

Ember-Sinon

Build Status Ember Observer Score Dependency Status Code Climate Codacy Badge

This addon adds support for Sinon to assist in testing your Ember CLI app.

Installation

If you are using Ember CLI 0.2.3 or higher:

ember install ember-sinon

otherwise:

npm install --save-dev ember-sinon
ember g ember-sinon

Usage

While in testing mode (i.e. either when visiting /tests or when running ember test), sinon will be available as an import.

import sinon from 'sinon';

test(".runCallback() should run the callback passed", function(assert) {
  var spy = sinon.spy();
  this.subject().runCallback(spy);

  // Default Sinon messages:
  sinon.assert.calledOnce(spy);
  sinon.assert.calledWith(spy, 'foo');

  // Custom messages:
  assert.ok(spy.calledOnce, "the callback should be called once");
  assert.ok(spy.calledWith('foo'), "the callback should be passed 'foo' as an argument");
});

Integration with testing frameworks

Check out ember-sinon-qunit for QUnit integration!

Running Tests

You must have PhantomJS installed to run tests.

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server
Pincer is a project which aims to provide best library discovery tools for developers. We're growing day by day. We have only npm platform for now but we will add the others as much as we can.