@@ -10,71 +10,12 @@ import * as fs from 'fs';
1010import * as os from 'os' ;
1111import * as vscodetest from '@vscode/test-electron' ;
1212import { createApp , retry } from './utils' ;
13- import * as minimist from 'minimist ' ;
13+ import { opts } from './options ' ;
1414
1515const rootPath = path . join ( __dirname , '..' , '..' , '..' ) ;
16-
17- const [ , , ...args ] = process . argv ;
18- const opts = minimist ( args , {
19- string : [
20- 'browser' ,
21- 'build' ,
22- 'stable-build' ,
23- 'wait-time' ,
24- 'test-repo' ,
25- 'electronArgs'
26- ] ,
27- boolean : [
28- 'verbose' ,
29- 'remote' ,
30- 'web' ,
31- 'headless' ,
32- 'tracing'
33- ] ,
34- default : {
35- verbose : false
36- }
37- } ) as {
38- verbose ?: boolean ;
39- remote ?: boolean ;
40- headless ?: boolean ;
41- web ?: boolean ;
42- tracing ?: boolean ;
43- build ?: string ;
44- 'stable-build' ?: string ;
45- browser ?: 'chromium' | 'webkit' | 'firefox' | 'chromium-msedge' | 'chromium-chrome' | undefined ;
46- electronArgs ?: string ;
47- } ;
48-
49- const logsRootPath = ( ( ) => {
50- const logsParentPath = path . join ( rootPath , '.build' , 'logs' ) ;
51-
52- let logsName : string ;
53- if ( opts . web ) {
54- logsName = 'smoke-tests-browser' ;
55- } else if ( opts . remote ) {
56- logsName = 'smoke-tests-remote' ;
57- } else {
58- logsName = 'smoke-tests-electron' ;
59- }
60-
61- return path . join ( logsParentPath , logsName ) ;
62- } ) ( ) ;
63-
64- const crashesRootPath = ( ( ) => {
65- const crashesParentPath = path . join ( rootPath , '.build' , 'crashes' ) ;
66-
67- let crashesName : string ;
68- if ( opts . web ) {
69- crashesName = 'smoke-tests-browser' ;
70- } else if ( opts . remote ) {
71- crashesName = 'smoke-tests-remote' ;
72- } else {
73- crashesName = 'smoke-tests-electron' ;
74- }
75-
76- return path . join ( crashesParentPath , crashesName ) ;
77- } ) ( ) ;
16+ const logsRootPath = path . join ( rootPath , '.build' , 'vscode-playwright-mcp' , 'logs' ) ;
17+ const crashesRootPath = path . join ( rootPath , '.build' , 'vscode-playwright-mcp' , 'crashes' ) ;
18+ const videoRootPath = path . join ( rootPath , '.build' , 'vscode-playwright-mcp' , 'videos' ) ;
7819
7920const logger = createLogger ( ) ;
8021
@@ -291,7 +232,7 @@ async function setup(): Promise<void> {
291232 logger . log ( 'Smoketest setup done!\n' ) ;
292233}
293234
294- export async function getApplication ( ) {
235+ export async function getApplication ( { recordVideo } : { recordVideo ?: boolean } = { } ) {
295236 const testCodePath = getDevElectronPath ( ) ;
296237 const electronPath = testCodePath ;
297238 if ( ! fs . existsSync ( electronPath || '' ) ) {
@@ -315,6 +256,7 @@ export async function getApplication() {
315256 logger,
316257 logsPath : path . join ( logsRootPath , 'suite_unknown' ) ,
317258 crashesPath : path . join ( crashesRootPath , 'suite_unknown' ) ,
259+ videosPath : ( recordVideo || opts . video ) ? videoRootPath : undefined ,
318260 verbose : opts . verbose ,
319261 remote : opts . remote ,
320262 web : opts . web ,
@@ -350,12 +292,12 @@ export class ApplicationService {
350292 return this . _application ;
351293 }
352294
353- async getOrCreateApplication ( ) : Promise < Application > {
295+ async getOrCreateApplication ( { recordVideo } : { recordVideo ?: boolean } = { } ) : Promise < Application > {
354296 if ( this . _closing ) {
355297 await this . _closing ;
356298 }
357299 if ( ! this . _application ) {
358- this . _application = await getApplication ( ) ;
300+ this . _application = await getApplication ( { recordVideo } ) ;
359301 this . _application . code . driver . currentPage . on ( 'close' , ( ) => {
360302 this . _closing = ( async ( ) => {
361303 if ( this . _application ) {
0 commit comments