ConvertFrom-JSON: Cannot bind argument to parameter 'InputObject' because it is null

Hello, can anyone tell me what I am doing wrong here?
Here’s a script I want to test using Pester (e.g. run3.ps1):

using namespace System.Net
param($Subscription)

$ok = $true
$errorMsg = ""
$status = "In Progress"
Write-Host "Function: myFunction. Applying tags.."
Write-Host $Subscription

$CreationState = $Subscription.CreationState | ConvertFrom-Json 

if ($CreationState.Tags -eq "Complete") {

    Write-Host "Tags are already applied."
    return @{
        OK               = $ok
        Status           = $status
        SubscriptionInfo = $Subscription    
    }
}

And here’s my Pester unit test (e.g. run3.Tests.ps1):

BeforeAll {
    . $PSScriptRoot/run3.ps1
}
Describe 'run-orig.ps1' {
    It 'Tags are applied' {

        $tags = [pscustomobject]@{
            Tags = "Complete"
        }
        $tagsJson = $tags | ConvertTo-Json

        $value = [pscustomobject]@{
            Status = 'Active'

        }
        $value | Add-Member -MemberType NoteProperty  -Name CreationState -Value $tagsJson

        $res = . $PSScriptRoot/run3.ps1 -Subscription $value
        $res | Should -BeOfType [System.Collections.Hashtable]

    }
}

When I execute my pester tests, this is the error message I receive. Error is on ConvertFrom-Json on line #10 and error message is Cannot bind argument to parameter ‘InputObject’ because it is null.
I would greatly appreciate any help on this. Thank you!

Pester v5.3.3

Starting discovery in 1 files.
Discovery found 1 tests in 5ms.
Running tests.

Running tests from '/Users/dfdf/Downloads/azfunc/HelloWorldProj/HttpExample/run3.Tests.ps1'
Function: myFunction. Applying tags..

ConvertFrom-Json: /Users/dfdf/Downloads/azfunc/HelloWorldProj/HttpExample/run3.ps1:10:48
Line |
  10 |  $CreationState = $Subscription.CreationState | ConvertFrom-Json
     |                                                 ~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

Describing run-orig.ps1
Function: myFunction. Applying tags..
@{Status=Active; CreationState={
  "Tags": "Complete"
}}
  [-] Tags are applied 6ms (6ms|1ms)
   Expected the value to have type [hashtable] or any of its subtypes, but got @{Tags=Complete} with type [PSCustomObject].
   at $res | Should -BeOfType [System.Collections.Hashtable], /Users/jink/Downloads/azfunc/HelloWorldProj/HttpExample/run3.Tests.ps1:19
   at <ScriptBlock>, /Users/dfdf/Downloads/azfunc/HelloWorldProj/HttpExample/run3.Tests.ps1:19
Tests completed in 36ms
Tests Passed: 0, Failed: 1, Skipped: 0 NotRun: 0

The problem occurs because you’re dot sourcing your script.

Consider using [CmdletBinding()] and then checking if the parameter has been passed:

using namespace System.Net
[CmdletBinding()]
param($Subscription)

$ok = $true
$errorMsg = ""
$status = "In Progress"
Write-Host "Function: myFunction. Applying tags.."
Write-Host $Subscription

if ($PSBoundParameters.Subscription) {
    $CreationState = $Subscription.CreationState | ConvertFrom-Json
}

if ($CreationState.Tags -eq "Complete") {

    Write-Host "Tags are already applied."
    return @{
        OK               = $ok
        Status           = $status
        SubscriptionInfo = $Subscription    
    }
}