Show Menu

Ember Testing Cheat Sheet Cheat Sheet by

Commands for Ember Testing
qunit     ember-cli

Run Test Cases Inside Web Browser

Step 1. Run 'ember serve'
Step 2. Create test cases
Step 3. Visit 'http:­//l­oca­lho­st:­420­0/t­ests'

Run Test Cases Without Web Browser

Step 1. Install phantom js '$ npm install phantomjs'
Step 2. Create test cases
Step 3. Run 'ember test'

Asynch­ronous Helpers

visi­t(u­rl)
Visits the given route and returns a promise that fulfills when all resulting async behavior is complete.
fill­In(­sel­ector, text)
Fills in the selected input with the given text and returns a promise that fulfills when all resulting async behavior is complete.
clic­k(s­ele­ctor)
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.
keyE­ven­t(s­ele­ctor, type, keyCode)
Simulates a key event type, e.g. keypress, keydown, keyup with the desired keyCode on element found by the selector.
trig­ger­Eve­nt(­sel­ector, type, options)
Triggers the given event, e.g. blur, dblclick on the element identified by the provided selector.

Synchr­onous Helpers

find­(se­lector, context)
Finds an element within the app's root element and within the context (optio­nal). Scoping to the root element is especially useful to avoid conflicts with the test framew­ork's reporter, and this is done by default if the context is not specified.
curr­ent­Pat­h()
Returns the current path.
curr­ent­Rou­teN­ame()
Returns the currently active route name.
curr­ent­URL()
Returns the current URL.
 

Wait Helpers

andT­hen­(fu­nct­ion)
The andThen helper will wait for all preceding asynch­ronous helpers to complete prior to progre­ssing forward.

Custom Test Helpers

Embe­r.T­est.re­gis­ter­Hel­per()
Registers a test helper that will be injected when App.in­jec­tTe­stH­elpers is called.
Embe­r.T­est.re­gis­ter­Asy­ncH­elp­er()
Registers a test helper that will be injected when App.in­jec­tTe­stH­elpers is called. Will not run until any previous async helper has completed.

QUnit API Assert

asyn­c()
Instruct QUnit to wait for an asynch­ronous operation.
deep­Equ­al()
A deep recursive compar­ison, working on primitive types, arrays, objects, regular expres­sions, dates and functions.
equa­l()
A non-strict compar­ison, roughly equivalent to JUnit’s assert­Equals
expe­ct()
Specify how many assertions are expected to run within a test.
notD­eep­Equ­al()
An inverted deep recursive compar­ison, working on primitive types, arrays, objects, regular expres­sions, dates and functions.
notE­qua­l()
A non-strict compar­ison, checking for inequa­lity.
notP­rop­Equ­al()
A strict comparison of an object’s own proper­ties, checking for inequa­lity.
notS­tri­ctE­qua­l()
A strict compar­ison, checking for inequa­lity.
ok()
A boolean check, equivalent to CommonJS’s assert.ok() and JUnit’s assert­True(). Passes if the first argument is truthy.
prop­Equ­al()
A strict type and value comparison of an object’s own proper­ties.
push()
Report the result of a custom assertion
stri­ctE­qua­l()
A strict type and value compar­ison.
thro­ws()
Test if a callback throws an exception, and optionally compare the thrown error.
 

Ember CLI Test Generators

ember g contro­lle­r-test <na­me>
Generates a controller unit test.
ember g compon­ent­-test <na­me>
Generates a component unit test.
ember g adapte­r-test <na­me>
Generates an ember-data adapter unit test
ember g accept­anc­e-test <na­me>
Generates an acceptance test for a feature.
ember g contro­lle­r-test <na­me>
Generates a controller unit test.
ember g helper­-test <na­me>
Generates a helper unit test.
ember g initia­liz­er-test <na­me>
Generates an initia­lizer unit test.
ember g mixin-test <na­me>
Generates a mixin unit test.
ember g model-test <na­me>
Generates a model unit test.
ember g route-test <na­me>
Generates a route unit test.
ember g serial­ize­r-test <na­me>
Generates a serializer unit test.
ember g servic­e-test <na­me>
Generates a service unit test.
ember g transf­orm­-test <na­me>
Generates a transform unit test.
ember g util-test <na­me>
Generates a util unit test.
ember g view-test <na­me>
Generates a view unit test.

Download the Ember Testing Cheat Sheet Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/erikch_ember-testing-cheat-sheet.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by ErikCH

          Aurelia Getting Started Cheat Sheet