Skip to content

Using fluture/test/assertions.js with Json is never reference-equal #35

@dotnetCarpenter

Description

@dotnetCarpenter

Using fluture/test/assertions.js with Json is never reference-equal when Json is imported from a commonjs module and esm module and compared with equivalence.

When using Json from 'fluture-express', if you test subject is a commonjs module, then the value in the Json object is not reference-equal and tests with equivalence from 'fluture/test/assertions.js' will fail even though the tests should pass.

Error:
	resolve ({"body": {"data": {"foo": "bar"}}, "head": []}) :: Future({ <resolved> {"body": {"data": {"foo": "bar"}}, "head": []} })
is not equivalent to:
	resolve ({"body": {"data": {"foo": "bar"}}, "head": []}) :: Future({ <resolved> {"body": {"data": {"foo": "bar"}}, "head": []} })

The inner values are not equal: Values have same structure but are not reference-equal

Example of error message when Json is not imported via esm.

However, note that it does not matter if your test data is from a commonjs module or EcmaScript module (esm).

A thorough run down is in the https://github.com/dotnetCarpenter/fluture-test-gotcha repository.

It boils down to strictEqual and show from 'sanctuary-show' not playing nice together. I guess that the output of show (a) changes depending on module format. But that is a guess.

// always success
deepStrictEqual (Json (data1), Json (data1));
deepStrictEqual (Json (data2), Json (data2));
// always failure
strictEqual (Json (data1), Json (data1));
strictEqual (Json (data2), Json (data2));

strictEqual.mjs and strictEqual.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions