Skip to content

Commit

Permalink
Add sleep to code action test
Browse files Browse the repository at this point in the history
The test for code actions can take slightlty longer to activate terraform-ls than the method open() accounts for. This adds a sleep to ensure that it's activated before we attempt to ask for supported code actions.
  • Loading branch information
jpogran committed Sep 12, 2023
1 parent f6f3681 commit 074eea5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/integration/codeAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ suite('code actions', () => {
new vscode.CodeAction('Format Document', vscode.CodeActionKind.Source.append('formatAll').append('terraform')),
];

// wait till the LS is ready to acccept a code action request
await sleep(1000);

for (let index = 0; index < supported.length; index++) {
const wanted = supported[index];
const requested = wanted.kind?.value.toString();
Expand All @@ -50,3 +53,9 @@ suite('code actions', () => {
}
});
});

function sleep(ms: number) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

0 comments on commit 074eea5

Please sign in to comment.