-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve selfhost testing experience #189680
Comments
Personally I am hoping greater use by the team of the native testing UI will lead to the coverage API getting some attention. In particular, until its results get surfaced in the UI there's not a lot of incentive for us extension developers to invest in it. See #123713 |
I’m a big fan of snapshot testing that Jest supports and think we could benefit greatly from adopting it. Snapshot testingSnapshot tests (aka "expect tests) are tests that capture the string representation of a given object and compare to the expected string. The important aspect of these tests is that those snapshots
Screen.Recording.2023-08-10.at.11.56.36.mov
Snapshots also allow for more visual tests because one doesn't need to write those by hand: test('returns the positions of all functions in the source code', async () => {
const source = outdent`
function add(a, b) {
return a + b;
}
function subtract(a, b) {
return a - b;
}
`;
expect(await jsSourceWithFunPos(source)).toMatchInlineSnapshot(`
"<start-0>function add(a, b) {
return a + b;
}<end-0>
<start-1>function subtract(a, b) {
return a - b;
}<end-1>"
`);
}); Some things that could be improved with Jest & Jest extension:
I like this blog post describing how snapshot tests can be nice - https://blog.janestreet.com/the-joy-of-expect-tests/ Jane Street is big on snapshot testing and have their own framework. Their way of creating snapshots is a bit different because they don't compare the snapshot against an object but they capture stdout from a test as a snapshot. Happy to jump on a call to discuss this more and, in general, help with implementation some of the things, if time permits. |
This adds Jest-like support for snapshot testing. Developers can do something like: ```js await assertSnapshot(myComplexObject) ``` The first time this is run, the snapshot expectation file is written to a `__snapshots__` directory beside the test file. Subsequent runs will compare the object to the snapshot, and fail if it doesn't match. You can see an example of this in the test for snapshots themselves! After a successful run, any unused snapshots are cleaned up. On a failed run, a gitignored `.actual` snapshot file is created beside the snapshot for easy processing and inspection. Shortly I will do some integration with the selfhost test extension to allow developers to easily update snapshots from the vscode UI. For #189680 cc @ulugbekna @hediet
This adds Jest-like support for snapshot testing. Developers can do something like: ```js await assertSnapshot(myComplexObject) ``` The first time this is run, the snapshot expectation file is written to a `__snapshots__` directory beside the test file. Subsequent runs will compare the object to the snapshot, and fail if it doesn't match. You can see an example of this in the test for snapshots themselves! After a successful run, any unused snapshots are cleaned up. On a failed run, a gitignored `.actual` snapshot file is created beside the snapshot for easy processing and inspection. Shortly I will do some integration with the selfhost test extension to allow developers to easily update snapshots from the vscode UI. For #189680 cc @ulugbekna @hediet
This adds Jest-like support for snapshot testing. Developers can do something like: ```js await assertSnapshot(myComplexObject) ``` The first time this is run, the snapshot expectation file is written to a `__snapshots__` directory beside the test file. Subsequent runs will compare the object to the snapshot, and fail if it doesn't match. You can see an example of this in the test for snapshots themselves! After a successful run, any unused snapshots are cleaned up. On a failed run, a gitignored `.actual` snapshot file is created beside the snapshot for easy processing and inspection. Shortly I will do some integration with the selfhost test extension to allow developers to easily update snapshots from the vscode UI. For #189680 cc @ulugbekna @hediet
* eng: add support for snapshot tests This adds Jest-like support for snapshot testing. Developers can do something like: ```js await assertSnapshot(myComplexObject) ``` The first time this is run, the snapshot expectation file is written to a `__snapshots__` directory beside the test file. Subsequent runs will compare the object to the snapshot, and fail if it doesn't match. You can see an example of this in the test for snapshots themselves! After a successful run, any unused snapshots are cleaned up. On a failed run, a gitignored `.actual` snapshot file is created beside the snapshot for easy processing and inspection. Shortly I will do some integration with the selfhost test extension to allow developers to easily update snapshots from the vscode UI. For #189680 cc @ulugbekna @hediet * fix async stacktraces getting clobbered * random fixes * comment out leak detector, for now * add option to snapshot file extension
Followup items from discussion:
|
I finished the big themes I wanted to implement for this issues with the test CLI and its adoption in core. Copying the notice I sent for posterity This week I've been working on a new way to run extension tests. It includes a configuration-driven command-line runner, as well as an extension that runs extensions tests in the VS Code UI. 👉 For people who own built-in extensions: You can now use this for built-in extensions in VS Code! To onboard your extension: (example)
👉 For people who write extensions: pretty similar to the above! You can use the above as guidelines as well as the documentation and an example. |
The text was updated successfully, but these errors were encountered: