Run Test Cases Inside Web Browser
Step 1. Run 'ember serve' |
Step 2. Create test cases |
Step 3. Visit 'http://localhost:4200/tests' |
Run Test Cases Without Web Browser
Step 1. Install phantom js '$ npm install phantomjs' |
Step 2. Create test cases |
Step 3. Run 'ember test' |
Asynchronous Helpers
visit(url) Visits the given route and returns a promise that fulfills when all resulting async behavior is complete.
|
fillIn(selector, text) Fills in the selected input with the given text and returns a promise that fulfills when all resulting async behavior is complete.
|
click(selector) Clicks an element and triggers any actions triggered by the element's click event and returns a promise that fulfills when all resulting async behavior is complete.
|
keyEvent(selector, type, keyCode) Simulates a key event type, e.g. keypress, keydown, keyup with the desired keyCode on element found by the selector.
|
triggerEvent(selector, type, options) Triggers the given event, e.g. blur, dblclick on the element identified by the provided selector.
|
Synchronous Helpers
find(selector, context) Finds an element within the app's root element and within the context (optional). Scoping to the root element is especially useful to avoid conflicts with the test framework's reporter, and this is done by default if the context is not specified.
|
currentPath() Returns the current path.
|
currentRouteName() Returns the currently active route name.
|
currentURL() Returns the current URL.
|
|
|
Wait Helpers
andThen(function) The andThen helper will wait for all preceding asynchronous helpers to complete prior to progressing forward.
|
Custom Test Helpers
Ember.Test.registerHelper() Registers a test helper that will be injected when App.injectTestHelpers is called.
|
Ember.Test.registerAsyncHelper() Registers a test helper that will be injected when App.injectTestHelpers is called. Will not run until any previous async helper has completed.
|
QUnit API Assert
async() Instruct QUnit to wait for an asynchronous operation.
|
deepEqual() A deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.
|
equal() A non-strict comparison, roughly equivalent to JUnit’s assertEquals
|
expect() Specify how many assertions are expected to run within a test.
|
notDeepEqual() An inverted deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.
|
notEqual() A non-strict comparison, checking for inequality.
|
notPropEqual() A strict comparison of an object’s own properties, checking for inequality.
|
notStrictEqual() A strict comparison, checking for inequality.
|
ok() A boolean check, equivalent to CommonJS’s assert.ok() and JUnit’s assertTrue(). Passes if the first argument is truthy.
|
propEqual() A strict type and value comparison of an object’s own properties.
|
push() Report the result of a custom assertion
|
strictEqual() A strict type and value comparison.
|
throws() Test if a callback throws an exception, and optionally compare the thrown error.
|
|
|
Ember CLI Test Generators
ember g controller-test <name> Generates a controller unit test.
|
ember g component-test <name> Generates a component unit test.
|
ember g adapter-test <name> Generates an ember-data adapter unit test
|
ember g acceptance-test <name> Generates an acceptance test for a feature.
|
ember g controller-test <name> Generates a controller unit test.
|
ember g helper-test <name> Generates a helper unit test.
|
ember g initializer-test <name> Generates an initializer unit test.
|
ember g mixin-test <name> Generates a mixin unit test.
|
ember g model-test <name> Generates a model unit test.
|
ember g route-test <name> Generates a route unit test.
|
ember g serializer-test <name> Generates a serializer unit test.
|
ember g service-test <name> Generates a service unit test.
|
ember g transform-test <name> Generates a transform unit test.
|
ember g util-test <name> Generates a util unit test.
|
ember g view-test <name> Generates a view unit test.
|
|
Created By
www.ProgramWithErik.com
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
More Cheat Sheets by ErikCH