diff --git a/packages/test-renderer/src/createTestInstance.ts b/packages/test-renderer/src/createTestInstance.ts index 28bc90d6ec..69d89f786d 100644 --- a/packages/test-renderer/src/createTestInstance.ts +++ b/packages/test-renderer/src/createTestInstance.ts @@ -12,7 +12,7 @@ export class ReactThreeTestInstance { } public get instance(): Object3D { - return (this._fiber as unknown) as TInstance + return this._fiber as unknown as TInstance } public get type(): string { @@ -20,7 +20,7 @@ export class ReactThreeTestInstance { } public get props(): Obj { - return this._fiber.__r3f.memoizedProps + return this._fiber.__r3f?.memoizedProps ?? this._fiber } public get parent(): ReactThreeTestInstance | null { @@ -50,7 +50,7 @@ export class ReactThreeTestInstance { */ return [ ...(fiber.children || []).map((fib) => wrapFiber(fib as MockInstance)), - ...fiber.__r3f.objects.map((fib) => wrapFiber(fib as MockInstance)), + ...(fiber.__r3f?.objects ?? []).map((fib) => wrapFiber(fib as MockInstance)), ] } else { return (fiber.children || []).map((fib) => wrapFiber(fib as MockInstance))