Skip to content

Commit 4756e59

Browse files
committed
Update test docs
1 parent 71a5fd3 commit 4756e59

File tree

1 file changed

+47
-35
lines changed

1 file changed

+47
-35
lines changed

test/README.md

+47-35
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,79 @@
44

55
- [Jest](https://jestjs.io): A test framework used for assertions, mocks, spies, etc.
66
- [Playwright](https://playwright.dev): A test automation tool for launching browsers and manipulating the DOM.
7-
- [Jest-Playwright](https://github.com/playwright-community/jest-playwright): A Jest preset that simplifies using Jest and Playwright together
87

98
## Test files
109

11-
- E2E tests are located in `/test/e2e/` and use [Jest](https://jestjs.io) + [Playwright](https://playwright.dev).
12-
- Integration tests are located in `/test/integration/` and use [Jest](https://jestjs.io).
1310
- Unit tests located in `/test/unit/` and use [Jest](https://jestjs.io).
14-
15-
## Global Variables
16-
17-
- `process.env.TEST_HOST`: Test server ip:port
11+
- Integration tests are located in `/test/integration/` and use [Jest](https://jestjs.io).
12+
- E2E tests are located in `/test/e2e/` and use [Jest](https://jestjs.io) + [Playwright](https://playwright.dev).
1813

1914
## CLI commands
2015

2116
```bash
2217
# Run all tests
23-
npm run test
18+
npm t
2419

2520
# Run test types
2621
npm run test:e2e
2722
npm run test:integration
2823
npm run test:unit
24+
```
25+
26+
### Unit / Integration (Jest)
27+
28+
```bash
29+
# Run test file(s)
30+
npm run test:unit -- -i ./path/to/file.test.js
31+
npm run test:unit -- -i ./path/to/*.test.js
2932

30-
# Run test file
31-
npm run test -- -i /path/to/file.test.js
33+
# Run test name(s)
34+
npm run test:unit -- -t "my test"
3235

33-
# Run matching test files
34-
npm run test -- -i /path/to/*.test.js
36+
# Run test name(s) in file
37+
npm run test:unit -- -i ./path/to/file.test.js -t "my test"
3538

36-
# Run matching test name(s)
37-
npm run test -- -t \"describe() or test() name\"
39+
# ------------------------------------------------------------------------------
3840

39-
# Run matching test name(s) in file
40-
npm run test -- -i /path/to/file.test.js -t \"describe() or test() name\"
41+
# Update snapshots
42+
npm run test:unit -- -u
4143

42-
# Run all example tests
43-
npm run test -- -i /test/**/example.test.js
44+
# Update snapshots for test file(s)
45+
npm run test:unit -- -u -i ./path/to/file.test.js
46+
npm run test:unit -- -u -i ./path/to/*.test.js
4447

45-
# Run specific example test file
46-
npm run test -- -i /path/to/example.test.js
48+
# Update snapshots for test name(s)
49+
npm run test:unit -- -u -t "my test"
4750

48-
# ------------------------------------------------------------------------------
51+
# Update snapshots for test name(s) in file
52+
npm run test:unit -- -u -i ./path/to/file.test.js -t "my test"
53+
```
4954

50-
# Update snapshots for matching test files
51-
npm run test -- -u -i /path/to/*.test.js
55+
### E2E (Playwright)
5256

53-
# Update snapshots for matching test name(s)
54-
npm run test -- -u -t \"describe() or test() name\"
57+
```bash
58+
# Run test file(s)
59+
npm run test:e2e -- ./path/to/file.test.js
60+
npm run test:e2e -- ./path/to/*.test.js
5561

56-
# Update snapshots for matching test name(s) in file
57-
npm run test -- -u -i /path/to/file.test.js -t \"describe() or test() name\"
62+
# Run test name(s)
63+
npm run test:e2e -- -g "my test"
64+
65+
# Run test name(s) in file
66+
npm run test:e2e -- ./path/to/file.test.js -g "my test"
5867

5968
# ------------------------------------------------------------------------------
6069

61-
# Start manual test server instance. Useful for previewing test fixtures.
62-
# Root: /test/e2e/fixtures/
63-
# Routes: /docs, /lib,
64-
node ./test/config/server.js --start
65-
```
70+
# Update snapshots
71+
npm run test:e2e -- -u
6672

67-
## Resource
73+
# Update snapshots for test file(s)
74+
npm run test:e2e -- -u ./path/to/file.test.js
75+
npm run test:e2e -- -u ./path/to/*.test.js
6876

69-
- [UI Testing Best Practices](https://github.com/NoriSte/ui-testing-best-practices)
70-
- [Using Jest with Playwright](https://playwright.tech/blog/using-jest-with-playwright)
77+
# Update snapshots for test name(s)
78+
npm run test:e2e -- -u -g "my test"
79+
80+
# Update snapshots for test name(s) in file
81+
npm run test:e2e -- -u ./path/to/file.test.js -g "my test"
82+
```

0 commit comments

Comments
 (0)