File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -797,8 +797,11 @@ export class Vitest {
797
797
async close ( ) {
798
798
if ( ! this . closingPromise ) {
799
799
this . closingPromise = ( async ( ) => {
800
+ const teardownProjects = [ ...this . projects ]
801
+ if ( ! teardownProjects . includes ( this . coreWorkspaceProject ) )
802
+ teardownProjects . push ( this . coreWorkspaceProject )
800
803
// do teardown before closing the server
801
- for await ( const project of [ ... this . projects ] . reverse ( ) )
804
+ for await ( const project of teardownProjects . reverse ( ) )
802
805
await project . teardownGlobalSetup ( )
803
806
804
807
const closePromises : unknown [ ] = this . projects . map ( w => w . close ( ) . then ( ( ) => w . server = undefined as any ) )
Original file line number Diff line number Diff line change @@ -24,14 +24,17 @@ export function setup({ provide }: GlobalSetupContext) {
24
24
}
25
25
}
26
26
27
+ let teardownCalled = false
28
+
27
29
export async function teardown ( ) {
30
+ teardownCalled = true
28
31
const results = JSON . parse ( await readFile ( './results.json' , 'utf-8' ) )
29
32
30
33
try {
31
34
assert . ok ( results . success )
32
- assert . equal ( results . numTotalTestSuites , 11 )
33
- assert . equal ( results . numTotalTests , 12 )
34
- assert . equal ( results . numPassedTests , 12 )
35
+ assert . equal ( results . numTotalTestSuites , 28 )
36
+ assert . equal ( results . numTotalTests , 29 )
37
+ assert . equal ( results . numPassedTests , 29 )
35
38
36
39
const shared = results . testResults . filter ( ( r : any ) => r . name . includes ( 'space_shared/test.spec.ts' ) )
37
40
@@ -42,3 +45,10 @@ export async function teardown() {
42
45
process . exit ( 1 )
43
46
}
44
47
}
48
+
49
+ process . on ( 'beforeExit' , ( ) => {
50
+ if ( ! teardownCalled ) {
51
+ console . error ( 'teardown was not called' )
52
+ process . exitCode = 1
53
+ }
54
+ } )
You can’t perform that action at this time.
0 commit comments