-
To organize better the scripts and the relative tests, I created in my pipeline a simple structure: the scripts folder has all the scripts; then the tests folder contains the folder for each script and the necessary files. I have an issue in find the script from the test in the setup. For example, the code is Describe "Setup" {
BeforeAll {
. $PSCommandPath.Replace('.Tests.ps1', '.ps1') -flowJsonPath $flowJsonPath
}
} Also, I tried to write the setup like this Describe "Setup" {
BeforeAll {
$scriptName = [System.IO.Path]::GetFileName($PSCommandPath.Replace('.Tests.ps1', '.ps1'))
$scriptPath = Split-Path -Parent $PSCommandPath.Replace('.Tests.ps1', '.ps1')
$scriptPath = $scriptPath -replace "Tests\\JsonFiltering", ""
$script = [System.IO.Path]::Combine($scriptPath, $scriptName)
. $script -flowJsonPath $flowJsonPath -flowTycheJsonPath $flowTycheJsonPath -outputFilePath $outputFilePath
}
} but I still get an error
Is there a way to use a script in the parent directory? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
The variable |
Beta Was this translation helpful? Give feedback.
-
Thank you for answer. If it can be useful, here the code $scriptRoot = "$PSScriptRoot/../../"
$filename = (Split-Path $PSCommandPath -Leaf).Replace('.Tests.ps1', '.ps1')
$scriptToTest = [System.IO.Path]::Combine($scriptRoot, $filename) |
Beta Was this translation helpful? Give feedback.
The variable
$PSScriptRoot
. So. $PSScriptRoot/../JsonFiltering.ps1
.