diff --git a/test/sample-components/depth-2-nested-1.tsx b/test/sample-components/depth-2-nested-1.tsx
new file mode 100644
index 0000000..1d20cf7
--- /dev/null
+++ b/test/sample-components/depth-2-nested-1.tsx
@@ -0,0 +1,16 @@
+// import * as PropTypes from "prop-types";
+import * as React from "react";
+
+class CDepth2Nested1 extends React.Component {
+ render() {
+ return ;
+ }
+}
+
+class CDepth0 extends React.Component {
+ render() {
+ return null;
+ }
+}
+
+export default CDepth2Nested1;
diff --git a/test/sample-components/depth-3-nested-1.tsx b/test/sample-components/depth-3-nested-1.tsx
new file mode 100644
index 0000000..5c65be3
--- /dev/null
+++ b/test/sample-components/depth-3-nested-1.tsx
@@ -0,0 +1,20 @@
+// import * as PropTypes from "prop-types";
+import * as React from "react";
+
+class CDepth3Nested1 extends React.Component {
+ render() {
+ return (
+
+
+
+ );
+ }
+}
+
+class CDepth0 extends React.Component {
+ render() {
+ return null;
+ }
+}
+
+export default CDepth3Nested1;
diff --git a/test/traverse-nested.spec.tsx b/test/traverse-nested.spec.tsx
new file mode 100644
index 0000000..815e181
--- /dev/null
+++ b/test/traverse-nested.spec.tsx
@@ -0,0 +1,43 @@
+// import * as React from "react";
+
+// Import stuff from src
+import { traverse } from "../src";
+
+// Import test helpers and sample components
+import { mountAndGetRootNode } from "./utils/mount-in-enzyme";
+import CDepth2Nested1 from "./sample-components/depth-2-nested-1";
+import CDepth3Nested1 from "./sample-components/depth-3-nested-1";
+
+describe("traverse", () => {
+ let container: HTMLDivElement;
+
+ beforeEach(() => {
+ container = document.body.appendChild(document.createElement("div"));
+ });
+
+ afterEach(() => {
+ document.body.removeChild(container);
+ });
+
+ describe("nested", () => {
+ it("should work for depth=2 with level of nesting=1", () => {
+ const rootNode = mountAndGetRootNode(CDepth2Nested1, container);
+ const mockCallback = jest.fn();
+
+ traverse(rootNode, mockCallback);
+
+ expect(mockCallback.mock.calls.length).toBe(2);
+ });
+ });
+
+ it("should work for depth=3 with level of nesting=1", () => {
+ const rootNode = mountAndGetRootNode(CDepth3Nested1, container);
+ const mockCallback = jest.fn();
+
+ traverse(rootNode, mockCallback);
+
+ // Shouldn't count just component depth, should include string nodes
+ expect(mockCallback.mock.calls.length).not.toBe(2);
+ expect(mockCallback.mock.calls.length).toBe(3);
+ });
+});