Skip to content

Commit d2e89dd

Browse files
authored
🪳Dont reference getter in method initialization (#187)
1 parent 4d4982c commit d2e89dd

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

Scripts/PesterInterface.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Describe 'PesterInterface' {
1616
It 'Basic.Tests Discovery' {
1717
$paths = "$testDataPath/Tests/Basic.Tests.ps1"
1818
& $PesterInterface -Path $paths -Discovery -PipeName $PipeOutPath -DryRun 6>$null
19-
Get-Content $PipeOutPath | ConvertFrom-Json | ForEach-Object label | Should -HaveCount 61
19+
Get-Content $PipeOutPath | ConvertFrom-Json | ForEach-Object label | Should -HaveCount 58
2020
}
2121
It 'Simple Test Run' {
2222
$paths = "$testDataPath/Tests/True.Tests.ps1"

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@
5858
},
5959
"pester.configurationPath": {
6060
"type": "string",
61-
"markdownDescription": "Specifies the path to a custom Pester configuration in `.psd1` format. This is useful if you want to use a custom configuration file, or if you want to use a configuration file that is not named `PesterConfiguration.psd1`. If this is not set then the runner will look for a file named `PesterConfiguration.psd1` at the root of the workspace folder. This is best specified as a workspace setting and not a user setting. You may also provide a configuration via a `$PesterPreference` variable in your running session, this will apply for debug runs only."
61+
"markdownDescription": "Specifies the path to a custom Pester configuration in `.psd1` format. This is useful if you want to use a custom configuration file, or if you want to use a configuration file that is not named `PesterConfiguration.psd1`. If this is not set then the runner will look for a file named `PesterConfiguration.psd1` at the root of the workspace folder. This is best specified as a workspace setting and not a user setting. You may also provide a configuration via a `$PesterPrefer ence` variable in your running session, this will apply for debug runs only."
62+
},
63+
"pester.testChangeTimeout": {
64+
"type": "integer",
65+
"default": 100,
66+
"markdownDescription": "Specifies the timeout in milliseconds that the test adapter waits for changes to be detected before running the test. You may need to increase this value if you are on a slower computer and are getting duplicate runs after making changes or starting up the test adapter."
6267
}
6368
}
6469
}

src/pesterTestController.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,17 @@ export class PesterTestController implements Disposable {
391391

392392
if (testItem !== undefined) {
393393
const newTestItemData = testDef
394-
const existingTestItemData = TestData.get(testItem)
394+
const existingTestItemData = TestData.get(testItem) as TestDefinition
395+
396+
if (existingTestItemData === undefined) {
397+
this.log.fatal(
398+
`Test Item ${testDef.label} exists but does not have test data. This is a bug and should not happen`
399+
)
400+
throw new Error(
401+
`Test Item ${testDef.label} exists but does not have test data. This is a bug and should not happen`
402+
)
403+
}
404+
395405
if (isDeepStrictEqual(existingTestItemData, newTestItemData)) {
396406
this.log.trace(`Discovery: Test Exists but has not changed. Skipping: ${testDef.id}`)
397407
return
@@ -476,7 +486,7 @@ export class PesterTestController implements Disposable {
476486
}
477487
this.discoveryQueue.clear()
478488
return result
479-
}, 300)
489+
}, workspace.getConfiguration('pester', this.workspaceFolder).get<number>('testChangeTimeout') ?? 100)
480490

481491
/** The test controller API calls this when tests are requested to run in the UI. It handles both runs and debugging.
482492
* @param cancelToken The cancellation token passed by VSCode
@@ -736,7 +746,7 @@ export class PesterTestController implements Disposable {
736746
scriptArgs.push(pesterCustomModulePath)
737747
}
738748

739-
const configurationPath = workspace.getConfiguration('pester', this.workspaceFolder).get<string>('configurationPath')
749+
const configurationPath = this.config.get<string>('configurationPath')
740750
if (configurationPath !== undefined && configurationPath !== '') {
741751
scriptArgs.push('-ConfigurationPath')
742752
scriptArgs.push(configurationPath)

0 commit comments

Comments
 (0)