Skip to content

Testing best practices

jtlan edited this page Aug 18, 2015 · 30 revisions

Testing best practices

Add more best practices here!

Checking the size of a D3 Selection

The "length" of a D3 Selection is always 1, regardless of how many elements are in it:

d3.select().length; // 1, not 0

The correct way to check the size of the Selection is to assert that its size() is equal to a particular value:

assert.strictEquals(selection.size(), expectedSize, message);