npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-qunit-assert-helpers

v0.2.2

Published

An ember-addon that provides additional QUnit 2.0 assertions specific to Ember.js.

Downloads

7,624

Readme

ember-qunit-assert-helpers

This addon provides additional QUnit 2.0 assertions that are specific to Ember.js. It is meant to be a replacement for ember-dev which only supports QUnit 1.0.

Can be use in your application or an addon.

Installation

ember install ember-qunit-assert-helpers

Compatibility

This addon relies on functionality introduced in Ember 2.1. If you need support for Ember 2.0 and old, please also include ember-debug-handlers-polyfill.

Usage

Ember.assert Assertions

assert.expectAssertion(callback, matcher)

Asserts that Ember.assert did throw an error. An optional string or regular expression matcher can be provided to match a specific error message.

test('triggers Ember.assert', function(assert) {
  assert.expectAssertion(() => {
    // Code triggers Ember.assert
  });

  assert.expectAssertion(() => {
    Ember.assert('You forgot "bar", the required parameter');
  }, /You forgot "\w+", the required parameter/);
})

Ember.run Assertions

assert.expectNoRunLoop()

Asserts that there is not a current run loop running and there are no scheduled timers. If there are, they will be cleaned up.

test('`Ember.deprecate` was called anytime during the test and matched', function(assert) {
  Ember.run.later(() => { });
  assert.expectNoRunLoop(); // Fail
});

Ember.deprecate Assertions

assert.expectDeprecation(callback, matcher)

Asserts that Ember.deprecate was called. An optional callback can be provided. An optional string or regular expression matcher can also be provided.

test('`Ember.deprecate` was called anytime during the test', function(assert) {
  // ...

  // One or more deprecations were triggered since the start of this test
  assert.expectDeprecation();
});

test('`Ember.deprecate` was called in a callback', function(assert) {
  assert.expectDeprecation(() => {
    // Code triggers one or more Ember.deprecate
  });
});

test('`Ember.deprecate` was called anytime during the test and matched', function(assert) {
  // ...

  // One or more deprecations matching a specific message were triggered since the start of this test
  assert.expectDeprecation(/expected deprecation message/);
});

test('`Ember.deprecate` was called in a callback', function(assert) {
  assert.expectDeprecation(() => {
    Ember.deprecate('API is deprecated', false, {
      id: 'old-api',
      until: '3.0.0'
    })
  }, 'API is deprecated');
});

assert.expectNoDeprecation(callback, matcher)

Asserts that Ember.deprecate was not called. An optional callback can be provided. An optional matcher can also be provided.

test('`Ember.deprecate` was not called anytime during the test', function(assert) {
  // ...

  // No deprecations were triggered since the start of this test
  assert.expectNoDeprecation();
});

Ember.warn Assertions

Same as Ember.deprecate, but for warnings. Above code samples can be applied here.

assert.expectWarning(callback, matcher)

Asserts that Ember.warn was called. An optional callback can be provided. An optional matcher can also be provided.

assert.expectNoWarning(callback, matcher)

Asserts that Ember.warn was not called. An optional callback can be provided. An optional matcher can also be provided.

afterEach asserting

You can easily use these asserts in your afterEach.

moduleForComponent('x-foo', {
  integration: true,
  afterEach(assert) {
    assert.expectNoDeprecation();
    assert.expectNoRunLoop();
    assert.expectNoWarning();
  }
});

Thanks and Credit

Thanks to Robert Jackson (@rwjblue) for providing guidance on the implementation.

Credit goes ember-dev and CrowdStrike for the overall concept and much the API provided by this addon.