mirror of
https://github.com/Microsoft/vscode
synced 2024-10-01 08:50:48 +00:00
a0b548807a
This adds an `assertHeap` function that can be used in tests. It takes a heap snapshot, and asserts the state of classes in memory. This works in Node and the Electron sandbox, but is a no-op in the browser. Snapshots are process asynchronously and will report failures at the end of the suite. This method should be used sparingly (e.g. once at the end of a suite to ensure nothing leaked before), as gathering a heap snapshot is fairly slow, at least until V8 11.5.130 (https://v8.dev/blog/speeding-up-v8-heap-snapshots). When used, the function will ensure the test has a minimum timeout duration of 20s to avoid immediate failures. It takes options containing a mapping of class names, and assertion functions to run on the number of retained instances of that class. For example: ```ts assertSnapshot({ classes: { ShouldNeverLeak: count => assert.strictEqual(count, 0), SomeSingleton: count => assert(count <= 1), } }); ``` Closes https://github.com/microsoft/vscode/issues/191920 |
||
---|---|---|
.. | ||
automation | ||
integration | ||
leaks | ||
monaco | ||
smoke | ||
unit | ||
.mocharc.json | ||
cgmanifest.json | ||
README.md |