Skip to content

Conversation

Felsilva15
Copy link

PR Checklist

Overview

Add comprehensive test suite for the prototypes-to-classes exercise in the-typeinator project.

This PR adds the missing index.test.js file that was requested in issue #323. The test file includes:

  • Conditional test skipping: Tests are skipped when index.js is empty (learner mode), allowing students to start with clean files
  • Solution validation: Tests run properly when TEST_SOLUTIONS=true is set (validation mode)
  • Comprehensive coverage: Tests for both Robot and Humanoid classes including:
    • Class construction with proper properties
    • Method functionality (announce, charge, move)
    • Inheritance behavior (Humanoid extends Robot)
    • Console output validation with Jest mocks
    • Power management and error handling logic

The implementation follows the same pattern established in other test files in the repository, ensuring consistency with the educational workflow.

test(the-typeinator): add index.test.js for syntactic-sugar step
- Use jest.fn() instead of manual array for cleaner assertions
- Add missing machine objects to fix test failures
- Support TEST_SOLUTIONS environment variable
- Add comprehensive test suite for Robot and Humanoid classes
- Implement conditional test skipping for educational workflow
- Tests skip when index.js is empty (learner mode)
- Tests run with TEST_SOLUTIONS=true (validation mode)
- Cover class construction, inheritance, and method functionality
- Include console.log mocking for announce/charge/move methods
- Validate power management and error handling logic
@JoshuaKGoldberg
Copy link
Contributor

The implementation follows the same pattern established in other test files in the repository, ensuring consistency with the educational workflow.

By the way @Felsilva15, have you been writing these PR descriptions -or the PRs themselves?- largely with AI? They're very verbose. There's no need to explicitly call out every single detail in them, or end with this kind of high-level overview. 🙂

Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this also has the step 1 change from #321? See: #321 (comment)

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Sep 9, 2025
@felipe-hadrian
Copy link

@JoshuaKGoldberg - yes, I am using AI for the description since it has a template, and I thought it had to follow a specific format every single time. I’ll keep this in mind for the next PRs; I really appreciate the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author Needs an action taken by the original poster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: [the-typeinator] 02. Prototypes to Classes is missing tests
3 participants