Skip to content

How to access extension in tests? #2563

Discussion options

You must be logged in to vote

Hi @eschricker ,

I'm not an expert in testing extensions, but I have a few tests on my extensions. For your use case, as a startup, I guess you only need to get the extension.

Add this to the test suite. A reference to an extension, which is filled in the suiteSetup.

suite('Extension Test Suite', () => {
    vscode.window.showInformationMessage('Start all tests.');

    // add below code
    let extension: vscode.Extension<any>;
    suiteSetup(() => {
        extension = vscode.extensions.getExtension('vscode-samples.helloworld-sample') as vscode.Extension<any>;
    });

    test('Activation test', async () => {
        await extension.activate();
        assert.strictEqual(extension.isAc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alefragnani
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants