# Pester: Unable to find type

**URL:** <https://forums.powershell.org/t/pester-unable-to-find-type/7561>\
**Category:** PowerShell Help\
**Created:** [November 20, 2016, 7:42am UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561 "2016-11-20T07:42:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregt8](https://avatars.discourse-cdn.com/v4/letter/g/3bc359/32.png) [@gregt8](https://forums.powershell.org/u/gregt8)\
**Post date:** [November 20, 2016, 7:42am UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561/1 "2016-11-20T07:42:30Z")

</div>

Just getting started with Pester and want to test that my function returns an object of custom type. I am using the test {Get-CustomObjectType} | Should Be ([CustomObjectType]). However, when running the test I get an error message RuntimeException: Unable to find type [CustomObjectType].

In the test file, ISESteroids shows a squiggly line indicating ‘CustomObjectType’ is unknown. You may have to load an assembly first. You may have to run this script once to load non-default assemblies. Adornments will be refreshed once you change your script code.

I dot-sourced my test script file and even confirmed that CustomObjectType exists via the Get-TypeData command.

Any ideas or suggestions on how to get around this issue?

Thanks!

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [November 21, 2016, 3:21pm UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561/2 "2016-11-21T15:21:46Z")

</div>

Well… it’s not so much an “issue,” I guess, as the way PowerShell works. [CustomObjectType] isn’t known to the shell, and assuming that all you’re doing is applying a custom type name to a PSObject, then there’s not really a stellar workaround. Because your type isn’t “in” .NET, then it doesn’t exist in the shell.

And here’s the thing - according to OOP principles, this _shouldn’t_ work. A type is meant to be a contract - a fixed interface. If you’re just applying a name to something, then you don’t have a declarative, actual _type_. Now, if you’re doing this with classes, that’s different.

---

<div class="post-metadata">

**Author:** ![gregt8](https://avatars.discourse-cdn.com/v4/letter/g/3bc359/32.png) [@gregt8](https://forums.powershell.org/u/gregt8)\
**Post date:** [November 21, 2016, 3:33pm UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561/3 "2016-11-21T15:33:12Z")

</div>

Thanks Don. That makes sense and gives me some direction to go from here. Appreciate the reply!

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [November 21, 2016, 3:35pm UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561/4 "2016-11-21T15:35:18Z")

</div>

One thing that comes to mind would be writing a test to check for the output object having the desired members - that way you could validate the structure that you expect?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:39pm UTC](https://forums.powershell.org/t/pester-unable-to-find-type/7561/5 "2024-05-16T20:39:52Z")

</div>

Closed on May 16, 2024, 8:39pm UTC


