Skip to content

assert.deepStrictEqual() fails to compare ES6 style object properties #11803

Description

@AnnaMag
  • Version: v7.7.1
  • Platform: Mac OSX X86_64
  • Subsystem:

The following assertion fails when objects are property descriptors:

'use strict';
require('../common');
const assert = require('assert');

const x = {};

Object.defineProperty(x, 'prop', {
  get() {
    return 'foo';
  }
});

const y = {};

Object.defineProperty(y, 'prop', {
  get() {
    return 'foo';
  }
});

const descriptorx = Object.getOwnPropertyDescriptor(x, 'prop');
const descriptory = Object.getOwnPropertyDescriptor(y, 'prop');

assert.deepStrictEqual(x, y); // ok
assert.deepStrictEqual(descriptorx, descriptory); // throws an error

What seems to happen is that (in both cases) Object.getPrototypeOf(descriptor)
results in {}, which leads to the condition
https://github.com/nodejs/node/blob/master/lib/assert.js#L200
returning false. Same is true for assert.strictEqual()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions