Skip to content

[jsweep] Clean error_codes.cjs#30935

Merged
pelikhan merged 1 commit intomainfrom
jsweep/error-codes-tests-1dd45006db05b8ce
May 8, 2026
Merged

[jsweep] Clean error_codes.cjs#30935
pelikhan merged 1 commit intomainfrom
jsweep/error-codes-tests-1dd45006db05b8ce

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 8, 2026

Summary

Adds comprehensive test coverage for error_codes.cjs, the module that provides standardized error code constants used throughout the safe-outputs handlers.

File Cleaned

actions/setup/js/error_codes.cjs — Node.js context (no GitHub Actions globals needed)

The file itself was already clean (@ts-check present, well-typed, good JSDoc). The missing piece was test coverage.

Changes

  • Created actions/setup/js/error_codes.test.cjs with 15 test cases

Test Coverage Added

Test Group Tests Description
module exports 2 Verifies all 9 exports exist and are strings
primary error codes 7 Asserts each primary code has the correct string value
legacy safe-output codes 2 Asserts E001 and E099 values
usage as error message prefixes 4 Verifies template literal usage, uniqueness across all codes

Total: 15 tests added

Validation ✅

  • Formatting: npx prettier --check error_codes.cjs error_codes.test.cjs
  • Type checking: npm run typecheck
  • Tests: npx vitest run error_codes.test.cjs → 15/15 passed ✓

Generated by jsweep - JavaScript Unbloater · ● 13.5M ·

  • expires on May 10, 2026, 4:55 AM UTC

Add 15 test cases covering all exported error code constants,
type verification, value correctness, usage as message prefixes,
and uniqueness guarantees.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review May 8, 2026 05:00
Copilot AI review requested due to automatic review settings May 8, 2026 05:00
@pelikhan pelikhan merged commit 4ee1275 into main May 8, 2026
11 checks passed
@pelikhan pelikhan deleted the jsweep/error-codes-tests-1dd45006db05b8ce branch May 8, 2026 05:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Vitest coverage for the standardized error code constants used by safe-outputs handlers.

Changes:

  • Added a new Vitest test suite covering actions/setup/js/error_codes.cjs exports, expected string values, and basic usage/uniqueness assertions.
Show a summary per file
File Description
actions/setup/js/error_codes.test.cjs Adds unit tests validating the error code constants’ exports, values, and uniqueness.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +19 to +23
it("exports string values only", () => {
const codes = [ERR_VALIDATION, ERR_PERMISSION, ERR_API, ERR_CONFIG, ERR_NOT_FOUND, ERR_PARSE, ERR_SYSTEM, SAFE_OUTPUT_E001, SAFE_OUTPUT_E099];
for (const code of codes) {
expect(typeof code).toBe("string");
}
@github-actions github-actions Bot mentioned this pull request May 8, 2026
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd based on the test-only nature of this PR.

Key Themes

  • Tautological value assertions: Tests like expect(ERR_VALIDATION).toBe("ERR_VALIDATION") verify that a constant equals a string matching its own name. These are low-signal — they pass trivially and would still pass if both the constant name and its value were renamed together.
  • Mechanics tests: The "can be used as a prefix" tests verify JavaScript template literal interpolation, not module behaviour. They don't surface real failure modes.
  • No negative/boundary tests: There is no test that the module does not export unexpected extras, or that the exported set is complete and stable.

Positive Highlights

  • ✅ Excellent describe grouping — the test structure reads as a clear specification.
  • ✅ Uniqueness tests (Set.size === array.length) are genuinely valuable — they would catch accidental duplicate values.
  • ✅ Comprehensive export coverage: all 9 exports verified to exist and be strings.
  • ✅ Clean separation between primary codes and legacy E00x codes.

Suggestion

The individual value assertions could be consolidated into a data-driven table test to reduce repetition and make future additions a one-liner:

it.each([
  ["ERR_VALIDATION", ERR_VALIDATION],
  ["ERR_PERMISSION", ERR_PERMISSION],
  ["ERR_API",        ERR_API],
  // ...
])("%s has the correct string value", (expected, actual) => {
  expect(actual).toBe(expected);
});

No blocking issues — commenting only.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 2.1M

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 8, 2026

🧪 Test Quality Sentinel Report

Test Quality Score: 55/100

🔶 Needs Improvement — score bounded by module nature (pure constants; no error paths exist to test)

Metric Value
New/modified tests analyzed 15
✅ Design tests (behavioral contracts) 15 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 0 (0%)
Duplicate test clusters 1
Test inflation detected N/A (test-retrofit PR; 0 production lines added)
🚨 Coding-guideline violations None

Test Classification Details

View all 15 tests
Test Classification Notes
exports all expected error codes ✅ Design API surface contract
exports string values only ✅ Design Type guarantee
ERR_VALIDATION is 'ERR_VALIDATION' ✅ Design Exact-value contract
ERR_PERMISSION is 'ERR_PERMISSION' ✅ Design Exact-value contract
ERR_API is 'ERR_API' ✅ Design Exact-value contract
ERR_CONFIG is 'ERR_CONFIG' ✅ Design Exact-value contract
ERR_NOT_FOUND is 'ERR_NOT_FOUND' ✅ Design Exact-value contract
ERR_PARSE is 'ERR_PARSE' ✅ Design Exact-value contract
ERR_SYSTEM is 'ERR_SYSTEM' ✅ Design Exact-value contract
SAFE_OUTPUT_E001 is 'E001' ✅ Design Verifies legacy value differs from constant name
SAFE_OUTPUT_E099 is 'E099' ✅ Design Verifies legacy value differs from constant name
can be used as a prefix in an Error message ✅ Design Usage/interpolation contract
can be used as a prefix in a setFailed-style string ✅ Design Usage/interpolation contract
all primary codes are distinct from each other ✅ Design Uniqueness invariant
legacy codes are distinct from primary codes ✅ Design Uniqueness invariant

Suggestions (Non-blocking)

Minor: Duplicate cluster in primary error codes suite

Seven individual it() blocks each assert expect(ERR_X).toBe("ERR_X") with trivially different constants. Consider a data-driven approach:

const primaryCodes = { ERR_VALIDATION, ERR_PERMISSION, ERR_API, ERR_CONFIG, ERR_NOT_FOUND, ERR_PARSE, ERR_SYSTEM };
for (const [name, value] of Object.entries(primaryCodes)) {
  it(`${name} equals its own name string`, () => expect(value).toBe(name));
}

This is a style suggestion only and does not block the verdict.


Score Breakdown

Component Points Notes
Behavioral coverage (40 pts) 40 15/15 design tests (100%)
Error/edge case coverage (30 pts) 0 No error paths in a constants module
Low duplication (20 pts) 15 1 cluster: 7 near-identical per-constant tests
Proportional growth (10 pts) 0 90 test lines added, 0 production lines changed
Total 55

i️ The low score reflects structural artefacts of this module (constants-only, no error paths, test-retrofit). The 0% implementation-test rate confirms all tests enforce genuine behavioral contracts.


Language Support

  • 🟨 JavaScript (*.test.cjs): 15 tests (vitest) — no mocking
  • 🐹 Go (*_test.go): 0 tests in this PR

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). No coding-guideline violations detected.

References: §25537761217

🧪 Test quality analysis by Test Quality Sentinel · ● 5.9M ·

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 55/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 15 tests enforce genuine behavioral contracts. The numeric score is bounded by the module's nature (pure constants; no error paths to test), not by test quality issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants