Skip to content

Commit 9dd918b

Browse files
AnnaMagMylesBorins
authored andcommitted
test: fix assertion in vm test
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>
1 parent 8e5c8a3 commit 9dd918b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/known_issues/test-vm-getters.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ const context = vm.createContext(sandbox);
1616
const code = 'Object.getOwnPropertyDescriptor(this, "prop");';
1717
const result = vm.runInContext(code, context);
1818

19-
assert.strictEqual(result, descriptor);
19+
// Ref: https://github.com/nodejs/node/issues/11803
20+
21+
assert.deepStrictEqual(Object.keys(result), Object.keys(descriptor));
22+
for (const prop of Object.keys(result)) {
23+
assert.strictEqual(result[prop], descriptor[prop]);
24+
}

0 commit comments

Comments
 (0)