diff --git a/src/web/test/suite/documentHelpers.test.ts b/src/web/test/suite/documentHelpers.test.ts index cb8323b..c9388e1 100644 --- a/src/web/test/suite/documentHelpers.test.ts +++ b/src/web/test/suite/documentHelpers.test.ts @@ -4,7 +4,9 @@ import { Range, TextDocument } from 'vscode'; import { adjustedRangeWithMinimumIndentation, contentOfLinesWithAdjustedIndentation, endOfLineCharacter, linesForIndexes, minimumIndentationForLineIndexes } from '../../../lib/documentHelpers'; const fixtureUri = (fileName: string) => { - const workspaceFolder = vscode.workspace.workspaceFolders![0]; + const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; + if (!workspaceFolder) { throw new Error('No workspace folder found'); } + return vscode.Uri.joinPath(workspaceFolder.uri, fileName); }; diff --git a/src/web/test/suite/textHelpers.test.ts b/src/web/test/suite/textHelpers.test.ts index d3a994e..edd7969 100644 --- a/src/web/test/suite/textHelpers.test.ts +++ b/src/web/test/suite/textHelpers.test.ts @@ -6,7 +6,9 @@ import { generateCopyableText, generateSnippet, includeLanguageIdentifier, isMar import { ExtensionConfig } from '../../../types/config'; const fixtureUri = (fileName: string) => { - const workspaceFolder = vscode.workspace.workspaceFolders![0]; + const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; + if (!workspaceFolder) { throw new Error('No workspace folder found'); } + return vscode.Uri.joinPath(workspaceFolder.uri, fileName); };