-
-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get Pester to see custom Should operators? #590
Comments
Just put your function into a PS1 file in the Pester\Functions\Assertions directory, and reload the module. Should be all set. :) |
Ah, but this for an OSS project... Is there a way to source Pester not from On Fri, Aug 12, 2016, 12:31 Dave Wyatt [email protected] wrote:
|
It probably depends on where you've defined those functions. Unless they're in the global scope, Pester's calls to Get-Command aren't going to find them. (The way that However, for now, you can inject your functions into Pester's scope after loading the module and it should work: $pesterModule = Import-Module Pester -PassThru
. $pesterModule {
function PesterBeDate { }
# etc
} Edit: I'm not 100% certain whether you need to use the |
Thanks, I did end up sourcing a local module for better out of the box On Mon, Aug 15, 2016, 20:24 Dave Wyatt [email protected] wrote:
|
Here's an example of what I did for future reference: https://github.com/kamranayub/posh-openweathermap/blob/afe931f979dd675c279eecd89028f3fe7c4a5893/Run-Tests.ps1 |
Hey guys, is there any information about how these have changed in v4? Ive been unsuccesful in located instructions on how to do custom Should extensions in the new version? |
Didn't write instructions yet, will get to that this weekend. However, you can look at https://github.com/pester/Pester/blob/master/Functions/Assertions/Be.ps1 for guidance. Three main changes:
The names of your functions don't matter anymore. You can add aliases for your operator with the |
Actually, Be.ps1 is probably one of the more complex files. Here's a simple one: https://github.com/pester/Pester/blob/master/Functions/Assertions/BeGreaterThan.ps1 |
Thanks for the info @dlwyatt It doesn't seem like
|
That's correct, though there's a PR open right now to change that. |
I've just installed 4.0.4 to try to update a couple of libraries with custom assertions and am hitting this issue. I can't see |
#765 merged need to release new version |
Thanks @nohwnd. Do you have any idea of timelines for a new release now that this is merged? |
@stuartleeks , please read #793. |
Thanks @it-praktyk, I read through #793 when I was trying to track down my issue. I guess the questions I was really asking is whether there will be a release ahead of a final v4 release (as there still seems to be a list of issues before then) :-) |
@stuartleeks it's released as 4.0.5. Closing this issue, feel free to reopen if you need more help. |
Awesome, thanks @nohwnd ! |
I must be missing something simple because I feel really close.
I have defined a new
PesterBeDate
function and failure functions. According to what I see in the Should assertion source, it should be able to find my command. In fact if I run:I see the command output. But for some reason Pester doesn't:
The text was updated successfully, but these errors were encountered: