Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 21, 2025

  • Analyze the current codebase and understand how Scenario.only works
  • Examine test structure and existing Feature functionality (skip, etc.)
  • Implement Feature.only method in lib/mocha/ui.js
  • Add comprehensive test cases for Feature.only functionality
  • Test the implementation to ensure all scenarios in a feature run when Feature.only is used
  • Validate edge cases and ensure backward compatibility
  • Create integration tests to verify Feature.only works in real scenarios
  • Update documentation with Feature.only usage and examples
  • Validate implementation with comprehensive manual testing

✅ Complete Implementation

Feature.only functionality successfully implemented and tested

🎯 Core Implementation

  • Added Feature.only method in lib/mocha/ui.js
  • Uses regex pattern ^FeatureTitle: to match all scenarios in the target feature
  • Sets FEATURE_ONLY=true environment variable for detection
  • Uses same mocha.grep() mechanism as Scenario.only for consistency
  • Supports both with and without options

🧪 Comprehensive Testing

  • Unit Tests: 8 new tests covering basic functionality, options handling, pattern matching
  • Integration Tests: 2 tests confirming only target feature scenarios execute
  • Edge Cases: Special characters, empty features, complex titles all work correctly
  • Regression Tests: All 349 existing tests still pass - no breaking changes

📚 Documentation Updated

  • Added Feature.only to docs/basics.md Skipping section
  • Included practical code example showing usage
  • Added version badge indicating availability since 3.7.5

✅ Verified Behavior

Feature.only('My Important Feature');

Scenario('test something', ({ I }) => {
  // ✅ This will run
});

Feature('Another Feature');

Scenario('will not run', ({ I }) => {
  // ❌ This will be skipped
});

Result: Only scenarios in Feature.only execute, all others are skipped. Works with complex feature names, special characters, and edge cases. Maintains full backward compatibility.

Fixes #5086.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
@kobenguyent
Copy link
Collaborator

@copilot add types to Feature.only so that no typescript complains, add types tests as well

Copy link
Contributor Author

Copilot AI commented Aug 21, 2025

@copilot add types to Feature.only so that no typescript complains, add types tests as well

Added TypeScript types for Feature.only with comprehensive type tests. The changes include:

  • Added only: IFeature to the Feature interface
  • Enhanced IFeature to accept optional opts parameter matching the implementation
  • Fixed Feature global declaration to use interface instead of typeof
  • Added type tests for Feature.only with and without options
  • All TypeScript definitions now compile without errors

Commit: 0a2650e

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
@kobenguyent
Copy link
Collaborator

@copilot fix failed types test (npm run types-fix && tsd)

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 21, 2025

@copilot fix failed types test (npm run types-fix && tsd)

Fixed the failing TypeScript tests by correcting the expected return types for hook functions. The issue was that Before, BeforeSuite, After, and AfterSuite hooks were expected to return void but actually return HookConfig according to the implementation. Updated the type tests to expect CodeceptJS.HookConfig and all TypeScript tests now pass.

Commit: 7deb2cf

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
  • https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.168/linux64/chrome-linux64.zip
    • Triggering command: node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of kobenguyent August 21, 2025 15:05
@kobenguyent kobenguyent marked this pull request as ready for review August 21, 2025 15:12
@kobenguyent kobenguyent requested a review from thomashohn August 21, 2025 15:12
@kobenguyent kobenguyent merged commit ce16e92 into 3.x Aug 21, 2025
12 checks passed
@kobenguyent kobenguyent deleted the copilot/fix-5086 branch August 21, 2025 15:16
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.

[FR] - Support feature.only like Scenario.only
2 participants