diff --git a/packages/foam-vscode/src/test/run-tests.ts b/packages/foam-vscode/src/test/run-tests.ts index 0a755d4ca..73fd8a53f 100644 --- a/packages/foam-vscode/src/test/run-tests.ts +++ b/packages/foam-vscode/src/test/run-tests.ts @@ -1,3 +1,4 @@ +import rf from 'rimraf'; import path from 'path'; import { runTests } from 'vscode-test'; import { runUnit } from './suite-unit'; @@ -34,12 +35,21 @@ async function main() { // Passed to --extensionTestsPath const extensionTestsPath = path.join(__dirname, 'suite'); + const testWorkspace = path.join( + extensionDevelopmentPath, + '.test-workspace' + ); + // clean test workspace + rf.sync(path.join(testWorkspace, '*')); + rf.sync(path.join(testWorkspace, '.vscode')); + rf.sync(path.join(testWorkspace, '.foam')); + // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: [ - path.join(extensionDevelopmentPath, '.test-workspace'), + testWorkspace, '--disable-extensions', '--disable-workspace-trust', ], diff --git a/packages/foam-vscode/src/test/test-utils-vscode.ts b/packages/foam-vscode/src/test/test-utils-vscode.ts index d42e49d41..c55915197 100644 --- a/packages/foam-vscode/src/test/test-utils-vscode.ts +++ b/packages/foam-vscode/src/test/test-utils-vscode.ts @@ -108,10 +108,10 @@ export const runCommand = async (command: string, args: T = undefined) => * @param fn the function to execute */ export const withModifiedConfiguration = async (key, value, fn: () => void) => { - const old = vscode.workspace.getConfiguration().get(key); + const old = vscode.workspace.getConfiguration().inspect(key); await vscode.workspace.getConfiguration().update(key, value); await fn(); - await vscode.workspace.getConfiguration().update(key, old); + await vscode.workspace.getConfiguration().update(key, old.workspaceValue); }; /**