|
4 | 4 |
|
5 | 5 | - [Jest](https://jestjs.io): A test framework used for assertions, mocks, spies, etc.
|
6 | 6 | - [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 |
8 | 7 |
|
9 | 8 | ## Test files
|
10 | 9 |
|
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). |
13 | 10 | - 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). |
18 | 13 |
|
19 | 14 | ## CLI commands
|
20 | 15 |
|
21 | 16 | ```bash
|
22 | 17 | # Run all tests
|
23 |
| -npm run test |
| 18 | +npm t |
24 | 19 |
|
25 | 20 | # Run test types
|
26 | 21 | npm run test:e2e
|
27 | 22 | npm run test:integration
|
28 | 23 | 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 |
29 | 32 |
|
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" |
32 | 35 |
|
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" |
35 | 38 |
|
36 |
| -# Run matching test name(s) |
37 |
| -npm run test -- -t \"describe() or test() name\" |
| 39 | +# ------------------------------------------------------------------------------ |
38 | 40 |
|
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 |
41 | 43 |
|
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 |
44 | 47 |
|
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" |
47 | 50 |
|
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 | +``` |
49 | 54 |
|
50 |
| -# Update snapshots for matching test files |
51 |
| -npm run test -- -u -i /path/to/*.test.js |
| 55 | +### E2E (Playwright) |
52 | 56 |
|
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 |
55 | 61 |
|
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" |
58 | 67 |
|
59 | 68 | # ------------------------------------------------------------------------------
|
60 | 69 |
|
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 |
66 | 72 |
|
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 |
68 | 76 |
|
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