test(scripts): add Pester tests for linting scripts#237
Merged
WilliamBerryiii merged 10 commits intomainfrom Jan 22, 2026
Merged
test(scripts): add Pester tests for linting scripts#237WilliamBerryiii merged 10 commits intomainfrom
WilliamBerryiii merged 10 commits intomainfrom
Conversation
- Move Generate-PrReference.Tests.ps1 to dev-tools/ - Move Get-VerifiedDownload.Tests.ps1 to lib/ - Move Package-Extension.Tests.ps1 to extension/ - Move Prepare-Extension.Tests.ps1 to extension/ - Move LintingHelpers.Tests.ps1 to linting/ - Move Validate-MarkdownFrontmatter.Tests.ps1 to linting/ Related to #231 🤖 - Generated by Copilot
Adjust PSScriptRoot-relative paths to source files after moving tests into subdirectories. Related to #231 🤖 - Generated by Copilot
- add unit tests for Invoke-LinkLanguageCheck, Invoke-PSScriptAnalyzer - add unit tests for Link-Lang-Check, Markdown-Link-Check - add test fixtures for markdown link validation scenarios - fix array wrapping bug in Link-Lang-Check.ps1 🧪 - Generated by Copilot
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive Pester tests around the linting PowerShell scripts, introduces markdown/link fixtures to exercise those tests, and fixes a single-file edge case in Link-Lang-Check.ps1. It also aligns test script paths with the reorganized scripts/tests/* directory layout.
Changes:
- New unit and integration-style Pester suites for
Validate-MarkdownFrontmatter.ps1,Markdown-Link-Check.ps1,Link-Lang-Check.ps1,Invoke-PSScriptAnalyzer.ps1, andInvoke-LinkLanguageCheck.ps1, plus sharedLintingHelperstests. - New markdown and JSON fixtures under
scripts/tests/Fixtures/Linting/for valid/invalid links and anchor scenarios. - Bug fix in
Find-LinksInFileto always treatGet-Contentresults as an array, avoiding incorrect behavior on single-line files. - Updated existing tests under
scripts/tests/{lib,extension,dev-tools}to match the new directory structure.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/tests/linting/Validate-MarkdownFrontmatter.Tests.ps1 |
Adds unit and integration tests for frontmatter parsing, schema selection/validation, footer detection, git-changed-file grouping, and end-to-end validation behavior. |
scripts/tests/linting/Markdown-Link-Check.Tests.ps1 |
Tests Get-MarkdownTarget (git-aware and non-git modes), Get-RelativePrefix, and validates the link-check JSON config fixture; contains one OS-specific path assertion that will fail on Linux. |
scripts/tests/linting/LintingHelpers.Tests.ps1 |
Provides coverage for all exported helpers (changed-files discovery, recursive file enumeration, .gitignore parsing, and GitHub Actions output/env/summary helpers). |
scripts/tests/linting/Link-Lang-Check.Tests.ps1 |
Exercises Get-GitTextFile, Find-LinksInFile, Repair-LinksInFile, Repair-AllLink, and ConvertTo-JsonOutput using temp files to validate detection and repair of en-us URLs. |
scripts/tests/linting/Invoke-PSScriptAnalyzer.Tests.ps1 |
Adds tests around parameter validation, module-availability handling, file-discovery logic, GitHub Actions integration, JSON output, and exit-code behavior; current “module not installed” test will cause a real Install-Module call. |
scripts/tests/linting/Invoke-LinkLanguageCheck.Tests.ps1 |
Verifies presence of Invoke-LinkLanguageCheck.ps1/Link-Lang-Check.ps1, JSON parsing expectations, GitHub Actions helper exports, and basic output/summary semantics. |
scripts/tests/lib/Get-VerifiedDownload.Tests.ps1 |
Updates dot-source path to Get-VerifiedDownload.ps1 to account for the tests being moved under scripts/tests/lib/. |
scripts/tests/extension/Prepare-Extension.Tests.ps1 |
Adjusts the relative dot-source path to Prepare-Extension.ps1 to match the new scripts/tests/extension layout. |
scripts/tests/extension/Package-Extension.Tests.ps1 |
Adjusts the relative dot-source path to Package-Extension.ps1 after test directory reorganization. |
scripts/tests/dev-tools/Generate-PrReference.Tests.ps1 |
Fixes the dot-source path to Generate-PrReference.ps1 for the new scripts/tests/dev-tools location. |
scripts/tests/Fixtures/Linting/valid-links.md |
Fixture file containing only valid internal, external, and anchor links for link-check tests. |
scripts/tests/Fixtures/Linting/mixed-links.md |
Fixture mixing valid and invalid links (missing file, bad anchor) to exercise failure detection. |
scripts/tests/Fixtures/Linting/link-check-config.json |
JSON configuration fixture for markdown-link-check tests, including ignore/replacement patterns, headers, timeout, and retry options. |
scripts/tests/Fixtures/Linting/invalid-links.md |
Fixture with broken internal/anchor/malformed links to test error reporting. |
scripts/tests/Fixtures/Linting/anchors-test.md |
Fixture to validate anchor extraction and matching (including headings with dashes, underscores, and uppercase). |
scripts/linting/Link-Lang-Check.ps1 |
Fixes Find-LinksInFile to wrap Get-Content in @() so single-line files are always processed as an array of lines. |
- add ExcludePaths parameter to Link-Lang-Check.ps1 - pass ExcludePaths through Invoke-LinkLanguageCheck.ps1 wrapper - update package.json to exclude scripts/tests/** from lint:links 🔧 - Generated by Copilot
- fix BeforeAll path in Generate-PrReference.Tests.ps1 from ../ to ../../ - use IsPathRooted() for cross-platform absolute path validation - mock Install-Module to prevent network calls in unit tests 🔧 - Generated by Copilot
- workflow was calling script directly without exclusion parameter - test files containing intentional 'en-us' URLs are now excluded 🔧 - Generated by Copilot
…ity scripts - add ExcludePaths filtering tests to Link-Lang-Check.Tests.ps1 - add ExcludePaths filtering tests to Validate-MarkdownFrontmatter.Tests.ps1 - add ExcludePaths filtering tests to Test-DependencyPinning.Tests.ps1 🧪 - Generated by Copilot
- add invocation guard to Test-DependencyPinning.ps1 main block - simplify test file to use dot-source instead of AST extraction - fixes 5 Export-ComplianceReport test failures 🔧 - Generated by Copilot
katriendg
approved these changes
Jan 22, 2026
- rename misleading test to match actual behavior - rewrite GitHub Actions detection test to exercise env var 🧪 - Generated by Copilot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Add comprehensive Pester tests for four linting PowerShell scripts. This PR provides complete test coverage for the linting infrastructure and fixes a discovered bug in
Link-Lang-Check.ps1.Changes
New test files (4 files, 1,156 lines total):
Invoke-LinkLanguageCheck.Tests.ps1- Tests for link/language validation orchestrationInvoke-PSScriptAnalyzer.Tests.ps1- Tests for PowerShell static analysis wrapperLink-Lang-Check.Tests.ps1- Tests for link language checking with npx integrationMarkdown-Link-Check.Tests.ps1- Tests for markdown link validation with npx integrationTest fixtures (5 files):
anchors-test.md- Internal anchor link scenariosinvalid-links.md- Broken URL test caseslink-check-config.json- Configuration fixturemixed-links.md- Combined valid/invalid link scenariosvalid-links.md- Working URL test casesBug fix:
Link-Lang-Check.ps1- Fixed array wrapping onGet-Contentto handle single-file edge caseTest organization:
scripts/tests/linting/,scripts/tests/dev-tools/,scripts/tests/extension/,scripts/tests/lib/)Test Results
Related Issue(s)
Closes #231
Closes #190
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderagent and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md)Other:
.ps1,.sh,.py)Testing
All tests verified locally:
Test coverage includes:
Invoke-LinkLanguageCheck.ps1Invoke-PSScriptAnalyzer.ps1Link-Lang-Check.ps1Markdown-Link-Check.ps1Checklist
Required Checks
AI Artifact Contributions
N/A - This PR contains test files only.
Required Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run lint:md-linksnpm run lint:psSecurity Considerations
Additional Notes
Commits
12c17c2- test(scripts): add Pester tests for linting scripts0a2378f- fix(tests): update relative paths after reorganization (Related to [Issue]: Add unit tests for linting scripts to improve code coverage #231)c223639- refactor(tests): reorganize test directory to mirror source structure (Related to [Issue]: Add unit tests for linting scripts to improve code coverage #231)Files Changed (16 total)
scripts/linting/Link-Lang-Check.ps1scripts/tests/Fixtures/Linting/*.mdscripts/tests/linting/*.Tests.ps1scripts/tests/dev-tools/scripts/tests/extension/scripts/tests/lib/