Skip to content

Commit 81a4133

Browse files
committed
chore: write article about vscode extension
1 parent c95725e commit 81a4133

12 files changed

+271
-0
lines changed

blog/vscode-extension.mdx

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
title: Расширение для VS Code
3+
slug: vscode-extension
4+
hide_table_of_contents: false
5+
date: 2024-09-26T16:00
6+
---
7+
8+
import Admonition from "@theme/Admonition";
9+
10+
Для Testplane реализовали расширение для [VS Code][vscode], с помощью которого можно настраивать Testplane с нуля, запускать тесты и удобно работать с <a href="/ru/docs/v8/command-line/#testplane-repl">REPL режимом</a>.
11+
12+
<!-- truncate -->
13+
14+
### Установка
15+
16+
Установите расширение со страницы [VS Code Marketplace][vscode-testplane-marketplace] или на вкладке расширений в VS Code IDE.
17+
18+
![Расширение в VS Code IDE](/img/blog/vscode-extension/testplane-in-extensions-panel.png)
19+
20+
После установки откройте VS Code в пустом проекте и в панеле управления введите:
21+
22+
```
23+
Install Testplane
24+
```
25+
26+
![Установка Testplane](/img/blog/vscode-extension/testplane-install.png)
27+
28+
### Запуск тестов
29+
30+
#### Из сайдбара в панеле для тестирования
31+
32+
Панель для тестирования можно открыть, кликнув на значок тестирования в панели действий.
33+
34+
![Открытие панели для тестирования](/img/blog/vscode-extension/testing-sidebar.png)
35+
36+
В левой части экрана отображается сайдбар с деревом всех прочитанных тестов. В дереве сверху вниз отображаются:
37+
38+
- название директории с тестами (`testplane-tests`);
39+
- название файла теста (`example.testplane.ts`);
40+
- название сьюта (`test`). В примере используется `describe` из [Mocha BDD интерфейса][mocha-bdd-interface];
41+
- название теста (`example`). В примере использует `it` из [Mocha BDD интерфейса][mocha-bdd-interface];
42+
- название браузера в котором тест будет запущен (`chrome`).
43+
44+
У каждого из элементов дерева отображается кнопка `Run Test`. Если нажать на `Run Test` у элемента:
45+
46+
- директории, файла или сьюта, то запустятся все дочерние тесты во всех браузерах;
47+
- теста, то запустится выбранный тест во всех браузерах;
48+
- браузера, то запустится один тест в одном браузере.
49+
50+
Пример запуска тестов из сайдбара:
51+
52+
<video controls="controls">
53+
<source
54+
src="/video/blog/vscode-extension/run-tests-from-sidebar.mp4"
55+
type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
56+
/>
57+
Тег video не поддерживается вашим браузером.
58+
<a href="video/blog/vscode-extension/run-tests-from-sidebar.mp4">Скачайте видео</a>.
59+
</video>
60+
61+
Также можно выполнить запуск всех тестов с помощью кнопки `Run Tests`.
62+
63+
![Запуск всех тестов](/img/blog/vscode-extension/run-all-tests-from-sidebar.png)
64+
65+
#### Из текстового редактора
66+
67+
Если в текстовом редакторе открыть Testplane тест, то рядом с каждым сьютом (`describe`) и тестом (`it`) будет отображаться зеленая кнопка play для их запуска. Если нажать левой кнопкой мыши, то запустится тест во всех браузерах, и после его выполнения отобразится результат в виде иконки статуса прохождения теста.
68+
Если нажать на кнопку play правой клавишей мыши, то можно запустить тест в одном из браузеров.
69+
70+
Пример запуска тестов из текстового редактора:
71+
72+
<video controls="controls">
73+
<source
74+
src="/video/blog/vscode-extension/run-tests-from-editor.mp4"
75+
type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
76+
/>
77+
Тег video не поддерживается вашим браузером.
78+
<a href="video/blog/vscode-extension/run-tests-from-editor.mp4">Скачайте видео</a>.
79+
</video>
80+
81+
#### С настройкой `devtools`
82+
83+
В сайдбаре в панели для тестирования так же отображается секция с названием Testplane. В ней можно управлять настройками в рантайме. При клике в чекбокс `Enable devtools` и последующем запуске тестов браузеры будут подниматься с использованием CDP протокола (вне зависимости от того что указано в конфиге). Подробнее про этот режим можно прочитать <a href="/ru/docs/v8/guides/how-to-use-cdp/">тут</a>.
84+
85+
![Включение опции devtools](/img/blog/vscode-extension/enable-devtools.png)
86+
87+
#### С настройкой `REPL`
88+
89+
При клике в чекбокс `Enable REPL` и последующем запуске теста (в REPL режиме можно одновременно запустить только один тест) он будет запущен в специальном REPL режиме. Подробнее про этот режим можно прочитать <a href="/ru/docs/v8/command-line/#testplane-repl">тут</a>.
90+
91+
![Включение опции REPL](/img/blog/vscode-extension/enable-repl.png)
92+
93+
### Фильтрация тестов в сайдбаре панели тестирования
94+
95+
Чтобы в дереве отобразить только тесты в определенном браузере, необходимо ввести тег `@testplane:browser:your_browser_name` в инпут фильтрации. Чтобы появился саджест, можно просто написать `@browser`. Там же можно использовать несколько тегов.
96+
97+
![Фильтр по указанном браузеру](/img/blog/vscode-extension/filter_sidebar_by_browser.png)
98+
99+
Также в инпуте с фильтрацией можно использовать следующие значения:
100+
101+
- строка с названием элемента дерева (директория/файл/сьют/тест/браузер);
102+
- тег `@doc` - для отображения тестов из активного файла в текстовом редакторе;
103+
- тег `@openedFiles` - для отображения тестов во всех открытых файлах в текстовом редакторе;
104+
- тег `@executed` - для отображения только выполняющихся тестов;
105+
- тег `@failed` - для отображения только упавших тестов.
106+
107+
### Перезапуск окружения Testplane
108+
109+
С помощью кнопки `Refresh Tests` в сайдбаре можно перезапустить Testplane. В этом случае перечитается конфиг и тесты. Пригодится в случае, если вы добавили новый тест в файл (вотчинг тестовых файлов пока не поддерживается) или произошла какая-то критическая ошибка.
110+
Обновление дерева тестов выполняется автоматически при изменении конфига.
111+
112+
![Обновление дерева тестов](/img/blog/vscode-extension/refresh-tests.png)
113+
114+
### Требования
115+
116+
- версия testplane должна быть 8.20.0 и старше (с версиями ниже запуск тестов работать не будет).
117+
118+
### Текущие ограничения
119+
120+
- не поддержаны debug и continuous (auto-run) режимы;
121+
- нет вотчинга добавления/удаления тестов и файлов;
122+
- использование кастомных интерфейсов Mocha может приводить к некорректному отображению иконок с кнопкой play для запуска тестов из текстового редактора.
123+
124+
### Заключение
125+
126+
Данная функциональность предоставляет нашим пользователям новые возможности:
127+
128+
- возможность запуска тестов прямо из IDE и просмотр результата выполнения;
129+
- возможность максимально быстро переключится в режим `devtools` и `repl`;
130+
- автоматически подхватывать изменения, внесенные в конфиг Testplane.
131+
132+
Устанавливайте расширение Testplane для VS Code и приходите с фидбеком. В случае обнаружения проблем приходите в [issue github](https://github.com/gemini-testing/testplane/issues) — мы вам обязательно поможем!
133+
134+
[vscode]: https://code.visualstudio.com/
135+
[vscode-testplane-marketplace]: https://marketplace.visualstudio.com/items?itemName=gemini-testing.vscode-testplane
136+
[mocha-bdd-interface]: https://mochajs.org/#bdd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: Extension for VS Code
3+
slug: vscode-extension
4+
hide_table_of_contents: false
5+
date: 2024-09-26T16:00
6+
---
7+
8+
import Admonition from "@theme/Admonition";
9+
10+
We have implemented an extension for [VS Code][vscode] for Testplane, which allows you to configure Testplane from scratch, run tests, and conveniently work with the <a href="/ru/docs/v8/command-line/#testplane-repl">REPL mode</a>.
11+
12+
<!-- truncate -->
13+
14+
### Installation
15+
16+
Install the extension from the [VS Code Marketplace][vscode-testplane-marketplace] or from the extensions tab in the VS Code IDE.
17+
18+
![Extension in VS Code IDE](/img/blog/vscode-extension/testplane-in-extensions-panel.png)
19+
20+
After installation, open VS Code in an empty project and enter in the command panel:
21+
22+
```
23+
Install Testplane
24+
```
25+
26+
![Install Testplane](/img/blog/vscode-extension/testplane-install.png)
27+
28+
### Running tests
29+
30+
#### From the sidebar in the testing panel
31+
32+
The testing panel can be opened by clicking on the testing icon in the activity bar.
33+
34+
![Opening testing panel in activity bar](/img/blog/vscode-extension/testing-sidebar.png)
35+
36+
On the left side of the screen, a sidebar displays a tree of all read tests. The tree displays from top to bottom:
37+
38+
- the name of the directory with tests (`testplane-tests`);
39+
- the name of the test file (`example.testplane.ts`);
40+
- the name of the suite (`test`). In the example, `describe` from the [Mocha BDD interface][mocha-bdd-interface] is used;
41+
- the name of the test (`example`). In the example, `it` from the [Mocha BDD interface][mocha-bdd-interface] is used;
42+
- the name of the browser in which the test will be run (`chrome`).
43+
44+
Each element in the tree has a `Run Test` button. If you click on it at the element:
45+
46+
- for a directory, file, or suite, all child tests will run in all browsers;
47+
- for a test, the selected test will run in all browsers;
48+
- for a browser, one test will run in one browser.
49+
50+
Example of running tests from the sidebar:
51+
52+
<video controls="controls">
53+
<source
54+
src="/video/blog/vscode-extension/run-tests-from-sidebar.mp4"
55+
type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
56+
/>
57+
The video tag is not supported by your browser.
58+
<a href="video/blog/vscode-extension/run-tests-from-sidebar.mp4">Download the video</a>.
59+
</video>
60+
61+
You can also run all tests using the `Run Tests` button.
62+
63+
![Running all tests](/img/blog/vscode-extension/run-all-tests-from-sidebar.png)
64+
65+
#### From a text editor
66+
67+
If you open a Testplane test in the text editor, a green play button will be displayed next to each suite (`describe`) and test (`it`) for launching them. If you click the left mouse button, the test will run in all browsers, and after execution, the result will be displayed as a status icon for the test's pass/fail status.
68+
If you right-click the play button, you can run the test in one of the browsers.
69+
70+
Example of running tests from a text editor:
71+
72+
<video controls="controls">
73+
<source
74+
src="/video/blog/vscode-extension/run-tests-from-editor.mp4"
75+
type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
76+
/>
77+
The video tag is not supported by your browser.
78+
<a href="video/blog/vscode-extension/run-tests-from-editor.mp4">Download the video</a>.
79+
</video>
80+
81+
#### With the `devtools` settings
82+
83+
In the sidebar of the testing panel, there is also a section titled Testplane. Here you can manage settings at runtime. By clicking the `Enable devtools` checkbox and subsequently running tests, browsers will launch using the CDP protocol (regardless of what is specified in the config). You can read more about this mode <a href="/en/docs/v8/guides/how-to-use-cdp/">here</a>..
84+
85+
![Enabling devtools option](/img/blog/vscode-extension/enable-devtools.png)
86+
87+
#### With the `REPL` settings
88+
89+
When you click the checkbox `Enable REPL` and subsequently run a test (only one test can be run simultaneously in REPL mode), it will be launched in a special REPL mode. You can read more about this mode <a href="/ru/docs/v8/command-line/#testplane-repl">here</a>.
90+
91+
![Enabling the REPL option](/img/blog/vscode-extension/enable-repl.png)
92+
93+
### Filtering tests in the sidebar of the testing panel
94+
95+
To display only tests in a specific browser in the tree, you need to enter the tag `@testplane:browser:your_browser_name` in the filtering input. To get a suggestion, you can simply type `@browser`. You can also use multiple tags there.
96+
97+
![Filter by specified browser](/img/blog/vscode-extension/filter_sidebar_by_browser.png)
98+
99+
You can also use the following values in the filter input:
100+
101+
- a string with the name of the tree element (directory/file/suite/test/browser);
102+
- tag @doc - to display tests from the active file in the text editor;
103+
- tag @openedFiles - to display tests in all open files in the text editor;
104+
- tag @executed - to display only running tests;
105+
- tag @failed - to display only failed tests.
106+
107+
### Restarting the Testplane Environment
108+
109+
You can restart Testplane using the `Refresh Tests` button in the sidebar. In this case, the config and tests will be re-read. This will be useful if you have added a new test to a file (watching test files is not yet supported) or if a critical error has occurred. The test tree is automatically updated when the config changes.
110+
111+
![Updating the test tree](/img/blog/vscode-extension/refresh-tests.png)
112+
113+
### Requirements
114+
115+
- the Testplane version must be 8.20.0 or higher (tests will not run with lower versions).
116+
117+
### Current Limitations
118+
119+
- debug and continuous (auto-run) modes are not supported;
120+
- there is no watching for adding/removing tests and files;
121+
- using custom Mocha interfaces may lead to incorrect display of icons with the play button for running tests from the text editor.
122+
123+
### Conclusion
124+
125+
This functionality provides our users with new opportunities:
126+
127+
- the ability to run tests directly from the IDE and view the execution results;
128+
- the ability to quickly switch to devtools and REPL mode;
129+
- automatically pick up changes made to the Testplane config.
130+
131+
Install the Testplane extension for VS Code and provide us with feedback. If you encounter any issues, please visit the [GitHub issue](https://github.com/gemini-testing/testplane/issues) — we will definitely help you!
132+
133+
[vscode]: https://code.visualstudio.com/
134+
[vscode-testplane-marketplace]: https://marketplace.visualstudio.com/items?itemName=gemini-testing.vscode-testplane
135+
[mocha-bdd-interface]: https://mochajs.org/#bdd
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)