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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ember-aupac-mocks

v1.0.1

Published

Mocking for ember tests

Readme

Ember-aupac-mocks

NPM package Build Status Ember Observer Score

Javascript Mocking and Matching Library for unit testing ember-cli applications.

Requirements

ember-cli >= 1.13.x

Installing

ember install ember-aupac-mocks

Usage

Import the Mocks and Matchers into your ember test.

import { Mocks, Matchers } from 'ember-aupac-mocks';

//Use object deconstruction to pull out the features you want to use
const { mock, mockFunction, verify, when, ...more} = Mocks;
const { empty, emailAddress, greaterThan, everyItem, hasSize, even, lessThan, either, ...more} = Matchers;

//Start mocking and matching in your tests
test('mocking and matching', function(assert) {

  const myMock = mock(Ember.Object);
  when(myMock).get('name').thenReturn('hello world');
  assert.equal('hello world', myMock.get('name'), 'should be the same');
  verify(myMock).get('name');

  assertThat('', empty());
  assertThat('[email protected]', emailAddress());
  assertThat(10, either(greaterThan(50)).or(even()));
  assertThat([1,2,3], everyItem(greaterThan(0)));
  assertThat([1,2,3], hasSize(lessThan(5)));
});

Features

Rich and readable matching api - docs

assertThat('', empty());
assertThat('[email protected]', emailAddress());
assertThat(10, either(greaterThan(50)).or(even()));
assertThat([1,2,3], everyItem(greaterThan(0)));
assertThat([1,2,3], hasSize(lessThan(5)));

Mock any object - docs

var modelMock = mock(DS.Model);
var controllerMock = mock(Ember.Controller);

Setup expectations on your mocks - docs

var employeeMock = mock(DS.Model);
when(employeeMock).get('name').thenReturn('jack');
equal('jack',employeeMock.get('name'));

Verify function execution - docs

var employeeMock = mock(DS.Model);
employeeMock.get('name');
verify(employeeMock).get("name");

Mock functions - docs

var mockedFunc = mockFunction();

Verify function execution - docs

var mockedFunc = mockFunction();
mockedFunc('hello world');
verify(mockedFunc)('hello world');
  • Visit JsMockito for more information about mocking.
  • Visit JsHamcrest for more information about the matching.

Mocks - docs

const {
  mock,
  when,
  verify,
  mockFunction,
  spy,
  verifyZeroInteractions,
  verifyNoMoreInteractions,
  isMock,
  never,
  zeroInteractions,
  noMoreInteractions,
  times,
  once
  } = Mocks;

Matchers - docs

const {
  assertThat,
  empty,
  everyItem,
  hasItem,
  hasItems,
  hasSize,
  isIn,
  oneOf,
  allOf,
  anyOf,
  anything,
  both,
  either,
  equalTo,
  is,
  nil,
  not,
  raises,
  raisesAnything,
  sameAs,
  truth,
  equivalentMap,
  equivalentArray,
  between,
  closeTo,
  divisibleBy,
  even,
  greaterThan,
  greaterThanOrEqualTo,
  lessThan,
  lessThanOrEqualTo,
  notANumber,
  odd,
  zero,
  bool,
  func,
  hasFunction,
  hasMember,
  instanceOf,
  number,
  object,
  string,
  typeOf,
  containsString,
  emailAddress,
  endsWith,
  equalIgnoringCase,
  matches,
  startsWith,
  filter,
  callTo
  } = Matchers;

Installation

  • git clone this repository
  • npm install
  • bower install

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.