Other than the HTTP requests that the browser makes, Zombie doesn't output much else that may be interesting or useful while debugging for you to debug your application.
A good option, which provides far more flexibility and insight, is to run your application inside a real browser with developer tools and/or a debugger.
A particularly useful alternative for debugging issues that are encountered specifically in Zombie.js is to use the console.log()
function inside your browser code (the code that, in the case of this app, sits inside the public/js
directory).
As an example, suppose that you were having a problem with the to-do creation form: the alarm option was not correctly triggering the show and hide option of the alarm option pane. For this, we can introduce the following console.log
statement in the public/js/todos.js
file, in order to inspect the value of the ringAlarm
variable: function hideOrShowDateTime()
.
{
var ringAlarm = $('input[name=alarm]:checked',
'#new-todo-form').val() === 'true';
console.log('\ntriggered hide or show. ringAlarm is ', ringAlarm);
if (ringAlarm) {
$('#alarm-date-time').slideDown();
} else {
$('#alarm-date-time').slideUp();
}
}
This way, when you run the test, you will get the following output:
$ node_modules/.bin/mocha -R spec -g 'alarm' test/todos Todos Todo creation form . should have an alarm option: triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false ✓ should have an alarm option (625ms) . should present the alarm date form fields when alarm: triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is true triggered hide or show. ringAlarm is true triggered hide or show. ringAlarm is false triggered hide or show. ringAlarm is false ✓ should present the alarm date form fields when alarm (1641ms) ✔ 2 tests complete (2393ms)
Using this technique, you can then inspect the state of your application when the tests are being run.