docsify/test
i544693 78aaa377fd chore: add changelog v4.13.0 2022-10-26 21:50:32 +08:00
..
config fix: Legacy bugs (styles, site plugin error, and dev server error) (#1743) 2022-02-05 03:21:50 -06:00
e2e fix: fix search with no content. (#1878) 2022-09-17 19:01:35 +08:00
helpers refactor: Update test environments and lint configuration (#1736) 2022-01-30 21:40:21 -06:00
integration chore: add changelog v4.13.0 2022-10-26 21:50:32 +08:00
unit fix: fix test. 2022-10-26 21:27:14 +08:00
README.md refactor: Update test environments and lint configuration (#1736) 2022-01-30 21:40:21 -06:00

README.md

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.
  • Jest-Playwright: A Jest preset that simplifies using Jest and Playwright together

Test files

  • E2E tests are located in /test/e2e/ and use Jest + Playwright.
  • Integration tests are located in /test/integration/ and use Jest.
  • Unit tests located in /test/unit/ and use Jest.

Global Variables

  • process.env.TEST_HOST: Test server ip:port

CLI commands

# Run all tests
npm run test

# Run test types
npm run test:e2e
npm run test:integration
npm run test:unit

# Run test file
npm run test -- -i /path/to/file.test.js

# Run matching test files
npm run test -- -i /path/to/*.test.js

# 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\"

# Run all example tests
npm run test -- -i /test/**/example.test.js

# Run specific example test file
npm run test -- -i /path/to/example.test.js

# ------------------------------------------------------------------------------

# Update snapshots for matching test files
npm run test -- -u -i /path/to/*.test.js

# Update snapshots for matching test name(s)
npm run test -- -u -t \"describe() or test() name\"

# Update snapshots for matching test name(s) in file
npm run test -- -u -i /path/to/file.test.js -t \"describe() or test() name\"

# ------------------------------------------------------------------------------

# Start manual test server instance. Useful for previewing test fixtures.
# Root: /test/e2e/fixtures/
# Routes: /docs, /lib,
node ./test/config/server.js --start

Resource