Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-sinon-qunit

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-sinon-qunit

Sinon sandbox test integration for QUnit

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
increased by29.68%
Maintainers
1
Weekly downloads
 
Created
Source

Ember-Sinon-QUnit

This addon integrates Sinon & Ember-QUnit via Ember-Sinon, as inspired by Sinon-QUnit.

Why not simply use Ember-Sinon? Two reasons:

  1. Ember-Sinon does not handle cleanup of Ember-QUnit tests. Ember-Sinon-QUnit provides a test method that wraps Ember-QUnit while making each test callback a sandboxed Sinon environment. All spies/stubs created via the sandbox will be automatically restored to their original methods at the end of each test.
  2. Sinon is a framework-agnostic library; as such, Ember-Sinon should be as well. This addon exists to enable Ember-Sinon to remove its QUnit specific functionality, making it easier to utilize Ember-Sinon with other addons like Ember-CLI-Mocha, for example.

Usage

Import Ember-Sinon-QUnit's test method into your tests in place of Ember-QUnit's test. This creates a Sinon sandbox around that test via Sinon's test API. Then, you can access Sinon's spy, stub, mock, and sandbox methods via this within the test callback:

import { moduleFor } from 'ember-qunit';
import test from 'ember-sinon-qunit/test';

moduleFor('route:foo', 'Unit | Route | foo');

test('fooTransition action transitions to bar route', function (assert) {
  const route = this.subject();
  const stub = this.stub(route, 'transitionTo');
  
  route.send('fooTransition');
  
  assert.ok(stub.calledOnce, 'transitionTo was called once');
  assert.ok(stub.calledWithExactly('bar'), 'bar was passed to transitionTo');
});

That's it! You can use this test method in place of all Ember-QUnit tests if you want, without any loss of functionality. Or, you can import them both into the same test to be used only when you need Sinon:

import { moduleFor, test } from 'ember-qunit';
import sinonTest from 'ember-sinon-qunit/test';

Contributing

Installation

  • git clone this repository
  • cd ember-sinon-qunit
  • npm install
  • bower install

Running Tests

  • ember test
  • ember test --server

Keywords

FAQs

Package last updated on 10 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc