Writing the test

Before we start writing our test, let's clean up the test folder by removing the app.spec.js file in the unit folder. Once completed, you should have something similar to folder tree:

.
├── aurelia-karma.js
└── unit
└── setup.js

In the unit folder, create the info-box.spec.js file and add the following code:

 import {StageComponent} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrapper';

describe('Info-Box', () => {

it('should render the username and topic', () => {

});
});

First, we import two objects from the Aurelia framework that we will use to initialize our info-box component. Then, we declare our Info-Box test suite and we declare one test case.

Note that we are using a special syntax; instead of using function() {}, we are using () => {} ECMAScript syntax. To unit test our component, we will need to perform the following steps:

  1. Bootstrap the component
  2. Test the component
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset