NO-JIRA: Add /gen-rtl-tests Claude code slash command for generating React Testing Library tests for React components
Add /gen-rtl-tests Claude code slash command for generating React Testing Library tests for React components
The /gen-rtl-tests uses the OCP Console React Testing Library Best Practices for React Components guide as a source of truth for test generation.
Usage
- /gen-rtl-test path/to/Component.tsx - Generate tests for a specific component
- /gen-rtl-test @Component.tsx` - Use `@` for file autocomplete, then select the file
- /gen-rtl-test` - Without arguments, you'll be prompted for the component
Objectives
- Establish consistent project-wide testing standards
- Promote user-centric testing that focuses on behavior over implementation
- Provide practical, rules-based guidance for common scenarios
- Improve test quality, resilience, and maintainability
Workflow
☒ Read and analyze <Component.tsx> ☒ Generate 5-10 comprehensive tests using Console RTL Best Practices for React Components ☒ Run generated tests ☒ Fix any test failures ☒ Fix act() warnings ☐ Run yarn build validation ☐ Verify all tests pass with zero warnings
@cajieh: This pull request explicitly references no jira issue.
In response to this:
Add /gen-rtl-tests Claude code slash command for generating React Testing Library tests for React components
The /gen-rtl-tests uses the OCP Console React Testing Library Best Practices for React Components guide as a source of truth for test generation.
Usage
- /gen-rtl-test path/to/Component.tsx - Generate tests for a specific component - /gen-rtl-test @Component.tsx` - Use `@` for file autocomplete, then select the file - /gen-rtl-test` - Without arguments, you'll be prompted for the componentObjectives
- Establish consistent project-wide testing standards
- Promote user-centric testing that focuses on behavior over implementation
- Provide practical, rules-based guidance for common scenarios
- Improve test quality, resilience, and maintainability
Workflow
☒ Read and analyze <Component.tsx> ☒ Generate 5-10 comprehensive tests using Console RTL Best Practices for React Components ☒ Run generated tests ☒ Fix any test failures ☒ Fix act() warnings ☐ Run yarn build validation ☐ Verify all tests pass with zero warnings
This proposed
/gen-rtl-testsslash command requires more testing for reliable and consistent output across multiple runs.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.
The PR looks good. I think we are missing the case when developer did some changes (added/modified some components) in which case Claude should check the
git diffand add/update the components. I think that could be the default use case when dev will not supply any arguments. If there are no valid components changes in thegit diffwe should be prompting the dev for name.Also I would also add a step where Claude will actually execute the added/modified tests to validate if they are passing.
Makes sense. 🙏
Walkthrough
A new documentation file is added at .claude/commands/generate-rtl-tests.md that outlines a comprehensive workflow and standards for generating React Testing Library tests, including usage instructions, component detection, testing principles, 26 rules, and validation procedures.
Changes
| Cohort / File(s) | Summary |
|---|---|
Documentation for RTL Test Generation \.claude/commands/generate-rtl-tests\.md |
Added new documentation file detailing comprehensive workflow and standards for React Testing Library test generation, including component detection, testing principles, 26 rules, test targets, verification steps, and validation procedures |
Estimated code review effort
🎯 1 (Trivial) | ⏱️ ~3 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Comment @coderabbitai help to get the list of available commands and usage tips.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: cajieh, jhadvig, sg00dwin
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [jhadvig]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/verified by @jhadvig
@cajieh: This PR has been marked as verified by @jhadvig.
In response to this:
/verified by @jhadvig
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.
/label jira/valid-bug
/retest
@cajieh: Can not set label jira/valid-bug: Must be member in one of these teams: [openshift-patch-managers openshift-staff-engineers openshift-release-oversight openshift-sustaining-engineers]
In response to this:
/label jira/valid-bug
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
/test okd-scos-images
/retest-required
Remaining retests: 0 against base HEAD 19b01f06cb8106dfe21ca3cc12dd5376a5935e39 and 2 for PR HEAD d65903e192919ed646440378c19c8b3481c2abdc in total
/retest-required
Remaining retests: 0 against base HEAD 9ac9e36e6bca30bd2b7f84752cc588f4cb842b44 and 1 for PR HEAD d65903e192919ed646440378c19c8b3481c2abdc in total
/retest-required
Remaining retests: 0 against base HEAD d3b540a070b976f490eb3259f963703f4c33200d and 0 for PR HEAD d65903e192919ed646440378c19c8b3481c2abdc in total
@cajieh: all tests passed!
Full PR test history. Your PR dashboard.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.