Skip to content

test(parse): add assertion for v6 inline reference behavior#4619

Merged
escapedcat merged 3 commits intomasterfrom
test/v6-parser-reference
Jan 31, 2026
Merged

test(parse): add assertion for v6 inline reference behavior#4619
escapedcat merged 3 commits intomasterfrom
test/v6-parser-reference

Conversation

@escapedcat
Copy link
Member

@escapedcat escapedcat commented Jan 31, 2026

User description

Verify that inline references are captured in the references array, documenting the behavioral change from v5 where they remained in body.

Answer to your co-maintainer:

"No, we initially did not have test coverage for where the inline reference went in v6. We only updated the expectation to body: null without verifying it was captured elsewhere. I've now added an assertion that confirms the reference is properly captured in the references[] array, documenting the v6 behavior change."


PR Type

Tests


Description

  • Add assertion verifying inline references captured in references array

  • Document v6 behavioral change from v5 where references remained in body

  • Verify reference object contains correct issue and prefix properties


Diagram Walkthrough

flowchart LR
  A["Inline reference in message"] -->|v6 behavior| B["Captured in references array"]
  B --> C["Assertion validates reference object"]
  C --> D["Confirms issue and prefix properties"]
Loading

File Walkthrough

Relevant files
Tests
index.test.ts
Add inline reference array assertion to parser test           

@commitlint/parse/src/index.test.ts

  • Added assertion to verify inline references are captured in references
    array
  • Validates reference object contains correct issue and prefix
    properties
  • Documents v6 behavioral change where inline references moved from body
    to references array
  • Uses expect.arrayContaining and expect.objectContaining for flexible
    matching
+9/-0     

Verify that inline references are captured in the references array,
documenting the behavioral change from v5 where they remained in body.
@qodo-code-review

This comment was marked as outdated.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 31, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@qodo-code-review

This comment was marked as outdated.

This comment was marked as resolved.

Add assertions to verify that:
- Both reference instances are captured (2 total)
- Body content with references moves to footer
- Each reference object includes the raw source line

This comprehensively documents the behavioral change from v5
(references stayed in body) to v6 (references move to footer).
@escapedcat
Copy link
Member Author

@knocte

@knocte
Copy link
Contributor

knocte commented Jan 31, 2026

Much better, but what about the "# some comment" thing?

Shouldn't that be in the body? or have an empty ref? or if it's supposed to be a comment in the sense that it should not appear in commit msg (because git should ignore it), then in that case it shouldn't even reach commitlint right?

Separate concerns for better clarity:
- Test 1: Inline reference parsing (verifies v6 moves body refs to footer)
- Test 2: Comment line filtering (verifies commentChar option works)

This addresses co-maintainer feedback about the confusing mixed test.
@escapedcat
Copy link
Member Author

Split into two tests to make this behaviour more clear

Answer:
No - the # some comment line is intentionally filtered out by the parser's commentChar option. This is working as designed:

  1. commentChar: "#" tells the parser to strip lines starting with # (like Git does)
  2. The line is completely removed - it doesn't appear in body, footer, or anywhere
  3. This was confusing because the original test mixed two concepts:
    • Inline reference parsing (the actual focus)
    • Comment filtering (a side effect of the setup)

@knocte
Copy link
Contributor

knocte commented Jan 31, 2026

LGTM

This was referenced Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants