I'm trying to write a test for an extension. The extension uses the python extension (ms-python.python). Therefore I put this in my package.json:
"extensionDependencies": [
"ms-python.python"
],
To be able to run my test I need "ms-python.python" to be installed. I followed this documentation: https://code.visualstudio.com/api/working-with-extensions/testing-extension#custom-setup-with-vscodetestelectron
but for some reason I can't make it work. When running my test with 'npm run test':
import * as path from 'path';
import * as cp from 'child_process';
import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from '@vscode/test-electron';
import * as fs from 'fs-extra';
import * as rimraf from 'rimraf';
async function main() {
const tmpHomeDir: string = fs.mkdtempSync("/tmp/vscode-tests");
try {
const workspaceSettingsPath = path.resolve(__dirname, '../../src/test/compile/workspace/.vscode/settings.json');
await fs.ensureFile(workspaceSettingsPath);
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.50.0');
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
cp.spawnSync(cliPath, ['--install-extension', 'ms-python.python'], {
encoding: 'utf-8',
stdio: 'inherit'
});
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath: extensionDevelopmentPath,
extensionTestsPath: path.resolve(__dirname, './compile/index'),
launchArgs: [path.resolve(__dirname, '../../src/test/compile/workspace')],
});
} catch (err) {
console.error('Failed to run tests: ' + err);
process.exit(1);
} finally {
rimraf.sync(tmpHomeDir);
}
}
main();
This start a new vscode(Extension Development Host)but with a message saying:
Cannot activate the 'xxx' extension because it depends on the 'Python' extension, which is not installed. Would you like to install the extension and reload the window?
So it seems the Python extension was not installed, or not where it should...
Thanks in advance for the help :)