error.test.ts 732 B

123456789101112131415161718
  1. import { describe, expect, test } from "bun:test"
  2. import { AccountTransportError } from "../../src/account/schema"
  3. import { FormatError } from "../../src/cli/error"
  4. describe("cli.error", () => {
  5. test("formats account transport errors clearly", () => {
  6. const error = new AccountTransportError({
  7. method: "POST",
  8. url: "https://console.opencode.ai/auth/device/code",
  9. })
  10. const formatted = FormatError(error)
  11. expect(formatted).toContain("Could not reach POST https://console.opencode.ai/auth/device/code.")
  12. expect(formatted).toContain("This failed before the server returned an HTTP response.")
  13. expect(formatted).toContain("Check your network, proxy, or VPN configuration and try again.")
  14. })
  15. })