Skip to content

[Node v20] assert.deepEqual doesn't detect two different URLs #50836

Closed
@regseb

Description

@regseb

Version

v20.9.0

Platform

Linux regseblaptop 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  • create file index.js:

    const assert = require("node:assert/strict");
    
    const url1 = new URL("http://foo1.com/");
    const url2 = new URL("http://foo2.com/");
    assert.deepEqual(url1, url2);
  • node index.js

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

The index.js script must raise an error because the two URLs are different.

What do you see instead?

No error.

Additional information

  • npx node@18 index.js

    node:assert:125
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
    + actual - expected ... Lines skipped
    
      URL {
        [Symbol(context)]: URLContext {
          hash_start: 4294967295,
          host_end: 15,
          host_start: 7,
    +     href: 'http://foo1.com/',
    -     href: 'http://foo2.com/',
          pathname_start: 15,
    ...
          username_end: 7
        }
      }
        at Object.<anonymous> (/home/regseb/testcase/index.js:5:8)
        at Module._compile (node:internal/modules/cjs/loader:1256:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
        at Module.load (node:internal/modules/cjs/loader:1119:32)
        at Module._load (node:internal/modules/cjs/loader:960:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
        at node:internal/main/run_main_module:23:47 {
      generatedMessage: true,
      code: 'ERR_ASSERTION',
      actual: URL {
        [Symbol(context)]: URLContext {
          href: 'http://foo1.com/',
          protocol_end: 5,
          username_end: 7,
          host_start: 7,
          host_end: 15,
          pathname_start: 15,
          search_start: 4294967295,
          hash_start: 4294967295,
          port: 4294967295,
          scheme_type: 0
        }
      },
      expected: URL {
        [Symbol(context)]: URLContext {
          href: 'http://foo2.com/',
          protocol_end: 5,
          username_end: 7,
          host_start: 7,
          host_end: 15,
          pathname_start: 15,
          search_start: 4294967295,
          hash_start: 4294967295,
          port: 4294967295,
          scheme_type: 0
        }
      },
      operator: 'deepStrictEqual'
    }
    
    Node.js v18.18.2
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions