Testing routes

Testing routes can be done either by acceptance tests or unit tests. In this example, we'll create a simple unit test for a route.

How to do it...

  1. In a new application, generate a new students route:
    $ ember g route students
    

    This command will generate the route code for students.

  2. Edit the students route information and add a new property:
    // app/routes/students.js
    import Ember from 'ember';
    
    export default Ember.Route.extend({
        someText: 'someText'
    });

    This route has a property called someText.

  3. Edit the students-tests.js file in the tests/unit/routes folder:
    // tests/unit/routes/students-test.js import { moduleFor, test } from 'ember-qunit'; moduleFor('route:students', 'Unit | Route | students', { // Specify the other units that are required ...

Get Ember.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.