From 4756e59f8c71bcc9d2dd23d8581df0136cc83fd6 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Sat, 2 Dec 2023 12:21:27 -0600 Subject: [PATCH] Update test docs --- test/README.md | 82 +++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/test/README.md b/test/README.md index 7f8b847e9..8bd8beeb4 100644 --- a/test/README.md +++ b/test/README.md @@ -4,67 +4,79 @@ - [Jest](https://jestjs.io): A test framework used for assertions, mocks, spies, etc. - [Playwright](https://playwright.dev): A test automation tool for launching browsers and manipulating the DOM. -- [Jest-Playwright](https://github.com/playwright-community/jest-playwright): A Jest preset that simplifies using Jest and Playwright together ## Test files -- E2E tests are located in `/test/e2e/` and use [Jest](https://jestjs.io) + [Playwright](https://playwright.dev). -- Integration tests are located in `/test/integration/` and use [Jest](https://jestjs.io). - Unit tests located in `/test/unit/` and use [Jest](https://jestjs.io). - -## Global Variables - -- `process.env.TEST_HOST`: Test server ip:port +- Integration tests are located in `/test/integration/` and use [Jest](https://jestjs.io). +- E2E tests are located in `/test/e2e/` and use [Jest](https://jestjs.io) + [Playwright](https://playwright.dev). ## CLI commands ```bash # Run all tests -npm run test +npm t # Run test types npm run test:e2e npm run test:integration npm run test:unit +``` + +### Unit / Integration (Jest) + +```bash +# Run test file(s) +npm run test:unit -- -i ./path/to/file.test.js +npm run test:unit -- -i ./path/to/*.test.js -# Run test file -npm run test -- -i /path/to/file.test.js +# Run test name(s) +npm run test:unit -- -t "my test" -# Run matching test files -npm run test -- -i /path/to/*.test.js +# Run test name(s) in file +npm run test:unit -- -i ./path/to/file.test.js -t "my test" -# Run matching test name(s) -npm run test -- -t \"describe() or test() name\" +# ------------------------------------------------------------------------------ -# Run matching test name(s) in file -npm run test -- -i /path/to/file.test.js -t \"describe() or test() name\" +# Update snapshots +npm run test:unit -- -u -# Run all example tests -npm run test -- -i /test/**/example.test.js +# Update snapshots for test file(s) +npm run test:unit -- -u -i ./path/to/file.test.js +npm run test:unit -- -u -i ./path/to/*.test.js -# Run specific example test file -npm run test -- -i /path/to/example.test.js +# Update snapshots for test name(s) +npm run test:unit -- -u -t "my test" -# ------------------------------------------------------------------------------ +# Update snapshots for test name(s) in file +npm run test:unit -- -u -i ./path/to/file.test.js -t "my test" +``` -# Update snapshots for matching test files -npm run test -- -u -i /path/to/*.test.js +### E2E (Playwright) -# Update snapshots for matching test name(s) -npm run test -- -u -t \"describe() or test() name\" +```bash +# Run test file(s) +npm run test:e2e -- ./path/to/file.test.js +npm run test:e2e -- ./path/to/*.test.js -# Update snapshots for matching test name(s) in file -npm run test -- -u -i /path/to/file.test.js -t \"describe() or test() name\" +# Run test name(s) +npm run test:e2e -- -g "my test" + +# Run test name(s) in file +npm run test:e2e -- ./path/to/file.test.js -g "my test" # ------------------------------------------------------------------------------ -# Start manual test server instance. Useful for previewing test fixtures. -# Root: /test/e2e/fixtures/ -# Routes: /docs, /lib, -node ./test/config/server.js --start -``` +# Update snapshots +npm run test:e2e -- -u -## Resource +# Update snapshots for test file(s) +npm run test:e2e -- -u ./path/to/file.test.js +npm run test:e2e -- -u ./path/to/*.test.js -- [UI Testing Best Practices](https://github.com/NoriSte/ui-testing-best-practices) -- [Using Jest with Playwright](https://playwright.tech/blog/using-jest-with-playwright) +# Update snapshots for test name(s) +npm run test:e2e -- -u -g "my test" + +# Update snapshots for test name(s) in file +npm run test:e2e -- -u ./path/to/file.test.js -g "my test" +```