Skip to content

Comments

feat(invokeCommand.mock): Add invoke tracing#44

Merged
rulasg merged 2 commits intomainfrom
trace-invoke-mock
Oct 13, 2025
Merged

feat(invokeCommand.mock): Add invoke tracing#44
rulasg merged 2 commits intomainfrom
trace-invoke-mock

Conversation

@rulasg
Copy link
Owner

@rulasg rulasg commented Oct 13, 2025

Allowm tracing all the mock invokes during test.
This will allow to know the dependecies the test has
This will allow to refresh mock data from live environment

  • feat(invokeCommand.mock): add tracing mock invokes
  • feat(invokeCommand.mock): Add invoke tracing


function Test_TraceInvokeCOmmandAlias{


Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$fileName = "traceInvoke.log"
Assert-ItemNotExist -Path $fileName

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$fileName = "traceInvoke.log"
Assert-ItemNotExist -Path $fileName

# Set flag

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$fileNamePath = $fileName | Resolve-Path
$env:TraceInvokeMockFilePath = $fileNamePath
Assert-ItemExist -Path $fileNamePath

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# Act record invoke alias
Set-InvokeCommandMock -alias "fakeAlias1" -Command 'echo "hello from fakeAlias1"'
Set-InvokeCommandMock -alias "fakeAlias2" -Command 'echo "hello from fakeAlias2"'

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Assert-Count -Expected 2 -Presented $content
Assert-Contains -Presented $content -Expected 'fakeAlias1'
Assert-Contains -Presented $content -Expected 'fakeAlias2'

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Set-InvokeCommandMock -alias "fakeAlias1" -Command 'echo "hello from fakeAlias1"'
$content = Get-Content $fileNamePath
Assert-Count -Expected 2 -Presented $content

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
@rulasg rulasg merged commit 20eaf8e into main Oct 13, 2025
3 checks passed
@rulasg rulasg deleted the trace-invoke-mock branch October 13, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant