
A fixture writes the expected record count as a number. A refactor serializes it as text, which looks identical in the dashboard but changes the API contract. Deep strict equality inspects structure and type. Array order participates in equality, making it a useful contract when a list's order is observable.
Inspect the value before the UI formats it
The example keeps the input to node:assert outside the function, so it is possible to run the same transformation in a test. The comparison uses concrete data rather than the rendered component. If the application accepts a value from JSON, run the fixture after parsing that JSON to preserve the relevant types.
const assert = require('node:assert/strict');
function evaluate(value) {
try{assert.deepStrictEqual(value[0],value[1]);
return true}catch(e){if(e.code==='ERR_ASSERTION')return false;throw e}
}
const samples = [[{"count": 3}, {"count": "3"}], [[1, 2], [1, 2]], [[1, 2], [2, 1]]];
for (const sample of samples) console.log(evaluate(sample));What appears for each input
| Input | Return value |
|---|---|
| [{"count": 3}, {"count": "3"}] | False |
| [[1, 2], [1, 2]] | True |
| [[1, 2], [2, 1]] | False |
For [{"count": 3}, {"count": "3"}], the observed output is False. With [[1, 2], [1, 2]], it becomes True. A UI screenshot alone would discard some of this evidence. Keep the original data, the expected return value and the runtime version together when filing a regression report.
For [[1, 2], [2, 1]], the answer is False. A test that checks only whether the program returned normally would miss a reversed condition. Assert the boolean directly and include the input in the failure message so a change can be reproduced.
When the integration needs another check
Tests that mean unordered membership should say so explicitly instead of sorting every assertion by habit.
Run one case twice through the real feature and look at both the displayed value and its stored representation. A component may coerce a result to text even when the implementation returns a yes-or-no decision. Keep a failing sample small enough that it can travel with a bug report, including the browser or Node version that produced it.
Turn the edge behaviour into a regression test
Compare the actual shape beside the failing assertion in the test report. Seeing count as a string versus a number is more helpful than a generic assertion failed message when ownership crosses a JSON adapter boundary.
The same Node.js function was also run with [] / [{"count": 3}] / [{"count": "3"}, {"count": 3}]. These additional inputs change the boundary without changing the implementation. An exception name in the table records where the operation rejects an input; a returned empty or zero value records a successful call. Choose deliberately which of those outcomes the surrounding feature should expose.
| Additional fixture | Result or exception |
|---|---|
| [] | True |
| [{"count": 3}] | False |
| [{"count": "3"}, {"count": 3}] | False |
Node.js node:assert API · MDN JavaScript language guide
Sources and further reading
Cover photograph: 2018 Bay Area Mechanical Keyboard Meetup (31006275737) by Patrick Breen. CC BY 2.0. Cropped and typeset for this cover. The photograph illustrates the topic.
