Skip to content

Commit 5231270

Browse files
committed
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.
1 parent d77a758 commit 5231270

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)