tapjs/tap-parser

Ability to set uniqueKeys to false when parsing YAML

Closed this issue · 0 comments

The deepEqual function in the "node:assert/strict" module, when comparing two arrays, results in a YAML with an array with duplicated keys. That is just the way that it formats diffs.
Such entries are irrelevant in the parsed output, but they make the parsing fail outright, with the diag key being set to null.
I would like to be able to customize the options passed to the yaml package in order to set the uniqueKeys option to false, such that these "invalid" entries would simply be skipped instead of making the parsing fail completely.
In fact, imho, it should be set to false by default.

Update:
Actually, I have tired to set that option manually in the node_modules and diag is still null, I do not know why it fails.

The test file looks like this:

import assert from "node:assert/strict";
import test from "node:test";

test("attempt", () => {
  assert.deepEqual(["foo", "bar", "baz"], ["foo", "bar", "ba"]);
});

I am executing it with node --test and then passing the TAP output to "tap-parser".

Update

I just realized that I'm not actually using "tap-parser" directly (I couldn't make node --test work for me, because it was truncating the TAP output so much it was missing almost all of the actually useful information).
I'm getting this output from the "test:fail" event of the TapStream instance returned by the run function of the native "node:test" module.
Although, I suspect that it probably uses "tap-parser" internally, because the shapes and even type names that I get are exactly the same.
The way that I was able to overcome this problem is by taking the next "extra" event after the failed "assert" event, then parsing it as yaml and overriding the diag field of the "assert" event with the result of parsing.
Thus, I'm retrying the parsing of this specific event manually with just uniqueKeys set to false.
So, this feature request is still relevant to me, although it should probably go to the "tap-yaml" repo instead.