Skip to content

Conversation

@Rozkalns
Copy link
Contributor

Overview

This PR introduces a new essentials:pest command that adds opinionated defaults to your Pest configuration. The command ensures your tests are more reliable and predictable by:

  • Preventing stray HTTP requests
  • Normalizing string and UUID generation
  • Faking sleep operations
  • Freezing time during tests
  • Configuring test paths for Feature and Unit tests

Credit & Inspiration

This feature was inspired by Nuno's livestream where he mentioned wanting to see such a command implemented. The configuration approach is based on his example in the vest-kits/laravel repository, which demonstrates these testing best practices in action.

Technical Note

Initially, I explored using PHP-Parser to modify the Pest configuration file programmatically. However, this approach proved challenging due to:

  • Complex AST transformations required
  • Difficulty preserving original code formatting and comments
  • Edge cases with different file structures

Instead, I opted for a simpler and more reliable approach of appending the configuration with clear section markers. While this might not be as sophisticated as AST manipulation, it's more maintainable and less prone to errors.

If you have a different vision for how this should be implemented, this PR can serve as a foundation for discussion and future improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant