Using console.log in a Node JS test

Get help with testing, discuss unit testing strategies etc.

Post Reply
User avatar
Core Developer
Core Developer
Posts: 16545
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden

Using console.log in a Node JS test

Post by mats »

Here's some background detailing why you cannot access symbols like 'console' in a Node sandbox.

Here's a hack to work around it if you need access to the console object.

Decorate the Harness with the console object.

Code: Select all

    title       : 'Cross-platform Test Suite',

    testClass   : testClass,
    console     : console,
    preload     : [
And in your test:

Code: Select all

StartTest(function(t) {
    t.harness.console.log('foo');, 1, 'Correct')
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

API documentation

Post Reply