@@ -33,7 +33,6 @@ import { ansi2html } from './ansi2html';
3333import { LocatorsView } from './locatorsView' ;
3434import { pathToFileURL } from 'url' ;
3535import { TestConfig } from './playwrightTestServer' ;
36- import { findTestEndPosition } from './babelHighlightUtil' ;
3736
3837const stackUtils = new StackUtils ( {
3938 cwd : '/ensure_absolute_paths'
@@ -60,20 +59,14 @@ export class Extension implements RunHooks {
6059
6160 private _testController : vscodeTypes . TestController ;
6261 private _workspaceObserver : WorkspaceObserver ;
63- private _testUnderDebug : {
64- testItem : vscodeTypes . TestItem | undefined ;
65- testCase : reporterTypes . TestCase ;
66- disposables : vscodeTypes . Disposable [ ] ;
67- } | undefined ;
62+ private _testItemUnderDebug : vscodeTypes . TestItem | undefined ;
6863 private _lastBeganTest ?: reporterTypes . TestCase ;
6964 private _activeSteps = new Map < reporterTypes . TestStep , StepInfo > ( ) ;
7065 private _completedSteps = new Map < reporterTypes . TestStep , StepInfo > ( ) ;
7166 private _testRun : vscodeTypes . TestRun | undefined ;
7267 private _models : TestModelCollection ;
7368 private _activeStepDecorationType : vscodeTypes . TextEditorDecorationType ;
7469 private _completedStepDecorationType : vscodeTypes . TextEditorDecorationType ;
75- private _pausedOnErrorDecorationType : vscodeTypes . TextEditorDecorationType ;
76- private _pausedAtEndDecorationType : vscodeTypes . TextEditorDecorationType ;
7770 private _debugHighlight : DebugHighlight ;
7871 private _isUnderTest : boolean ;
7972 private _reusedBrowser : ReusedBrowser ;
@@ -115,21 +108,6 @@ export class Extension implements RunHooks {
115108 } ,
116109 } ) ;
117110
118- this . _pausedAtEndDecorationType = this . _vscode . window . createTextEditorDecorationType ( {
119- isWholeLine : true ,
120- backgroundColor : { id : 'editor.wordHighlightStrongBackground' } ,
121- borderColor : { id : 'editor.wordHighlightStrongBorder' } ,
122- after : {
123- color : { id : 'editorCodeLens.foreground' } ,
124- contentText : ' \u2014 paused\u2026' ,
125- } ,
126- } ) ;
127- this . _pausedOnErrorDecorationType = this . _vscode . window . createTextEditorDecorationType ( {
128- isWholeLine : true ,
129- backgroundColor : { id : 'editor.wordHighlightStrongBackground' } ,
130- borderColor : { id : 'editor.wordHighlightStrongBorder' } ,
131- } ) ;
132-
133111 this . _logger = this . _vscode . window . createOutputChannel ( 'Playwright' , { log : true } ) ;
134112 this . _settingsModel = new SettingsModel ( vscode , context ) ;
135113 this . _reusedBrowser = new ReusedBrowser ( this . _vscode , this . _logger , this . _settingsModel , this . _envProvider . bind ( this ) ) ;
@@ -142,7 +120,6 @@ export class Extension implements RunHooks {
142120 envProvider : this . _envProvider . bind ( this ) ,
143121 onStdOut : this . _debugHighlight . onStdOut . bind ( this . _debugHighlight ) ,
144122 requestWatchRun : this . _runWatchedTests . bind ( this ) ,
145- testPausedHandler : this . _onTestPaused . bind ( this ) ,
146123 logger : this . _logger ,
147124 } ) ;
148125 this . _testController = vscode . tests . createTestController ( 'playwright' , 'Playwright' ) ;
@@ -240,7 +217,7 @@ export class Extension implements RunHooks {
240217 const model = this . _models . selectedModel ( ) ;
241218 if ( ! model )
242219 return vscode . window . showWarningMessage ( messageNoPlaywrightTestsFound ) ;
243- const openTestCase = this . _testUnderDebug ?. testCase ?? ( this . _settingsModel . showBrowser . get ( ) ? this . _lastBeganTest : undefined ) ;
220+ const openTestCase = this . _settingsModel . showBrowser . get ( ) ? this . _lastBeganTest : undefined ;
244221 const project = openTestCase ? ancestorProject ( openTestCase ) : model . enabledProjects ( ) [ 0 ] ?. project ;
245222 await this . _reusedBrowser . record ( model , project ) ;
246223 } ) ,
@@ -649,20 +626,15 @@ export class Extension implements RunHooks {
649626 this . _showTraceOnTestProgress ( testItem ) ;
650627 if ( mode === 'debug' ) {
651628 // Debugging is always single-workers.
652- this . _cleanupItemUnderDebug ( ) ;
653- this . _testUnderDebug = {
654- testItem,
655- testCase : test ,
656- disposables : [ ] ,
657- } ;
629+ this . _testItemUnderDebug = testItem ;
658630 }
659631 } ,
660632
661633 onTestEnd : ( test : reporterTypes . TestCase , result : reporterTypes . TestResult ) => {
662634 if ( result . errors . find ( e => e . message ?. includes ( `Error: browserType.launch: Executable doesn't exist` ) ) )
663635 browserDoesNotExist = true ;
664636
665- this . _cleanupItemUnderDebug ( ) ;
637+ this . _testItemUnderDebug = undefined ;
666638 this . _activeSteps . clear ( ) ;
667639 this . _executionLinesChanged ( ) ;
668640
@@ -725,7 +697,6 @@ export class Extension implements RunHooks {
725697
726698 if ( mode === 'debug' ) {
727699 await model . debugTests ( request , testListener , testRun . token ) ;
728- this . _cleanupItemUnderDebug ( ) ;
729700 } else {
730701 // Force trace viewer update to surface check version errors.
731702 await this . _models . selectedModel ( ) ?. updateTraceViewer ( mode === 'run' ) ?. willRunTests ( ) ;
@@ -890,44 +861,12 @@ test('test', async ({ page }) => {
890861 }
891862
892863 private _errorInDebugger ( errorStack : string , location : reporterTypes . Location ) {
893- if ( ! this . _testRun || ! this . _testUnderDebug ?. testItem )
864+ if ( ! this . _testRun || ! this . _testItemUnderDebug )
894865 return ;
895866 const testMessage = this . _testMessageFromText ( errorStack ) ;
896867 testMessage . location = this . _asLocation ( location ) ;
897- this . _testRun . failed ( this . _testUnderDebug . testItem , testMessage ) ;
898- this . _cleanupItemUnderDebug ( ) ;
899- }
900-
901- private _cleanupItemUnderDebug ( ) {
902- for ( const disposable of this . _testUnderDebug ?. disposables || [ ] )
903- disposable . dispose ( ) ;
904- this . _testUnderDebug = undefined ;
905- }
906-
907- private async _onTestPaused ( params : { errors : reporterTypes . TestError [ ] } ) {
908- if ( ! this . _testUnderDebug )
909- return ;
910- const errors = params . errors . filter ( e => ! ! e . message ) ;
911- if ( ! errors . length ) {
912- const location = this . _testUnderDebug . testCase . location ;
913- const document = await this . _vscode . workspace . openTextDocument ( location . file ) ;
914- const testEndPosition = findTestEndPosition ( document . getText ( ) , uriToPath ( document . uri ) , location ) ?? location ;
915- const range = this . _asRange ( testEndPosition ) ;
916- const editor = await this . _vscode . window . showTextDocument ( document , { selection : range } ) ;
917- editor . setDecorations ( this . _pausedAtEndDecorationType , [ { range } ] ) ;
918- this . _testUnderDebug . disposables . push ( { dispose : ( ) => editor . setDecorations ( this . _pausedAtEndDecorationType , [ ] ) } ) ;
919- } else {
920- if ( this . _testRun && this . _testUnderDebug . testItem )
921- this . _testRun . failed ( this . _testUnderDebug . testItem , errors . map ( error => this . _testMessageForTestError ( error ) ) ) ;
922- const error = errors . find ( e => e . location ) ;
923- if ( error ?. location ) {
924- const range = this . _asRange ( error . location ) ;
925- const document = await this . _vscode . workspace . openTextDocument ( error . location . file ) ;
926- const editor = await this . _vscode . window . showTextDocument ( document , { selection : range } ) ;
927- editor . setDecorations ( this . _pausedOnErrorDecorationType , [ { range } ] ) ;
928- this . _testUnderDebug . disposables . push ( { dispose : ( ) => editor . setDecorations ( this . _pausedOnErrorDecorationType , [ ] ) } ) ;
929- }
930- }
868+ this . _testRun . failed ( this . _testItemUnderDebug , testMessage ) ;
869+ this . _testItemUnderDebug = undefined ;
931870 }
932871
933872 private _executionLinesChanged ( ) {
0 commit comments