From bf7f46f529dd6ed95312202cd459b4a1d248529c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 00:13:41 +0000 Subject: [PATCH 1/2] test: Add unit tests for error handling utilities This commit adds a new test file, `core/util/errors.test.ts`, to provide test coverage for the `getRootCause` function and the `ContinueError` class. The tests for `getRootCause` verify its behavior with both nested and non-nested error objects. The tests for the `ContinueError` class ensure that the `reason` and `message` properties are set correctly during instantiation. --- core/util/errors.test.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core/util/errors.test.ts diff --git a/core/util/errors.test.ts b/core/util/errors.test.ts new file mode 100644 index 00000000000..63881000388 --- /dev/null +++ b/core/util/errors.test.ts @@ -0,0 +1,39 @@ +import { ContinueError, ContinueErrorReason, getRootCause } from './errors'; + +describe('getRootCause', () => { + test('should return the error itself when it has no cause', () => { + const err = new Error('This is an error'); + expect(getRootCause(err)).toBe(err); + }); + + test('should return the root cause of a nested error', () => { + const rootCause = new Error('This is the root cause'); + const err = new Error('This is an error', { cause: rootCause }); + expect(getRootCause(err)).toBe(rootCause); + }); + + test('should return the root cause of a deeply nested error', () => { + const rootCause = new Error('This is the root cause'); + const err1 = new Error('This is the first error', { cause: rootCause }); + const err2 = new Error('This is the second error', { cause: err1 }); + expect(getRootCause(err2)).toBe(rootCause); + }); +}); + +describe('ContinueError', () => { + test('should correctly set the reason and message', () => { + const reason = ContinueErrorReason.Unspecified; + const message = 'This is a test error'; + const err = new ContinueError(reason, message); + expect(err.reason).toBe(reason); + expect(err.message).toBe(message); + expect(err.name).toBe('ContinueError'); + }); + + test('should have an empty message if none is provided', () => { + const reason = ContinueErrorReason.Unspecified; + const err = new ContinueError(reason); + expect(err.reason).toBe(reason); + expect(err.message).toBe(""); + }); +}); From 38f77887d8523a1dafc16768d3fdf98b9878a366 Mon Sep 17 00:00:00 2001 From: "continue[bot]" Date: Wed, 17 Dec 2025 00:24:05 +0000 Subject: [PATCH 2/2] fix: Apply prettier formatting to errors.test.ts Generated with [Continue](https://continue.dev) Co-authored-by: nate Co-Authored-By: Continue --- core/util/errors.test.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/util/errors.test.ts b/core/util/errors.test.ts index 63881000388..a32a67c92a4 100644 --- a/core/util/errors.test.ts +++ b/core/util/errors.test.ts @@ -1,36 +1,36 @@ -import { ContinueError, ContinueErrorReason, getRootCause } from './errors'; +import { ContinueError, ContinueErrorReason, getRootCause } from "./errors"; -describe('getRootCause', () => { - test('should return the error itself when it has no cause', () => { - const err = new Error('This is an error'); +describe("getRootCause", () => { + test("should return the error itself when it has no cause", () => { + const err = new Error("This is an error"); expect(getRootCause(err)).toBe(err); }); - test('should return the root cause of a nested error', () => { - const rootCause = new Error('This is the root cause'); - const err = new Error('This is an error', { cause: rootCause }); + test("should return the root cause of a nested error", () => { + const rootCause = new Error("This is the root cause"); + const err = new Error("This is an error", { cause: rootCause }); expect(getRootCause(err)).toBe(rootCause); }); - test('should return the root cause of a deeply nested error', () => { - const rootCause = new Error('This is the root cause'); - const err1 = new Error('This is the first error', { cause: rootCause }); - const err2 = new Error('This is the second error', { cause: err1 }); + test("should return the root cause of a deeply nested error", () => { + const rootCause = new Error("This is the root cause"); + const err1 = new Error("This is the first error", { cause: rootCause }); + const err2 = new Error("This is the second error", { cause: err1 }); expect(getRootCause(err2)).toBe(rootCause); }); }); -describe('ContinueError', () => { - test('should correctly set the reason and message', () => { +describe("ContinueError", () => { + test("should correctly set the reason and message", () => { const reason = ContinueErrorReason.Unspecified; - const message = 'This is a test error'; + const message = "This is a test error"; const err = new ContinueError(reason, message); expect(err.reason).toBe(reason); expect(err.message).toBe(message); - expect(err.name).toBe('ContinueError'); + expect(err.name).toBe("ContinueError"); }); - test('should have an empty message if none is provided', () => { + test("should have an empty message if none is provided", () => { const reason = ContinueErrorReason.Unspecified; const err = new ContinueError(reason); expect(err.reason).toBe(reason);