vendredi 10 août 2018

VSCode getExtension error on test

I am having a problem when I am testing my vscode extension. I have this code:

const coreExports = 
vscode.extensions.getExtension('extension-core')!.exports;

In one of my classes that gets the exports from a different extension so that I can use them. This works fine when I launch the extension (a treedataprovider sidebar). However, when I try to test my exension, I create a new instance of my sidebar which then tries to access that other extension. However, in my tests, I get this error

Error: Extension `extension-core` is not known or not activated

Any way to get past this?

Example test:

it.only('No tests in file', () => {
  testOutline = new TestOutlineProvider('/bogus/path', null);
  expect(testOutline.getHead()).to.equal(
    new TestGroupNode('ApexTests', null)
  );
});

The error occurs when I create a new TestOutlineProvider

Also, I have this code in my test which is either being skipped or also erroring:

const coreExtension = vscode.extensions.getExtension('extension-core');
beforeEach(async () => {
  if (coreExtension && !coreExtension.isActive) {
    await coreExtension.activate();
  }
...

Aucun commentaire:

Enregistrer un commentaire