Skip to content

Commit a2c6492

Browse files
committed
Fix playwright testing guideline commands (#598)
1 parent 3880e72 commit a2c6492

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Testing
2+
3+
Tools used to test the application:
4+
5+
* **ESLint** (static code analysis of JS files)
6+
* **Markdownlint** (static analysis of MD files)
7+
* **Stylelint** (static code analysis of CSS files)
8+
* **Jest** (unit testing)
9+
* **Playwright** (visual and functional component testing)
10+
11+
Generally, `npm test` and `npm run test:playwright-ct:all` should be run within
12+
their designated Docker containers before pushing changes to the repository.
13+
14+
## Tools
15+
16+
### Linters (ESlint, Markdownlint, Stylelint)
17+
18+
**On host:**
19+
20+
[Open][gh-gg-node-shell] `node_shell` Docker container:
21+
22+
```bash
23+
docker compose run --rm node_shell
24+
```
25+
26+
**Within `node_shell`:**
27+
28+
Run linters either all together:
29+
30+
```bash
31+
npm run lint
32+
```
33+
34+
or run linters individually:
35+
36+
```bash
37+
npm run <eslint|markdownlint|stylelint>
38+
```
39+
40+
### Jest
41+
42+
**On host:**
43+
44+
[Open][gh-gg-node-shell] `node_shell` Docker container:
45+
46+
```bash
47+
docker compose run --rm node_shell
48+
```
49+
50+
**Within `node_shell`:**
51+
52+
Run Jest tests:
53+
54+
```bash
55+
npm run test:jest
56+
```
57+
58+
### Playwright
59+
60+
Playwright tests must be run in a Docker container to ensure a uniform
61+
environment. Otherwise, snapshots would differ between operating systems.
62+
63+
This is the reason why you need to run Playwright tests separately
64+
from other tools.
65+
66+
#### Configuration
67+
68+
Test parameters can be tweaked by creating and tweaking `.env.playwright` file:
69+
70+
```bash
71+
cp .env.playwright.dist .env.playwright
72+
```
73+
74+
#### Running Tests
75+
76+
Playwright tests can be run using the following commands:
77+
78+
**On host:**
79+
80+
[Open][gh-gg-playwright] `playwright` Docker container:
81+
82+
```bash
83+
docker compose run --rm --service-ports playwright
84+
```
85+
86+
**Within `playwright`:**
87+
88+
Run tests:
89+
90+
```bash
91+
npm run test:playwright-ct:<all|all-with-update>
92+
```
93+
94+
You can also run specific tests by passing a path to the test files:
95+
96+
```bash
97+
npm run test:playwright-ct:<all|all-with-update> -- -- <match_path>
98+
```
99+
100+
You can also pass any [CLI command][playwright-cli] to the test runner:
101+
102+
```bash
103+
npm run test:playwright-ct:<all|all-with-update> -- -- <cli_argument>
104+
```
105+
106+
#### Opening Test Report
107+
108+
After running Playwright tests, test report can be served by using
109+
the following command:
110+
111+
```bash
112+
npm run test:playwright-ct:show-report
113+
```
114+
115+
Then open the displayed URL (typically `http://localhost:9323`)
116+
in your browser. Please note that the test report is only available
117+
if the tests were run prior to serving the report.
118+
119+
[gh-gg-node-shell]: ./general-guidelines.md#node-shell
120+
[gh-gg-playwright]: ./general-guidelines.md#playwright
121+
[playwright-cli]: https://playwright.dev/docs/test-cli#reference

0 commit comments

Comments
 (0)