@@ -182,4 +182,44 @@ export async function clearCommandPalette() {
182182 const buttons = await dialog . getButtons ( ) ;
183183 expect ( buttons . length ) . equals ( 2 ) ;
184184 await dialog . pushButton ( 'Clear' ) ;
185+ }
186+
187+ /**
188+ * Copies screenshots from the temporary VSCode screenshots directory to a permanent location
189+ * organized by build tool (maven or gradle).
190+ * @param buildTool The build tool name ('maven' or 'gradle') to organize screenshots
191+ */
192+ export function copyScreenshotsToProjectFolder ( buildTool : string ) : void {
193+ const VSBrowser = require ( 'vscode-extension-tester' ) . VSBrowser ;
194+ const sourcePath = VSBrowser . instance . getScreenshotsDir ( ) ;
195+ const destinationPath = path . join ( './screenshots' , buildTool ) ;
196+
197+ copyFolderContents ( sourcePath , destinationPath ) ;
198+ }
199+
200+ /**
201+ * Recursively copies all files from source folder to destination folder.
202+ * @param sourceFolder Source directory path
203+ * @param destinationFolder Destination directory path
204+ */
205+ function copyFolderContents ( sourceFolder : string , destinationFolder : string ) : void {
206+ if ( ! fs . existsSync ( sourceFolder ) ) {
207+ return ;
208+ }
209+
210+ if ( ! fs . existsSync ( destinationFolder ) ) {
211+ fs . mkdirSync ( destinationFolder , { recursive : true } ) ;
212+ }
213+
214+ const files = fs . readdirSync ( sourceFolder ) ;
215+ for ( const file of files ) {
216+ const sourcePath = path . join ( sourceFolder , file ) ;
217+ const destinationPath = path . join ( destinationFolder , file ) ;
218+
219+ if ( fs . statSync ( sourcePath ) . isDirectory ( ) ) {
220+ copyFolderContents ( sourcePath , destinationPath ) ;
221+ } else {
222+ fs . copyFileSync ( sourcePath , destinationPath ) ;
223+ }
224+ }
185225}
0 commit comments