Skip to content

Add test coverage for error.js utility module#831

Closed
Copilot wants to merge 2 commits into
error-handling-formsfrom
copilot/sub-pr-830
Closed

Add test coverage for error.js utility module#831
Copilot wants to merge 2 commits into
error-handling-formsfrom
copilot/sub-pr-830

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

The error.js utility module lacked test coverage despite having complex JSON parsing logic with escaped quote handling and brace matching.

Test coverage added:

  • extractErrorMessage: Tests for Axios errors (response.data), BPM SDK errors (response.body), Error objects, plain strings, and nested server error extraction from params arrays
  • extractServerErrorFromMessage edge cases: Escaped quotes (\"), nested JSON objects, malformed JSON, missing required fields, unbalanced braces, multiple JSON-like strings in single message
  • Form error detection: isFormElementError, isDeployedFormNotFoundError, extractDeployedFormName with resource name and key patterns

Example test for complex JSON extraction:

it('should extract nested server error from params', () => {
  const error = {
    response: {
      data: {
        params: ['Error occurred: {"type":"ProcessEngineException","message":"Engine error details"}']
      }
    }
  }
  expect(extractErrorMessage(error)).toBe('Engine error details')
})

it('should handle message with escaped quotes', () => {
  const error = {
    message: 'Error: {\\"type\\":\\"Exception\\",\\"message\\":\\"Escaped error\\"}'
  }
  expect(extractErrorMessage(error)).toBe('Escaped error')
})

58 test cases covering all exported functions, following existing test patterns from engineTokens.test.js and parser.test.js.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dmitrymalk <2931932+dmitrymalk@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • artifacts.cibseven.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npx vitest run src/__tests__/utils/error.test.js --reporter=verbose (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback on error handling improvements Add test coverage for error.js utility module Feb 16, 2026
Copilot AI requested a review from dmitrymalk February 16, 2026 07:46
@dmitrymalk dmitrymalk closed this Feb 16, 2026
@dmitrymalk dmitrymalk reopened this Feb 16, 2026
@dmitrymalk dmitrymalk closed this Feb 16, 2026
@dmitrymalk dmitrymalk deleted the copilot/sub-pr-830 branch February 16, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants