Giter Club home page Giter Club logo

ember-test-helpers's Introduction

ember-test-helpers Build Status

A test-framework-agnostic set of helpers for testing Ember.js applications.

Usage

This library is best used in conjunction with a test-framework-specific wrapper, such as ember-qunit or ember-mocha.

This library was written using ES6 modules, which are contained in lib/. These modules must be transpiled for pre-ES6 compatibility.

Test Helpers

TestModule

The TestModule class is used to configure modules for unit testing different aspects of your Ember application. This class can be extended to create modules focused on particular types of unit tests.

TestModule is intended to be used in conjunction with modules specific to a test framework. For instance, you could create QUnit-compatible modules with a method such as:

function moduleFor(name, description, callbacks) {
  var module = new TestModule(name, description, callbacks);

  QUnit.module(module.name, {
    setup: function() {
      module.setup();
    },
    teardown: function() {
      module.teardown();
    }
  });
}

TestModule(name [, description [, callbacks]])

  • name - the full name of the test subject as it is registered in a container (e.g. 'controller:application', 'route:index', etc.).

  • description (optional) - the description of the test module as it should be displayed in test output. If omitted, defaults to name.

  • callbacks (optional) - an object that may include setup and teardown steps as well as the other units needed by tests.

TestModuleForComponent

TestModuleForComponent extends TestModule to allow unit testing of Ember Components.


TestModuleForComponent(name [, description [, callbacks]])

  • name - the short name of the component that you'd use in a template (e.g. 'x-foo', 'color-picker', etc.).

TestModuleForModel

TestModuleForModel extends TestModule to allow unit testing of Ember Data Models.


TestModuleForModel(name [, description [, callbacks]])

  • name - the short name of the model that you'd use in store operations (e.g. 'user', 'assignmentGroup', etc.).

Miscellaneous Helpers

  • getContext / setContext - access the context to be used in each test.

  • setResolver - sets the resolver which will be used to look up objects from each test's container.

  • isolatedContainer - creates a new isolated container for unit testing.

Contributing

Contributions are welcome. Please follow the instructions below to install and test this library.

Installation

$ npm install
$ bower install

Testing

In order to test in the browser:

$ npm start

... and then visit http://localhost:4200/tests.

In order to perform a CI test:

$ npm test

Attribution

Much of ember-test-helpers was extracted from the original ember-qunit, which was written by Stefan Penner, Robert Jackson, and Ryan Florence.

Copyright and License

Copyright 2014 Switchfly and contributors.

Dual-licensed under the Apache License, Version 2.0 and the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.