diff --git a/package.json b/package.json
index 9f9ad08..744df91 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
"license": "MIT",
"dependencies": {
"lodash.compact": "^3.0.1",
+ "lodash.isplainobject": "^4.0.6",
"lodash.omit": "^4.5.0",
"object-values": "^1.0.0",
"object.entries": "^1.0.3"
diff --git a/src/shallow.js b/src/shallow.js
index 2c60049..e47e774 100644
--- a/src/shallow.js
+++ b/src/shallow.js
@@ -1,4 +1,5 @@
import compact from 'lodash.compact';
+import isPlainObject from 'lodash.isplainobject';
import omit from 'lodash.omit';
import entries from 'object.entries';
import {propsOfNode} from 'enzyme/build/Utils';
@@ -18,7 +19,7 @@ function nodeToJson(node) {
return node.map(nodeToJson);
}
- if (typeof node === 'object') {
+ if (isPlainObject(node)) {
return entries(node).reduce((obj, [key, val]) => {
obj[key] = nodeToJson(val);
return obj;
diff --git a/test/__snapshots__/shallow.test.js.snap b/test/__snapshots__/shallow.test.js.snap
index 42984b0..057008b 100644
--- a/test/__snapshots__/shallow.test.js.snap
+++ b/test/__snapshots__/shallow.test.js.snap
@@ -96,3 +96,12 @@ exports[`test handles elements in props 1`] = `
} />
`;
+
+exports[`test ignores non-plain objects 1`] = `
+
+`;
diff --git a/test/shallow.test.js b/test/shallow.test.js
index 13b7676..2c90250 100644
--- a/test/shallow.test.js
+++ b/test/shallow.test.js
@@ -68,3 +68,15 @@ it('handles elements in prop objects', () => {
expect(shallowToJson(shallowed)).toMatchSnapshot();
});
+
+it('ignores non-plain objects', () => {
+ function TestConstructor() {
+ this._test = true;
+ }
+
+ const shallowed = shallow(
+
+ );
+
+ expect(shallowToJson(shallowed)).toMatchSnapshot();
+});