DouglasMeyer/test_it — Issue #3: Node.js: T.inspect of Array results into '{}'
Author: LiraNuna
Created: 2011-11-10 00:06:11+00:00
State: open

TestIt.inspect will return a '{}' for empty arrays in nodejs because of a bad javascript parctice:

> var TestIt = require('test_it');
> TestIt.inspect([])
'{}'

The problem is caused because of a bad Javascript practice in TestIt source (test_it.js line 347) - you are comparing the constructor to Array which is only good if you are in a browser and do not work across IFrames.

The correct way to compare an array is to either use Array.isArray (not supported everywhere) or roll your own:

function isArray(instance) {
return Object.prototype.toString.call(instance) == '[object Array]';
}