This guide provides tips for debugging common issues when developing the Ably CLI.
- Check Logs: Look for errors or relevant messages in the CLI output, test runner output, server logs (for Web CLI tests), or browser console (for Web CLI tests).
- Isolate the Issue: Try to reproduce the problem with the simplest possible command or test case. Comment out parts of the code or test to narrow down the source of the error.
- Consult Documentation: Review relevant project docs (
docs/,AGENTS.md) and Ably documentation (https://ably.com/docs).
Refer to Testing.md for how to run specific tests.
console.log: Add temporaryconsole.logstatements in the test or the code being tested.- Mocking Issues (Unit/Integration):
- Verify mocks (
vitest,nock) are correctly set up and restored (beforeEach/afterEach). - Ensure stubs match the actual function signatures.
- Check that network requests are being intercepted as expected (e.g., using
nock.recorder).
- Verify mocks (
- E2E Failures:
- Credentials: Ensure
E2E_ABLY_API_KEY(and any other required keys) are correctly set in your environment (.envfile locally, secrets in CI). - Network: Check for network connectivity issues to Ably services.
- Resource Conflicts: Ensure previous test runs cleaned up resources correctly (e.g., unique channel names per test run).
- CI vs. Local: If tests fail only in CI, suspect environment differences (Node version, dependencies, permissions, resources). Check CI logs carefully.
- Credentials: Ensure
- Test Output: Playwright provides detailed error messages, including:
- The specific action that failed (e.g.,
locator.waitFor,expect.toContainText). - The expected vs. received values.
- Call logs showing the sequence of actions.
- The specific action that failed (e.g.,
- Error Context: Check the linked
error-context.mdfile intest-results/for screenshots, DOM snapshots, and console logs at the point of failure. - Browser Console: Add
page.on('console', ...)listeners in your test (as shown in.specstoryexamples) to capture browser logs. - Debugging UI Mode: Run Playwright with the UI for interactive debugging:
pnpm exec playwright test test/e2e/web-cli/web-cli.test.ts --ui
- Common Issues:
- Selector Timeouts: The element didn't appear within the timeout. Check if the server/app started correctly, if there were errors, or if the selector is correct.
- Incorrect Text/Assertions: The expected text doesn't match the actual text in the terminal (check for subtle differences like whitespace, case sensitivity, or ANSI codes if not using
toContainText). - Connection Errors: Check browser console logs and terminal server logs for WebSocket connection issues (e.g., wrong port, server crash,
ERR_CONNECTION_REFUSED). - Build Artifacts: Ensure the Web CLI example (
examples/web-cli) was built successfully (pnpm --filter ably-web-cli-example build) before the test runs, especially in CI.
- Run with Node Inspector:
Attach your debugger.
node --inspect-brk bin/run.js [your command and flags] - Verbose Flags: Use the CLI's built-in
--verboseflag if available for the command. - Oclif Debugging: Set the
DEBUGenvironment variable for oclif internal logs:DEBUG=oclif* bin/run.js [command] - Check Configuration: Use
ably config showto view stored credentials orably config pathto find the config file location.