Change:
options: TestCodeEditorCreationOptions & { provider?: CompletionItemProvider, fakeClock?: boolean, serviceCollection?: never }, callback: (args: { editor: ITestCodeEditor, editorViewModel: ViewModel, model: SuggestWidgetAdapterModel, context: GhostTextContext }) => Promise<void> ): Promise<void> { <del> const serviceCollection = new ServiceCollection( [ITelemetryService, NullTelemetryService], [ILogService, new NullLogService()], [IStorageService, new InMemoryStorageService()], [IKeybindingService, new MockKeybindingService()], [IEditorWorkerService, new class extends mock<IEditorWorkerService>() { override computeWordRanges() { return Promise.resolve({}); } }], [ISuggestMemoryService, new class extends mock<ISuggestMemoryService>() { override memorize(): void { } override select(): number { return 0; } }], [IMenuService, new class extends mock<IMenuService>() { override createMenu() { return new class extends mock<IMenu>() { override onDidChange = Event.None; override dispose() { } }; </del> <ins> await runWithFakedTimers({ useFakeTimers: options.fakeClock }, async () => { const disposableStore = new DisposableStore(); try { const serviceCollection = new ServiceCollection( [ITelemetryService, NullTelemetryService], [ILogService, new NullLogService()], [IStorageService, new InMemoryStorageService()], [IKeybindingService, new MockKeybindingService()], [IEditorWorkerService, new class extends mock<IEditorWorkerService>() { override computeWordRanges() { return Promise.resolve({}); } }], [ISuggestMemoryService, new class extends mock<ISuggestMemoryService>() { override memorize(): void { } override select(): number { return 0; } }], [IMenuService, new class extends mock<IMenuService>() { override createMenu() { return new class extends mock<IMenu>() { override onDidChange = Event.None; override dispose() { } }; } }] ); if (options.provider) { const d = CompletionProviderRegistry.register({ pattern: '**' }, options.provider); disposableStore.add(d); </ins> } <del> }] ); const disposableStore = new DisposableStore(); if (options.provider) { const d = CompletionProviderRegistry.register({ pattern: '**' }, options.provider); disposableStore.add(d); } let clock: sinon.SinonFakeTimers | undefined; if (options.fakeClock) { clock = sinon.useFakeTimers(); } try { const p = withAsyncTestCodeEditor(text, { ...options, serviceCollection }, async (editor, editorViewModel, instantiationService) => { editor.registerAndInstantiateContribution(SnippetController2.ID, SnippetController2); editor.registerAndInstantiateContribution(SuggestController.ID, SuggestController); const model = instantiationService.createInstance(SuggestWidgetAdapterModel, editor); const context = new GhostTextContext(model, editor); await callback({ editor, editorViewModel, model, context }); model.dispose(); }); const p2 = clock?.runAllAsync(); await p; await p2; } finally { clock?.restore(); disposableStore.dispose(); } </del> <ins> await withAsyncTestCodeEditor(text, { ...options, serviceCollection }, async (editor, editorViewModel, instantiationService) => { editor.registerAndInstantiateContribution(SnippetController2.ID, SnippetController2); editor.registerAndInstantiateContribution(SuggestController.ID, SuggestController); const model = instantiationService.createInstance(SuggestWidgetAdapterModel, editor); const context = new GhostTextContext(model, editor); await callback({ editor, editorViewModel, model, context }); model.dispose(); }); } finally { disposableStore.dispose(); } }); </ins> }

Discussion:
I used blame to find the owner of inline completions. Who should this be assigned to?
Looks like you did that wrong <img width="826" alt="Screen Shot 2021-07-12 at 12 53 21" src="https://user-"
From slack: I found the real issue of the flaky unit test. Apparently, some test that runs before the inline suggestion test (which fakes /) calls . spawns a (5 seconds) that calls itself (basically an endless loop over time). When the time is faked, my inline completion test waits for all scheduled timers to finish until the queue of scheduled timers is empty (assuming I am in control of all scheduled timers when my test is run). However, the loop in then causes an endless loop. My test gives up after running 1000 scheduled timers and I guess then things are in an inconsistent state. This only happens when my tests are run right before is about to run. If my tests a run in the 5s interval in which is not called, nothing bad happens. As a quick fix, I will change my tests to not wait for the timer queue to get empty. As a long term fix, I think tests should be isolated better - at least they should make really sure they clean up everything (such as disposables/timers/global handlers/etc.). Joh tracked this down to this leaking disposable: