mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
- Refactor methods names and functionality - Replace scroll listeners with observers - Replace Tweezer-based scrolling with native scroll methods - Remove tweezer.js dependency - Remove redundant method calls - Rename $resetEvents to onNavigate - Rename __scrollActiveSidebar to onRender - Remove __getAndActive - Remove __sticky - Add IntersectionObserver mock to Jest environment Also included: - Add e2e test “ui” and “chromium” scripts - Rename "jest" script to "test:jest" - Remove unused SSR code --------- Co-authored-by: Koy Zhuang <koy@ko8e24.top>
Docsify Testing
Environment
- Jest: A test framework used for assertions, mocks, spies, etc.
- Playwright: A test automation tool for launching browsers and manipulating the DOM.
Test files
- Unit tests located in
/test/unit/and use Jest. - Integration tests are located in
/test/integration/and use Jest. - E2E tests are located in
/test/e2e/and use Jest + Playwright.
CLI commands
# Run all tests
npm t
# Run test types
npm run test:e2e
npm run test:integration
npm run test:unit
Unit / Integration (Jest)
# 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 name(s)
npm run test:unit -- -t "my test"
# Run test name(s) in file
npm run test:unit -- -i ./path/to/file.test.js -t "my test"
# ------------------------------------------------------------------------------
# Update snapshots
npm run test:unit -- -u
# 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
# 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"
E2E (Playwright)
# Run test file(s)
npm run test:e2e -- ./path/to/file.test.js
npm run test:e2e -- ./path/to/*.test.js
# 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"
# ------------------------------------------------------------------------------
# Update snapshots
npm run test:e2e -- -u
# 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
# 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"