vscode/test/smoke
2018-03-02 16:48:22 +01:00
..
src debt - clean up and polish some CSS rules in base 2018-03-02 16:48:22 +01:00
test smoke: different slow number 2017-09-15 16:00:42 +02:00
.gitignore Moved to test directory. 2017-05-26 12:56:22 +02:00
Audit.md Added markdown to trace all smoke test failures to understand their patterns. Resolves #27906 2017-06-26 14:37:27 +02:00
package.json Locks vscode smoketest typescript to specific version 2017-10-31 12:12:38 -07:00
README.md smoketest: data migration tests 🎆 2017-12-08 16:06:05 +01:00
tsconfig.json further smoke test improvements 2017-09-04 14:54:26 +02:00
yarn.lock yarn: missing yarn.lock files 2017-11-13 23:07:17 +01:00

VS Code Smoke Test

How to run

# Dev
npm run smoketest

# Specific build
npm run smoketest -- --build "path/to/code"

# Data Migration tests
npm run smoketest -- --build "path/to/code-insiders" --stable-build "path/to/code"

The script calls mocha, so all mocha arguments should work fine. For example, use -f Git to only run the Git tests.

By default, screenshots are not captured. To run tests with screenshots use the argument --screenshots.

Pitfalls

  • Beware of state. The tests within a single suite will share the same state.

  • Beware of singletons. This evil can, and will, manifest itself under the form of FS paths, TCP ports, IPC handles. Whenever writing a test, or setting up more smoke test architecture, make sure it can run simultaneously with any other tests and even itself. All test suites should be able to run many times in parallel.

  • Beware of focus. Never depend on DOM elements having focus using .focused classes or :focus pseudo-classes, since they will lose that state as soon as another window appears on top of the running VS Code window. A safe approach which avoids this problem is to use the waitForActiveElement API. Many tests use this whenever they need to wait for a specific element to have focus.

  • Beware of timing. You need to read from or write to the DOM... yeah I know. But is it the right time to do that? Can you 100% promise that that input box will be visible and in the DOM at this point in time? Or are you just hoping that it will be so? Every time you want to interact with the DOM, be absolutely sure that you can. Eg. just because you triggered Quick Open, it doesn't mean that it's open; you must wait for the widget to be in the DOM and for its input field to be the active element.

  • Beware of waiting. Never wait longer than a couple of seconds for anything, unless it's justified. Think of it as a human using Code. Would a human take 10 minutes to run through the Search viewlet smoke test? Then, the computer should even be faster. Don't use setTimeout just because. Think about what you should wait for in the DOM to be ready, then wait for that instead.

Common Issues

Certain keys don't appear in input boxes (eg: Space)

This is a waiting issue. Everytime you send keys to Code, you must be aware that the keybinding service can handle them. Even if you're sure that input box is focused.

Here's an example: when opening quick open, focus goes from its list to its input. We used to simply wait for the input to have focus and then send some text to be typed, like Workbench: Show Editor; yet, only Workbench:ShowEditor would be rendered in the input box. This happened due to the fact that the ListService takes 50ms to unset the context key which indicates a list is focused. The fix was to wait 50ms as well on the smoke test.

I type in a Monaco editor instance, but the text doesn't appear to be there

This is a waiting issue. When you type in a Monaco editor instance, you're really typing in a textarea. The textarea is then polled for its contents, then the editor model gets updated and finally the editor view gets updated. It's a good idea to always wait for the text to appear rendered in the editor after you type in it.

I type in a Monaco editor instance, but the text appears scrambled

This is an issue which is not yet fixed. Unfortunately this seems to happen whenever the CPU load of the system is high. Rerunning the test will often result in a successful outcome.