Skip to content

Commit c35b6a3

Browse files
eleanorjboydanthonykim1
authored andcommitted
Fix service.test.ts to stop disposing of all services (microsoft#21811)
file `service.test.ts` was calling to dispose of all items related to the service container for clean up. This led to services in later tests failing since they were close already. Fixes here allow for new tests in the test adapter to be written. fix helps microsoft#21803
1 parent 387dc3c commit c35b6a3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/test/common/configuration/service.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Licensed under the MIT License.
33
import { expect } from 'chai';
44
import { workspace } from 'vscode';
5-
import { IConfigurationService, IDisposableRegistry } from '../../../client/common/types';
6-
import { disposeAll } from '../../../client/common/utils/resourceLifecycle';
5+
import { IConfigurationService, IDisposableRegistry, IExtensionContext } from '../../../client/common/types';
76
import { IServiceContainer } from '../../../client/ioc/types';
87
import { getExtensionSettings } from '../../extensionSettings';
98
import { initialize } from '../../initialize';
@@ -23,15 +22,17 @@ suite('Configuration Service', () => {
2322

2423
test('Ensure async registry works', async () => {
2524
const asyncRegistry = serviceContainer.get<IDisposableRegistry>(IDisposableRegistry);
26-
let disposed = false;
25+
let subs = serviceContainer.get<IExtensionContext>(IExtensionContext).subscriptions;
26+
const oldLength = subs.length;
2727
const disposable = {
2828
dispose(): Promise<void> {
29-
disposed = true;
3029
return Promise.resolve();
3130
},
3231
};
3332
asyncRegistry.push(disposable);
34-
await disposeAll(asyncRegistry);
35-
expect(disposed).to.be.equal(true, "Didn't dispose during async registry cleanup");
33+
subs = serviceContainer.get<IExtensionContext>(IExtensionContext).subscriptions;
34+
const newLength = subs.length;
35+
expect(newLength).to.be.equal(oldLength + 1, 'Subscription not added');
36+
// serviceContainer subscriptions are not disposed of as this breaks other tests that use the service container.
3637
});
3738
});

0 commit comments

Comments
 (0)