Automated Testing with Backbone
Testing is only useful if we actually use it. We really want to have our tests running permanently in the background as we work. We also really want to have our tests next to out code, so it is obvious which files are being tested, and which are not.
In this section we will write some tests for a Backbone app.
Inside your exercises folder you will find a simple test harness with live-server and jasmine. Download it now.
Grab the dependencies with
To start building and testing, a script has been created in the package.json file. You can run
npm run dev, and the tests will automatically fire up.
Exercise Resources and Downloads
Exercise - Extend these tests
Take the starting project and extend it so that the catView can set a name that we pass, rather than always setting the name to Mikey. Write the tests first, so they fail, then write code to make them pass.
Add a function to set an age and check that it works.
Further Exercise - Test a project
Pick your favourite project from yesterday. Add automated testing to it. You'll need the
package.json file, the
webpack.config.js file, and