@@ -3,6 +3,7 @@ import url from 'node:url'
33
44import { browser , expect } from '@wdio/globals'
55import shell from 'shelljs'
6+ import { sleep , type SideBarView , type Workbench } from 'wdio-vscode-service'
67
78import {
89 STATUS ,
@@ -15,8 +16,6 @@ import {
1516 waitForTestStatus ,
1617} from '../helpers/index.js'
1718
18- import type { SideBarView , Workbench } from 'wdio-vscode-service'
19-
2019const __dirname = path . dirname ( url . fileURLToPath ( import . meta. url ) )
2120const rootDir = path . resolve ( __dirname , '..' , '..' )
2221const workspacePath = path . resolve ( rootDir , 'samples/smoke/update-config/' )
@@ -85,20 +84,24 @@ describe('VS Code Extension Testing (Update config)', function () {
8584
8685 // Emulate the changing configuration
8786 shell . cp ( '-f' , afterConfig , beforeConfig )
88- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
87+ await sleep ( 1500 )
8988 await browser . waitUntil (
9089 async ( ) => {
91- if ( ! ( await items [ 0 ] . isExpanded ( ) ) ) {
92- await items [ 0 ] . expand ( )
93- }
94-
95- const children = await items [ 0 ] . getChildren ( )
96- const target = children [ 0 ]
97- if ( ! target ) {
90+ try {
91+ if ( ! ( await items [ 0 ] . isExpanded ( ) ) ) {
92+ await items [ 0 ] . expand ( )
93+ }
94+
95+ const children = await items [ 0 ] . getChildren ( )
96+ const target = children [ 0 ]
97+ if ( ! target ) {
98+ return false
99+ }
100+ const regex = new RegExp ( 'after.test.ts' )
101+ return regex . test ( await target . getLabel ( ) )
102+ } catch {
98103 return false
99104 }
100- const regex = new RegExp ( 'after.test.ts' )
101- return regex . test ( await target . getLabel ( ) )
102105 } ,
103106 { timeoutMsg : 'The label "after.test.ts" is not found.' }
104107 )
0 commit comments