1

Goal: Perfom real end-to-end tests for a VSCode extension using Spectron.

As an example I installed the vim extension.

I adapted the usage example from Spectron's README like this:

var Application = require('spectron').Application
var assert = require('assert')

describe('VSCode extension', function () {
  this.timeout(10000)

  beforeEach(function () {
    this.app = new Application({
      path: '.vscode-test/VSCode-linux-x64/bin/code',
      args: [
          '--extensionDevelopmentPath=' + process.cwd(),
          '--locale=en',
          process.cwd(),
      ],
      requireName: 'nodeRequire',
    })
    return this.app.start()
  })

  afterEach(function () {
    if (this.app && this.app.isRunning()) {
      return this.app.stop()
    }
  })

  it('suggest commands', function () {
    return this.app.client
      .waitUntilWindowLoaded()
      //.pause(5000)
      //.waitUntilTextExists('span', 'OPEN EDITORS', 10000)
      .keys('F1')
      .waitForVisible('.quick-open-widget:not(.hidden)')
      .keys('vim')
      .waitForVisible('.quick-open-entry*=Vim: Show Command Line')
  })
})

Problem: How to exactly determine if VSCode is ready.

Calling client.waitUntilWindowLoaded() is not sufficient. In some test runs entering text via client.keys(...) into the Command Palette (F1) does not suggest any commands.

I don't want to use pause(...) after waitUntilWindowLoaded() as it wastes useful time and may still not be sufficient when the system is under heavy load.

For the moment I just came up with .waitUntilTextExists('span', 'OPEN EDITORS', 10000) which seems to work most of the time. Sometimes it runs into the timeout.

Is there anything more reliable (in the DOM) that is set by VSCode and can be checked by Spectron that states that VSCode is really ready?

René Scheibe
  • 1,970
  • 2
  • 14
  • 20
  • 1
    Did you manage to solve this? You can't be the only guy wanting to run automated UI tests on their VSCode extension! – nbransby Oct 15 '19 at 14:19
  • No, I didn't find a better way than the described workaround waiting for 'OPEN EDITORS'. Maybe it's possible in the meantime. I am not working on this anymore. – René Scheibe Oct 15 '19 at 19:34

0 Answers0