-
Notifications
You must be signed in to change notification settings - Fork 11
test: add integration and unit tests with fixtures #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces comprehensive integration and unit tests using Node.js built-in test runner. Adds markdownlint before/after fixtures, snapshot testing, and a test README. Refactors diff generation logic for consistency and updates scripts in package.json to support testing and coverage.
Introduces a README.md in the markdownlint fixtures directory to document test cases for markdown formatting issues. Describes the purpose and structure of the test files used to verify the suggest-changes action.
Introduces a test workflow that runs on pull requests. The workflow sets up Node.js, installs dependencies, and executes tests using npm.
Added an 'engines' field to require Node.js version 20.9.0 or higher for compatibility and to prevent usage with unsupported Node.js versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces comprehensive testing infrastructure for the suggest-changes action, including both unit and integration tests using Node.js built-in test runner. The changes also refactor the diff generation logic for better consistency and modularity.
Key changes:
- Adds unit tests for core functions with mock dependencies and edge case coverage
- Implements integration tests with snapshot testing using fixture-based before/after file pairs
- Refactors git diff generation into a shared utility function for consistency
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/unit.test.js | Unit tests for generateCommentKey, createSuggestion, and run functions with mocked dependencies |
test/integration.test.js | Integration tests that discover fixture pairs and verify suggestion generation with snapshots |
test/integration.test.js.snapshot | Snapshot file containing expected output for markdownlint fixture tests |
test/fixtures/markdownlint/before.md | Test fixture with various markdown formatting issues for testing |
test/fixtures/markdownlint/after.md | Corrected version of markdown fixture showing expected formatting |
test/fixtures/markdownlint/README.md | Documentation explaining the markdownlint test fixtures and their purpose |
test/README.md | Comprehensive documentation for the testing setup, structure, and usage |
package.json | Adds test scripts and Node.js engine requirement for testing capabilities |
index.js | Refactors diff generation into shared getGitDiff function and updates parameter naming |
.github/workflows/test.yml | GitHub Actions workflow for running tests on pull requests |
Comments suppressed due to low confidence (2)
test/unit.test.js:99
- The test uses a minimal mock that only implements
listReviewComments
but doesn't test the case wherecreateReview
would be called. Consider adding a test that verifies the review creation path when comments are generated.
const result = await run({
// @ts-ignore - Test mock doesn't need full Octokit interface
octokit: mockOctokit,
test/unit.test.js:133
- This test expects
reviewCreated
to be true and comments to be generated, but the mock diff provided may not actually generate any comments through the real parsing logic. Consider using a diff that you've verified produces suggestions or mock thegenerateReviewComments
function.
const result = await run({
// @ts-ignore - Test mock doesn't need full Octokit interface
octokit: mockOctokit,
Removes the filter that excluded the 'duplicate-detection' directory from suggestion generation tests, ensuring all tool/testcase combinations are now covered.
Introduces comprehensive integration and unit tests using Node.js built-in test runner. Adds before/after fixtures, snapshot testing, and a test README. Refactors diff generation logic for consistency and updates scripts in
package.json
to support testing and coverage.