File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -797,8 +797,11 @@ export class Vitest {
797797 async close ( ) {
798798 if ( ! this . closingPromise ) {
799799 this . closingPromise = ( async ( ) => {
800+ const teardownProjects = [ ...this . projects ]
801+ if ( ! teardownProjects . includes ( this . coreWorkspaceProject ) )
802+ teardownProjects . push ( this . coreWorkspaceProject )
800803 // do teardown before closing the server
801- for await ( const project of [ ... this . projects ] . reverse ( ) )
804+ for await ( const project of teardownProjects . reverse ( ) )
802805 await project . teardownGlobalSetup ( )
803806
804807 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) {
2424 }
2525}
2626
27+ let teardownCalled = false
28+
2729export async function teardown ( ) {
30+ teardownCalled = true
2831 const results = JSON . parse ( await readFile ( './results.json' , 'utf-8' ) )
2932
3033 try {
3134 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 )
3538
3639 const shared = results . testResults . filter ( ( r : any ) => r . name . includes ( 'space_shared/test.spec.ts' ) )
3740
@@ -42,3 +45,10 @@ export async function teardown() {
4245 process . exit ( 1 )
4346 }
4447}
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