diff --git a/lib/assertions.js b/lib/assertions.js
index <HASH>..<HASH> 100644
--- a/lib/assertions.js
+++ b/lib/assertions.js
@@ -238,7 +238,7 @@ module.exports = function (expect) {
 
         if (this.flags.only) {
             expect(hasKeys, 'to be truthy');
-            expect(Object.keys(subject).length === keys.length, '[not] to be truthy');
+            expect(expect.findTypeOf(subject).getKeys(subject).length === keys.length, '[not] to be truthy');
         } else {
             expect(hasKeys, '[not] to be truthy');
         }
diff --git a/test/unexpected.spec.js b/test/unexpected.spec.js
index <HASH>..<HASH> 100644
--- a/test/unexpected.spec.js
+++ b/test/unexpected.spec.js
@@ -1210,6 +1210,12 @@ describe('unexpected', function () {
         });
     });
 
+    describe('to have keys assertion', function () {
+        it('should work with non-enumerable keys returned by the getKeys function of the subject type', function () {
+            expect(new Error('foo'), 'to only have key', 'message');
+        });
+    });
+
     describe('properties assertion', function () {
         it('asserts presence of a list of properties', function () {
             expect({a: 'foo', b: 'bar'}, 'to have properties', ['a', 'b']);
to have only key(s): Use type.getKeys instead of Object.keys.