Book Image

Learning Yeoman

By : Jonathan Spratley
Book Image

Learning Yeoman

By: Jonathan Spratley

Overview of this book

Table of Contents (17 chapters)
Learning Yeoman
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Modern Workflows for Modern Webapps
Index

Backbone generator solutions


This section covers some solutions that one might need when using the Backbone generator.

Code coverage with Karma

Problem: You want to run your project's unit tests with Karma and generate code coverage for your project.

Solution: Since you want to use Karma and leverage the karma-coverage plugin, you will need to create and configure a test/test-main.js file that will parse all the indexed files and create an array of spec files that are then added to the Require.js configuration as dependencies. After all the files have been indexed, you will need to start Karma so the specs can be run. To do so, perform the following steps:

Installing Karma and plugins

Since the Yeoman Backbone generator creates a Karma configuration file located in the root of the project directory by default, all that is needed is to install the karma-coverage plugin and enable it in your karma.conf.js file.

To install karma-coverage, open the terminal and execute the following command:

$ npm...