How to pass runtime test data to global.teardown.ts?

in fixtures.ts I perform some API calls that create objects in database and returns their ids.

After all tests are done, I need clean the created objects in database.

How do I pass the ids to global.teardown.ts?


What I have

I tries to import fixtures module with a singleton array from global.teardown.ts but the module is reinitialized.

global.teardown.ts

import { entityGuidsToDelete, api } from './fixtures'

async function globalTeardown() {
    //not working yet, because the array is always empty
    for(const entityGuid of entityGuidsToDelete) { 
        await api.deleteEntity(entityGuid);
    }
}

export default globalTeardown;

playwright.config.ts

export default defineConfig({
  ...
  /* Configure projects for major browsers */
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],

  globalTeardown: require.resolve('./global-teardown')
});
type Fixtures = {
  userApi: Api;
  newEntity: LegalEntityModel;
};

export const entityGuidsToDelete = new Array<string>();

export const test = base.extend<Fixtures>({
 ...
 newEntity: async ({ userApi }, use) => {
    const newEntity = await createNewEntity()
    entityGuidsToDelete.push(newEntity.id); //this is being called
    await use(newEntity);
  }  
}

export { expect } from '@playwright/test';