@@ -35,28 +35,8 @@ const extensionBootstrapper = (() => {
35
35
let activator : ( ( ) => Promise < Api > ) | undefined = undefined ;
36
36
let activatedAPI : Api | undefined = undefined ;
37
37
let lastTestName : string | undefined = undefined ;
38
- let lastTestLogs : string [ ] = [ ] ;
39
38
const testTitle = ( currentTest : Mocha . Test ) => currentTest . titlePath ( ) . join ( " → " ) ;
40
39
41
- mocha . afterEach ( function ( ) {
42
- if ( this . currentTest && this . currentTest . isFailed ( ) ) {
43
- console . log ( `Captured logs during ${ testTitle ( this . currentTest ) } :` ) ;
44
- if ( lastTestLogs . length === 0 ) {
45
- console . log ( "No logs captured." ) ;
46
- }
47
- for ( const log of lastTestLogs ) {
48
- console . log ( log ) ;
49
- }
50
- }
51
- } ) ;
52
-
53
- mocha . beforeEach ( function ( ) {
54
- if ( this . currentTest && activatedAPI && process . env [ "VSCODE_TEST" ] ) {
55
- activatedAPI . outputChannel . clear ( ) ;
56
- activatedAPI . outputChannel . appendLine ( `Starting test: ${ testTitle ( this . currentTest ) } ` ) ;
57
- }
58
- } ) ;
59
-
60
40
function testRunnerSetup (
61
41
before : Mocha . HookFunction ,
62
42
setup :
@@ -119,6 +99,25 @@ const extensionBootstrapper = (() => {
119
99
}
120
100
} ) ;
121
101
102
+ mocha . beforeEach ( function ( ) {
103
+ if ( this . currentTest && activatedAPI ) {
104
+ activatedAPI . outputChannel . clear ( ) ;
105
+ activatedAPI . outputChannel . appendLine (
106
+ `Starting test: ${ testTitle ( this . currentTest ) } `
107
+ ) ;
108
+ }
109
+ } ) ;
110
+
111
+ mocha . afterEach ( function ( ) {
112
+ if ( this . currentTest && activatedAPI && this . currentTest . isFailed ( ) ) {
113
+ console . log ( `Captured logs during ${ testTitle ( this . currentTest ) } :` ) ;
114
+ for ( const log of activatedAPI . outputChannel . logs ) {
115
+ console . log ( log ) ;
116
+ }
117
+ console . log ( "======== END OF LOGS ========\n\n" ) ;
118
+ }
119
+ } ) ;
120
+
122
121
after ( async function ( ) {
123
122
try {
124
123
// First run the users supplied teardown, then await the autoTeardown if it exists.
@@ -196,7 +195,6 @@ const extensionBootstrapper = (() => {
196
195
if ( ! activatedAPI ) {
197
196
throw new Error ( "Extension is not activated. Call activateExtension() first." ) ;
198
197
}
199
- lastTestLogs = activatedAPI . outputChannel . logs ;
200
198
201
199
// Wait for up to 10 seconds for all tasks to complete before deactivating.
202
200
// Long running tasks should be avoided in tests, but this is a safety net.
0 commit comments