Skip to content

Commit 1f9ba36

Browse files
authored
docs: enhance quick start section articles by adding separate installation, writing tests and running tests guides (#114)
1 parent e9bf4d2 commit 1f9ba36

8 files changed

Lines changed: 1428 additions & 435 deletions

File tree

docs/quickstart/index.mdx

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,59 @@ sidebar_position: 1
44

55
import Tabs from "@theme/Tabs";
66
import TabItem from "@theme/TabItem";
7+
import Admonition from "@theme/Admonition";
78

8-
# Installation {#install}
9+
# Installation and Setup
910

10-
Run the Testplane installer using `npm`.
11+
## System requirements
12+
13+
To start working with Testplane, install `Node.js` version 18.0 or higher.
14+
15+
## Installation {#install}
16+
17+
To run the Testplane installer using `npm`, execute the following command:
1118

1219
```bash
1320
npm init testplane@latest YOUR_PROJECT_PATH
1421
```
1522

16-
If you do not want to use the defaults when initializing the project and want to configure it using a wizard, specify the `-v` option.
23+
To configure the project instead of using defaults during initialization, specify the `-v` option.
24+
25+
After running the installation command, the following set of files and folders will appear in the project directory:
26+
27+
```bash
28+
node_modules
29+
testplane-tests
30+
example.testplane.ts
31+
ts.config.json
32+
package-lock.json
33+
package.json
34+
testplane.config.ts
35+
```
1736

1837
## Setup {#setup}
1938

20-
After executing the command mentioned above, a `testplane.config.ts` file with basic settings will be generated at the root of the project.
39+
The `testplane.config.ts` file contains a basic set of settings for running tests:
2140

2241
```typescript
2342
export default {
24-
// https://testplane.io/docs/v8/basic-guides/managing-browsers/
2543
gridUrl: "local",
2644
baseUrl: "http://localhost",
2745
pageLoadTimeout: 0,
2846
httpTimeout: 60000,
2947
testTimeout: 90000,
3048
resetCursor: false,
49+
50+
// The `sets` parameter contains information about the directory where the tests are located
51+
// and a list of browsers in which they will be run:
3152
sets: {
3253
desktop: {
3354
files: ["testplane-tests/**/*.testplane.(t|j)s"],
3455
browsers: ["chrome", "firefox"],
3556
},
3657
},
58+
59+
// The `browsers` field describes the configuration of the browsers used:
3760
browsers: {
3861
chrome: {
3962
headless: true,
@@ -48,9 +71,9 @@ export default {
4871
},
4972
},
5073
},
74+
5175
plugins: {
5276
"html-reporter/testplane": {
53-
// https://github.com/gemini-testing/html-reporter
5477
enabled: true,
5578
path: "testplane-report",
5679
defaultView: "all",
@@ -60,39 +83,10 @@ export default {
6083
};
6184
```
6285

63-
You can download these browsers, described in the config, separately from running Testplane itself:
86+
To download the browsers described in the config separately from running Testplane itself, execute the command:
6487

6588
```bash
6689
npx testplane install-deps
6790
```
6891

69-
Without running the command, absent browsers will be downloaded during first Testplane launch.
70-
71-
## Creating a Test {#test_creation}
72-
73-
Navigate to the `tests/example.testplane.js` file with a test. Here you can see a test example or write your own. For example,
74-
75-
```javascript
76-
describe("github", async function () {
77-
it("should find testplane", async function ({ browser }) {
78-
await browser.url("https://github.com/gemini-testing/testplane");
79-
const elem = await browser.$("#readme h1");
80-
81-
await expect(elem).toHaveText("Testplane");
82-
});
83-
});
84-
```
85-
86-
## Running a Test {#test_running}
87-
88-
Now you can run the tests:
89-
90-
```bash
91-
npx testplane
92-
```
93-
94-
or launch the GUI mode and run the test through the browser interface
95-
96-
```bash
97-
npx testplane gui
98-
```
92+
Without running this command beforehand, missing browsers will be automatically downloaded the first time Testplane is launched.

docs/quickstart/running-tests.mdx

Lines changed: 127 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,158 @@
22
sidebar_position: 3
33
---
44

5-
# Running Tests
5+
# Running and Debugging Tests
66

7-
Use the `npx testplane` command to run all tests in your project.
7+
## Running tests
88

9-
## Running a Specific File {#running_a_specific_file}
9+
To run tests, use the following command:
1010

11-
If you want to run a whole group of tests located in a specific file, specify the path to this file as an input parameter for testplane:
11+
```bash
12+
npx testplane
13+
```
14+
15+
You can also run tests in `gui` mode. To do this, execute the command:
16+
17+
```bash
18+
npx testplane gui
19+
```
20+
21+
### Running a specific test
22+
23+
Consider the following set of tests:
24+
25+
```javascript
26+
const assert = require("assert");
27+
28+
describe("tests", () => {
29+
it("Checking the display of the main page", async ({ browser }) => {
30+
await browser.url("https://testplane.io/ru/");
31+
const title = await browser.getTitle();
32+
assert.ok(title.includes("Testplane"));
33+
});
34+
35+
it("Checking for the presence of a search field", async ({ browser }) => {
36+
await browser.url("https://testplane.io/ru/");
37+
const searchButton = await browser.$("button.DocSearch");
38+
const isExisting = await searchButton.isExisting();
39+
assert.strictEqual(isExisting, true);
40+
});
41+
});
42+
```
43+
44+
If you want to run just one of them, use `--grep` option:
1245

1346
```bash
14-
npx testplane src/features/Reviews/Reviews.test/MyReview/MyReview.a11y@touch-phone.testplane.js
47+
testplane --grep "Checking for the presence of a search field"
1548
```
1649

17-
## The `--grep` Option {#the_grep_option}
50+
You can pass the whole test name, some part of it or regex pattern to run only those tests whose names will match.
51+
52+
### Running tests in specific browsers
53+
54+
By default, tests run in the browsers specified in the `testplane.config.ts` file.
1855

19-
If you want to run a specific test, use the `--grep` option by providing the full name of the test as its value:
56+
```bash
57+
browsers: ["chrome", "firefox"];
58+
```
59+
60+
When you run the `npx testplane` command, tests will run in Google Chrome and Mozilla Firefox.
2061

2162
```bash
22-
npx testplane --grep "Accessibility Leaving a review"
63+
# Run in all browsers (default)
64+
testplane
2365
```
2466

25-
## The `.only` Directive {#the_only_directive}
67+
To run tests in a specific browser, use the command:
2668

27-
You can also use the `.only` directive for a suite of tests (`describe`) or a specific test (`it`), similar to what is implemented in `mocha` (see the [exclusive tests](https://mochajs.org/#exclusive-tests) section):
69+
```bash
70+
# Run only in Chrome
71+
testplane --browser chrome
72+
```
2873

29-
For example:
74+
You can also specify a specific browser for use within the test body.
3075

3176
```javascript
32-
describe.only("Accessibility", function () {
33-
// Test suite...
77+
// tests/browser-specific.test.js
78+
describe("Browser specific tests", () => {
79+
it("should work in all browsers", async ({ browser }) => {
80+
await browser.url("https://example.com");
81+
});
82+
83+
// Skip the test in Safari
84+
testplane.skip.in("safari", "Feature not supported in Safari");
85+
it("should work only in Chrome and Firefox", async ({ browser }) => {
86+
await browser.url("https://example.com");
87+
// ... test body
88+
});
89+
90+
// Run only in Chrome
91+
testplane.only.in("chrome");
92+
it("should work only in Chrome", async ({ browser }) => {
93+
await browser.url("https://example.com");
94+
// ... test body
95+
});
3496
});
3597
```
3698

37-
or
99+
### Running a test from a specific file
100+
101+
To run tests from a specific file, execute the command:
102+
103+
```bash
104+
# Running a specific file
105+
testplane ../testplane-tests/example.testplane.ts
106+
```
107+
108+
Where `../testplane-tests/example.testplane.ts` is the path to the test file.
109+
110+
### User interface mode
111+
112+
In Testplane, you can work with tests in UI format using Testplane UI.
113+
114+
![](/img/docs/html-reporter/html-reporter-demo.png)
115+
116+
You can read about the installation and setup processes for Testplane UI in the [UI.](..//html-reporter//overview.mdx) section.
117+
118+
## Debugging
119+
120+
It’s very easy to track the test execution process if you run tests in `gui` mode. In this mode, the HTML reporter will show which tests were executed successfully, which ones have errors, and what kind of errors they are.
121+
122+
![Testplane GUI](/img/docs/guides/testplane-gui.png)
123+
124+
### Browser.debug()
125+
126+
Testplane has a built‑in debugging tool — `browser.debug`.
38127

39128
```javascript
40-
it.only("Leaving a review", async function () {
41-
// Test code...
129+
it("debugging with a pause", async ({ browser }) => {
130+
// Open the page being tested
131+
await browser.url("/page");
132+
133+
// browser.debug() stops test execution
134+
// and opens an interactive console (REPL — Read-Eval-Print Loop)
135+
await browser.debug();
136+
137+
// After calling debug(), the test pauses
138+
// In the console, you can enter WebdriverIO commands in real time:
139+
140+
// Examples of commands you can enter in REPL:
141+
// > await browser.$('.button').click() - click the button
142+
// > await browser.getTitle() - get the page title
143+
// > await browser.$$('.items') - find all elements
144+
// > .exit - exit debug mode
145+
146+
// This code will run only after exiting debug()
147+
await browser.$(".button").click();
42148
});
43149
```
44150

45-
## Running a Test N Times {#running_tests_multiple_times}
151+
### Debugging via Testplane UI
46152

47-
You might want to run the same test multiple times, for example, to check test stability. Use the [@testplane/test-repeater][testplane-test-repeater] plugin to run tests a specified number of times.
153+
The most convenient way to debug tests is using the UI mode, where you can observe test execution in real time.
48154

49-
After installing and enabling the plugin, you can run the test multiple times like this:
155+
![](/gif/docs/ui/run-debug.gif)
50156

51-
```bash
52-
npx testplane --test-repeater-repeat 5 --grep 'Test name'
53-
```
157+
You can find unstable, slow tests, or other issues using the «sorting» and «grouping» options.
54158

55-
[testplane-test-repeater]: ../../plugins/testplane-test-repeater
159+
![](/gif/docs/ui/analytics.gif)

0 commit comments

Comments
 (0)