Skip to content

Unable to mock function called within DSC Class based Resource #1822

Open
@MarkDordoy

Description

@MarkDordoy

General summary of the issue

Hello, im writing a DSC class based module. Within the PSM1 file, but outside the class definition i have defined a function. Im trying to mock that function and simply return a pre-defined string, however the mock is ignored. Ive spoken with Dave Wyatt recently and he said this was always a tricky issue to solve due to the way DSC Class methods exist in a dynamic module that gets built behind the scenes and not as you would expect. Im wondering if Pester version 5 goes anyway to solve this issue and allow a way to mock?

Describe your environment

Im currently using Powershell version 5.1 with pester version 4.10.1

Im currently running a windows docker container, that call's invoke-pester which finds a tests.ps1 script that defines a DSC config, declares the mock of the function required, then runs start-dscconfiguration inside the it block.

Im happy to add more detail to this ticket if you think there is a way to solve this.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions