Skip to content

Commit b692430

Browse files
committed
chore: update code styling
1 parent 4764473 commit b692430

8 files changed

Lines changed: 73 additions & 72 deletions

File tree

packages/vscode-wdio-test/src/manager.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export class RepositoryManager implements IRepositoryManager {
2828
private _workspaceTestItems: vscode.TestItem[] = []
2929
private _wdioConfigTestItems: vscode.TestItem[] = []
3030
private _isInitialized = false
31-
private isCreatedDefaultProfile = false
31+
private _isCreatedDefaultProfile = false
3232

3333
constructor(
3434
public readonly controller: vscode.TestController,
3535
public readonly configManager: ExtensionConfigManager,
36-
private readonly workerManager: IWorkerManager,
36+
private readonly _workerManager: IWorkerManager,
3737
private readonly _metadata = new MetadataRepository()
3838
) {
3939
this._loadingTestItem = this.controller.createTestItem(LOADING_TEST_ITEM_ID, 'Resolving WebdriverIO Tests...')
@@ -56,7 +56,7 @@ export class RepositoryManager implements IRepositoryManager {
5656
.then(async () => await this.initialize())
5757
.then(async () => await Promise.all(this.repos.map(async (repo) => await repo.discoverAllTests())))
5858
.then(() => this.registerToTestController())
59-
.then(() => this.workerManager.reorganize(configManager.getWdioConfigPaths()))
59+
.then(() => this._workerManager.reorganize(configManager.getWdioConfigPaths()))
6060
})
6161
}
6262

@@ -86,11 +86,11 @@ export class RepositoryManager implements IRepositoryManager {
8686

8787
this._workspaceTestItems = await Promise.all(
8888
workspaces.map(async (workspace) => {
89-
const workspaceTestItem = this.createWorkspaceTestItem(workspace.workspaceFolder)
89+
const workspaceTestItem = this._createWorkspaceTestItem(workspace.workspaceFolder)
9090
for (const wdioConfigFile of workspace.wdioConfigFiles) {
91-
await this.createWdioConfigTestItem(workspace.workspaceFolder, workspaceTestItem, wdioConfigFile)
91+
await this._createWdioConfigTestItem(workspace.workspaceFolder, workspaceTestItem, wdioConfigFile)
9292

93-
this.isCreatedDefaultProfile = true
93+
this._isCreatedDefaultProfile = true
9494
}
9595
return workspaceTestItem
9696
})
@@ -104,7 +104,7 @@ export class RepositoryManager implements IRepositoryManager {
104104
return item.uri?.fsPath === workspaceFolder.uri.fsPath
105105
})
106106
for (const workspaceTestItem of affectedWorkspaceItems) {
107-
const configTestItem = await this.createWdioConfigTestItem(
107+
const configTestItem = await this._createWdioConfigTestItem(
108108
workspaceFolder,
109109
workspaceTestItem,
110110
wdioConfigPath
@@ -125,7 +125,7 @@ export class RepositoryManager implements IRepositoryManager {
125125
log.debug(`Remove the config file from ${affectedWorkspaceItems.length} workspace(s)`)
126126
const configUri = convertPathToUri(wdioConfigPath)
127127
for (const workspaceItem of affectedWorkspaceItems) {
128-
const config = workspaceItem.children.get(this.generateConfigTestItemId(workspaceItem, configUri))
128+
const config = workspaceItem.children.get(this._generateConfigTestItemId(workspaceItem, configUri))
129129
if (!config) {
130130
continue
131131
}
@@ -141,7 +141,7 @@ export class RepositoryManager implements IRepositoryManager {
141141
this.controller.items.delete(workspaceItem.id)
142142
}
143143
} else {
144-
const targetId = this.generateConfigTestItemId(workspaceItem, configUri)
144+
const targetId = this._generateConfigTestItemId(workspaceItem, configUri)
145145
log.debug(`Remove Configuration from the controller: ${targetId}`)
146146
this.controller.items.delete(targetId)
147147
}
@@ -162,7 +162,7 @@ export class RepositoryManager implements IRepositoryManager {
162162
log.debug('Successfully registered.')
163163
}
164164

165-
private createWorkspaceTestItem(workspaceFolder: vscode.WorkspaceFolder) {
165+
private _createWorkspaceTestItem(workspaceFolder: vscode.WorkspaceFolder) {
166166
const workspaceItem = this.controller.createTestItem(
167167
`workspace:${workspaceFolder.uri.fsPath}`,
168168
workspaceFolder.name,
@@ -172,14 +172,14 @@ export class RepositoryManager implements IRepositoryManager {
172172
return workspaceItem
173173
}
174174

175-
private async createWdioConfigTestItem(
175+
private async _createWdioConfigTestItem(
176176
workspaceFolder: vscode.WorkspaceFolder,
177177
workspaceTestItem: vscode.TestItem,
178178
wdioConfigPath: string
179179
) {
180180
const uri = convertPathToUri(wdioConfigPath)
181181
const configItem = this.controller.createTestItem(
182-
this.generateConfigTestItemId(workspaceTestItem, uri),
182+
this._generateConfigTestItemId(workspaceTestItem, uri),
183183
basename(wdioConfigPath),
184184
uri
185185
)
@@ -192,20 +192,20 @@ export class RepositoryManager implements IRepositoryManager {
192192
this.controller,
193193
wdioConfigPath,
194194
configItem,
195-
this.workerManager,
195+
this._workerManager,
196196
workspaceFolder
197197
)
198198
this._repos.add(repository)
199199

200200
configItem.description = relative(workspaceTestItem.uri!.fsPath, dirname(wdioConfigPath))
201201

202-
const runProfiles = createRunProfile.call(this, configItem, !this.isCreatedDefaultProfile)
202+
const runProfiles = createRunProfile.call(this, configItem, !this._isCreatedDefaultProfile)
203203

204204
this._metadata.createWdioConfigFileMetadata(configItem, { uri, repository, runProfiles })
205205
return configItem
206206
}
207207

208-
private generateConfigTestItemId(workspaceTestItem: vscode.TestItem, configUri: vscode.Uri) {
208+
private _generateConfigTestItemId(workspaceTestItem: vscode.TestItem, configUri: vscode.Uri) {
209209
return [workspaceTestItem.id, `config:${configUri.fsPath}`].join(TEST_ID_SEPARATOR)
210210
}
211211

@@ -225,7 +225,7 @@ export class RepositoryManager implements IRepositoryManager {
225225
)
226226

227227
this.registerToTestController()
228-
await this.workerManager.reorganize(this.configManager.getWdioConfigPaths())
228+
await this._workerManager.reorganize(this.configManager.getWdioConfigPaths())
229229
} catch (error) {
230230
this.controller.items.replace([])
231231
const errorMessage = error instanceof Error ? error.message : String(error)

packages/vscode-wdio-test/src/metadata.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import type { ITestRepository, TestItemMetadata, TestType } from '@vscode-wdio/t
22
import type * as vscode from 'vscode'
33

44
export class MetadataRepository {
5-
private static testMetadataRepository = new WeakMap<vscode.TestItem, TestItemMetadata>()
5+
private static _testMetadataRepository = new WeakMap<vscode.TestItem, TestItemMetadata>()
6+
67
public getMetadata(testItem: vscode.TestItem) {
7-
const metadata = MetadataRepository.testMetadataRepository.get(testItem)
8+
const metadata = MetadataRepository._testMetadataRepository.get(testItem)
89
if (!metadata) {
910
throw new Error("The metadata for TestItem is not set. This is extension's bug.")
1011
}
@@ -20,7 +21,7 @@ export class MetadataRepository {
2021
}
2122

2223
protected setMetadata(testItem: vscode.TestItem, metadata: TestItemMetadata) {
23-
MetadataRepository.testMetadataRepository.set(testItem, metadata)
24+
MetadataRepository._testMetadataRepository.set(testItem, metadata)
2425
}
2526

2627
public createTestMetadata(

packages/vscode-wdio-test/src/reporter.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export class TestReporter {
4848

4949
// Process suites in this spec file
5050
for (const suite of result.suites) {
51-
this.processHierarchicalSuite(suite, specTestItem)
51+
this._processHierarchicalSuite(suite, specTestItem)
5252
}
5353

5454
// Update spec file status based on overall result status
55-
this.updateSpecFileStatus(specTestItem, result)
55+
this._updateSpecFileStatus(specTestItem, result)
5656
}
5757

5858
// Check if any test failed
@@ -74,7 +74,7 @@ export class TestReporter {
7474
* @param suite The suite result from WebdriverIO with potential nested suites
7575
* @param parentItem The parent TestItem (spec file or parent suite)
7676
*/
77-
private processHierarchicalSuite(suite: TestSuite, parentItem: vscode.TestItem): void {
77+
private _processHierarchicalSuite(suite: TestSuite, parentItem: vscode.TestItem): void {
7878
// Find the suite TestItem in the repository
7979
let suiteItem: vscode.TestItem | undefined
8080

@@ -91,26 +91,26 @@ export class TestReporter {
9191

9292
// Process tests in this suite
9393
for (const test of suite.tests) {
94-
this.processTest(test, suiteItem)
94+
this._processTest(test, suiteItem)
9595
}
9696

9797
// Process nested suites if any
9898
if (suite.suites && suite.suites.length > 0) {
9999
for (const nestedSuite of suite.suites) {
100-
this.processHierarchicalSuite(nestedSuite, suiteItem)
100+
this._processHierarchicalSuite(nestedSuite, suiteItem)
101101
}
102102
}
103103

104104
// Set suite status based on its tests
105-
this.updateSuiteStatus(suiteItem, suite)
105+
this._updateSuiteStatus(suiteItem, suite)
106106
}
107107

108108
/**
109109
* Process a test and update its status
110110
* @param test The test result from WebdriverIO
111111
* @param suiteItem The parent suite TestItem
112112
*/
113-
private processTest(test: Test, suiteItem: vscode.TestItem): void {
113+
private _processTest(test: Test, suiteItem: vscode.TestItem): void {
114114
// Find the test item in the children of the suite item
115115
let testItem: vscode.TestItem | undefined
116116

@@ -148,7 +148,7 @@ export class TestReporter {
148148
* @param suiteItem The suite TestItem
149149
* @param suiteResult The suite result from WebdriverIO
150150
*/
151-
private updateSuiteStatus(suiteItem: vscode.TestItem, suiteResult: TestSuite): void {
151+
private _updateSuiteStatus(suiteItem: vscode.TestItem, suiteResult: TestSuite): void {
152152
const hasFailedTests = suiteResult.tests.some((test) => test.state === 'failed')
153153

154154
if (hasFailedTests || suiteResult.tests.length > 0) {
@@ -168,7 +168,7 @@ export class TestReporter {
168168
* @param specItem The spec file TestItem
169169
* @param result The WebdriverIO result for this spec file
170170
*/
171-
private updateSpecFileStatus(specItem: vscode.TestItem, result: ResultSet): void {
171+
private _updateSpecFileStatus(specItem: vscode.TestItem, result: ResultSet): void {
172172
if (result.state.failed > 0) {
173173
const message = new vscode.TestMessage(
174174
`${result.state.failed} tests failed out of ${result.state.passed + result.state.failed + result.state.skipped}`

packages/vscode-wdio-test/src/repository.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
6868
return this._framework
6969
}
7070

71-
private async getEnvOptions() {
71+
private async _getEnvOptions() {
7272
return await getEnvOptions(this.configManager, this._workspaceFolder)
7373
}
7474

@@ -79,7 +79,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
7979
try {
8080
const worker = await this.getWorker()
8181
const config = await worker.rpc.loadWdioConfig({
82-
env: await this.getEnvOptions(),
82+
env: await this._getEnvOptions(),
8383
configFilePath: this.wdioConfigPath,
8484
})
8585

@@ -95,7 +95,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
9595
this._specPatterns = config.specPatterns
9696

9797
// Get specs from configuration
98-
const allSpecs = this.convertPathString(config.specs)
98+
const allSpecs = this._convertPathString(config.specs)
9999

100100
if (allSpecs.length < 1) {
101101
log.debug('No spec files found in configuration')
@@ -105,7 +105,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
105105
log.debug(`Discovered ${allSpecs.length} spec files`)
106106

107107
// Register all specs
108-
return await this.resisterSpecs(allSpecs)
108+
return await this._resisterSpecs(allSpecs)
109109
} catch (error) {
110110
log.error(`Failed to discover tests: ${(error as Error).message}`)
111111
log.trace(`Failed to discover tests: ${(error as Error).stack}`)
@@ -120,7 +120,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
120120
try {
121121
const worker = await this.getWorker()
122122
const config = await worker.rpc.loadWdioConfig({
123-
env: await this.getEnvOptions(),
123+
env: await this._getEnvOptions(),
124124
configFilePath: this.wdioConfigPath,
125125
})
126126
if (!config) {
@@ -131,10 +131,10 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
131131
this._specPatterns = config.specPatterns
132132

133133
// Get specs from configuration
134-
const allConfigSpecs = this.convertPathString(config.specs)
134+
const allConfigSpecs = this._convertPathString(config.specs)
135135
if (!filePaths || filePaths.length === 0) {
136136
for (const [fileId] of this._fileMap.entries()) {
137-
this.removeSpecFileById(fileId)
137+
this._removeSpecFileById(fileId)
138138
}
139139
}
140140
// Filter specs to only include those that match the provided file paths
@@ -158,7 +158,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
158158
}
159159
}
160160
// Register the updated spec files
161-
await this.resisterSpecs(specsToReload, false)
161+
await this._resisterSpecs(specsToReload, false)
162162

163163
log.debug(`Successfully reloaded ${specsToReload.length} spec files`)
164164
} catch (error) {
@@ -178,7 +178,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
178178
}
179179
}
180180

181-
private getTestFileId(wdioConfigTestItem: vscode.TestItem, testFilePath: string) {
181+
private _getTestFileId(wdioConfigTestItem: vscode.TestItem, testFilePath: string) {
182182
return [wdioConfigTestItem.id, testFilePath].join(TEST_ID_SEPARATOR)
183183
}
184184

@@ -187,14 +187,14 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
187187
* @param specs Paths to spec files
188188
* @param replaceAllSpecFiles if all spec files to resister, this parameter must be true
189189
*/
190-
private async resisterSpecs(specs: string[], replaceAllSpecFiles: boolean = true) {
190+
private async _resisterSpecs(specs: string[], replaceAllSpecFiles: boolean = true) {
191191
if (replaceAllSpecFiles) {
192192
this._fileMap.clear()
193193
}
194194
log.debug(`Spec files registration is started for: ${specs.length} files.`)
195195
const worker = await this.getWorker()
196196
const testData = await worker.rpc.readSpecs({
197-
env: await this.getEnvOptions(),
197+
env: await this._getEnvOptions(),
198198
specs,
199199
})
200200

@@ -203,11 +203,11 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
203203
testData.map(async (test) => {
204204
try {
205205
// Create TestItem testFile by testFile
206-
const fileId = this.getTestFileId(this._wdioConfigTestItem, test.spec)
206+
const fileId = this._getTestFileId(this._wdioConfigTestItem, test.spec)
207207

208208
const specFileUri = vscode.Uri.file(test.spec)
209209

210-
const fileTestItem = this.resisterSpecFile(fileId, specFileUri)
210+
const fileTestItem = this._resisterSpecFile(fileId, specFileUri)
211211
for (const testCase of test.tests) {
212212
fileTestItem.children.add(
213213
testTreeCreator(this, this._metadata, fileId, testCase, specFileUri)
@@ -241,11 +241,11 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
241241
*/
242242
public removeSpecFile(specPath: string): void {
243243
const normalizedPath = normalizePath(specPath)
244-
const fileId = this.getTestFileId(this._wdioConfigTestItem, normalizedPath)
245-
this.removeSpecFileById(fileId, specPath)
244+
const fileId = this._getTestFileId(this._wdioConfigTestItem, normalizedPath)
245+
this._removeSpecFileById(fileId, specPath)
246246
}
247247

248-
private removeSpecFileById(fileId: string, _specPath?: string): void {
248+
private _removeSpecFileById(fileId: string, _specPath?: string): void {
249249
const specPath = _specPath ? _specPath : fileId.split(TEST_ID_SEPARATOR)[2]
250250
// Get the TestItem for this spec file
251251
const fileItem = this._fileMap.get(fileId)
@@ -266,7 +266,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
266266
/**
267267
* Convert spec paths from WebdriverIO config to file system paths
268268
*/
269-
private convertPathString(specs: (string | string[])[]) {
269+
private _convertPathString(specs: (string | string[])[]) {
270270
return specs.flatMap((spec) => (Array.isArray(spec) ? spec.map((path) => path) : [spec]))
271271
}
272272

@@ -276,7 +276,7 @@ export class TestRepository extends WorkerMiddleware implements ITestRepository
276276
* @param uri Spec file URI
277277
* @returns TestItem for the spec file
278278
*/
279-
private resisterSpecFile(id: string, uri: vscode.Uri) {
279+
private _resisterSpecFile(id: string, uri: vscode.Uri) {
280280
log.trace(`[repository] spec file was registered: ${id}`)
281281
const fileTestItem = this.controller.createTestItem(id, path.basename(uri.fsPath), uri)
282282
fileTestItem.sortText = uri.fsPath

packages/vscode-wdio-test/src/runHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import type { IExtensionConfigManager } from '@vscode-wdio/types/config'
1111
import type { RepositoryManager } from './manager.js'
1212

1313
class TestQueue {
14-
private queue: vscode.TestItem[] = []
14+
private _queue: vscode.TestItem[] = []
1515

1616
push(item: vscode.TestItem) {
17-
this.queue.push(item)
17+
this._queue.push(item)
1818
}
1919

20-
forEach(cb: Parameters<typeof this.queue.forEach>[0]) {
21-
this.queue.forEach(cb)
20+
forEach(cb: Parameters<typeof this._queue.forEach>[0]) {
21+
this._queue.forEach(cb)
2222
}
2323

2424
[Symbol.iterator]() {
25-
return this.queue[Symbol.iterator]()
25+
return this._queue[Symbol.iterator]()
2626
}
2727
}
2828

0 commit comments

Comments
 (0)