diff --git a/tst/e2e/DocumentHandler.test.ts b/tst/e2e/DocumentHandler.test.ts index cddd4949..3099e7ed 100644 --- a/tst/e2e/DocumentHandler.test.ts +++ b/tst/e2e/DocumentHandler.test.ts @@ -11,10 +11,6 @@ describe('DocumentHandler', () => { await extension.reset(); }); - beforeEach(async () => { - await extension.reset(); - }); - afterAll(async () => { await extension.close(); }); @@ -35,7 +31,7 @@ describe('DocumentHandler', () => { const document = extension.components.documentManager.get(uri); expect(document).toBeDefined(); expect(document?.contents()).toBe(content); - }); + }, 2_500); }); it('should handle document change and update DocumentManager', async () => { @@ -65,7 +61,7 @@ describe('DocumentHandler', () => { await WaitFor.waitFor(() => { const document = extension.components.documentManager.get(uri); expect(document?.contents()).toBe(`Hello${newContent}`); - }); + }, 2_500); const replaceContent = 'SomeRandomContent'; await extension.changeDocument({ @@ -76,7 +72,7 @@ describe('DocumentHandler', () => { await WaitFor.waitFor(() => { const document = extension.components.documentManager.get(uri); expect(document?.contents()).toBe(replaceContent); - }); + }, 2_500); }); it('should handle document close and remove from DocumentManager', async () => { @@ -93,7 +89,7 @@ describe('DocumentHandler', () => { await WaitFor.waitFor(() => { expect(extension.components.documentManager.get(uri)).toBeDefined(); - }); + }, 2_500); await extension.closeDocument({ textDocument: { uri }, @@ -101,6 +97,6 @@ describe('DocumentHandler', () => { await WaitFor.waitFor(() => { expect(extension.components.documentManager.get(uri)).toBeUndefined(); - }); + }, 2_500); }); }); diff --git a/tst/utils/TestExtension.ts b/tst/utils/TestExtension.ts index f74459c9..fa6b3522 100644 --- a/tst/utils/TestExtension.ts +++ b/tst/utils/TestExtension.ts @@ -211,6 +211,8 @@ export class TestExtension implements Closeable { async reset() { await this.ready(); + (this.serverConnection.components.documents.documents as any)._syncedDocuments.clear(); + this.core.settingsManager.reset(); this.core.syntaxTreeManager.deleteAllTrees(); this.core.documentManager.clear(); @@ -241,12 +243,10 @@ export class TestExtension implements Closeable { async openDocument(params: DidOpenTextDocumentParams) { await this.notify(DidOpenTextDocumentNotification.method, params); - await wait(10); } async changeDocument(params: DidChangeTextDocumentParams) { await this.notify(DidChangeTextDocumentNotification.method, params); - await wait(10); } async closeDocument(params: DidCloseTextDocumentParams) { @@ -338,7 +338,3 @@ export class TestExtension implements Closeable { return uri; } } - -async function wait(ms: number) { - await new Promise((resolve) => setTimeout(resolve, ms)); -}