Skip to content

Commit

Permalink
test: fix assertion in vm test
Browse files Browse the repository at this point in the history
Prototypes are not strict equal when they are from
different contexts. Therefore, assert.strictEqual()
fails for objects that are created in different
contexts, e.g., in vm.runInContext().

Instead of expecting the prototypes to be equal,
only check the properties of the objects
for equality.

PR-URL: #11862
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
AnnaMag authored and MylesBorins committed Apr 19, 2017
1 parent 8e5c8a3 commit 9dd918b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/known_issues/test-vm-getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ const context = vm.createContext(sandbox);
const code = 'Object.getOwnPropertyDescriptor(this, "prop");';
const result = vm.runInContext(code, context);

assert.strictEqual(result, descriptor);
// Ref: https://github.com/nodejs/node/issues/11803

assert.deepStrictEqual(Object.keys(result), Object.keys(descriptor));
for (const prop of Object.keys(result)) {
assert.strictEqual(result[prop], descriptor[prop]);
}

0 comments on commit 9dd918b

Please sign in to comment.