Skip to content

tests: add unit coverage for scripts/docs-link-check.mjs #118

@IgorShevchik

Description

@IgorShevchik

Context

scripts/__tests__/ has unit tests for docs-lint.mjs (docs-lint.test.mjs) and docs-typecheck.mjs (docs-typecheck.test.mjs), but the third script in the docs-lint pipeline — scripts/docs-link-check.mjs — has zero unit coverage.

This came up during PR #116 review: a regression where 43 internal links silently rotted was not caught by the existing link-check. Even after we add a lint rule (#new-issue-from-PR-116), the rule's own behaviour should be pinned by tests.

Proposal

Create scripts/__tests__/docs-link-check.test.mjs modelled after the existing docs-lint.test.mjs fixture pattern (scripts/tests/docs-lint.test.mjs:132-177).

Suggested test cases:

  • Internal /docs/... paths
    • Resolves to a real page → passes.
    • Resolves to a missing page → reports as broken.
    • Resolves to a directory with 0.index.md → passes.
  • Heading fragments (#some-section)
    • Matches a real heading → passes.
    • Matches a slugged heading with -1/-2 suffix due to collision → passes.
    • References a missing heading → reports as broken.
  • Frontmatter links: - to: /docs/...
    • Real internal target → passes.
    • Missing internal target → reports as broken.
  • External URLs
    • https://example.com/... ignored entirely.
    • https://github.com/bitrix24/b24jssdk/blob/main/<path> either ignored (current behaviour) or checked (once #new-issue lands).

Acceptance criteria

  • scripts/__tests__/docs-link-check.test.mjs exists with at least the cases above.
  • pnpm run docs:lint:test runs them (the script already globs scripts/__tests__/**/*.test.mjs).
  • CI passes on main and would catch a future regression where a to: field rots.

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions