16.07.2017 Views

AngularJS Essentials

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Unit Testing<br />

'src/parkingCtrl.js',<br />

'src/plateFilter.js',<br />

'src/uiApp.js',<br />

'src/alertDirective.js',<br />

'src/mockedCarsFactoryFunction.js',<br />

'src/parkingHttpFacade.js',<br />

'src/parkingCtrlWithHttpFacade.js',<br />

'spec/parkingServiceSpec.js',<br />

'spec/parkingCtrlSpec.js',<br />

'spec/plateFilterSpec.js',<br />

'spec/alertDirectiveSpec.js',<br />

'spec/parkingHttpFacadeSpec.js'<br />

'spec/parkingCtrlWithHttpFacadeSpec.js'<br />

],<br />

exclude: [<br />

],<br />

reporters: ['progress'],<br />

port: 9876,<br />

colors: true,<br />

logLevel: config.LOG_INFO,<br />

autoWatch: true,<br />

browsers: ['Chrome'],<br />

captureTimeout: 60000,<br />

singleRun: false<br />

});<br />

};<br />

Running tests<br />

Before you run the tests, you need to start the Karma server. It is based on the<br />

browser configuration and can be started with the following command:<br />

karma start<br />

After this, we will be able to run the tests with the following command in another<br />

terminal window:<br />

karma run<br />

However, the behavior of Karma is different based on the autoWatch and singleRun<br />

properties. When the autoWatch property is enabled, Karma watches the source<br />

and test files, running tests every time to check whether anything has changed. The<br />

singleRun property is very useful when you are interested in just a single execution<br />

of the tests, such as when you are in an automated workflow.<br />

[ 142 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!