runner icon indicating copy to clipboard operation
runner copied to clipboard

Discussion for a new feature - add tags filtering on tests groups

Open lefolalan opened this issue 1 year ago • 2 comments

Current State of Group Tagging in Japa

Overview

As of the current implementation, the Japa testing framework does not support applying tags directly to test groups via a group.tags() method. This limitation requires developers to individually tag each test within a group, which can be repetitive and error-prone for large test suites.

Current Workaround

Currently, developers must apply tags to each individual test:

test.group('Push Token Model Unit Tests', (group) => {
  // Setup hooks...

  test('should create a push token with valid data', async ({ assert }) => {
    // Test implementation...
  }).tags(['push_tokens'])

  test('should allow null deviceId', async ({ assert }) => {
    // Test implementation...
  }).tags(['push_tokens'])

  // Must repeat .tags(['push_tokens']) on every test...
})

Missing Feature: Group-Level Tagging

Desired Functionality

The community would benefit from a feature that allows applying tags at the group level:

// DESIRED: This doesn't currently work
test.group('Push Token Model Unit Tests', (group) => {
  group.tags(['push_tokens']) // ❌ Not supported

  test('should create a push token', async ({ assert }) => {
    // Would inherit 'push_tokens' tag automatically
  })

  test('should allow null deviceId', async ({ assert }) => {
    // Would inherit 'push_tokens' tag automatically
  })
})

Benefits of Group Tags

  1. DRY Principle: Avoid repeating tags on every test in a group
  2. Maintainability: Single place to manage tags for related tests
  3. Consistency: Ensure all tests in a group have the same tags
  4. Scalability: Easier to manage large test suites with many groups

Research Findings

GitHub Repository Status

  • japa/runner repository: No open issues related to group tags functionality
  • japa/core repository: No discussions about group-level tagging features
  • Official documentation: No mentions of group tags in current docs

Current Tag Support

Japa does support:

  • Individual test tagging with .tags(['tag_name'])
  • Tag filtering via CLI: node ace test --tags="tag_name"
  • Manual filter configuration in test setup

lefolalan avatar Sep 25 '25 09:09 lefolalan

You can apply by tapping into the tests.

group.tap((t) => t.tags(['tag_name']))

thetutlage avatar Sep 26 '25 11:09 thetutlage

Hi, thank you for your reply. I tested it, and it works just as expected! 💯

lefolalan avatar Sep 26 '25 13:09 lefolalan