Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by group title also executes "root" tests #63

Closed
Julien-R44 opened this issue Sep 1, 2022 · 5 comments
Closed

Filter by group title also executes "root" tests #63

Julien-R44 opened this issue Sep 1, 2022 · 5 comments
Assignees
Labels
Type: Bug The issue has indentified a bug

Comments

@Julien-R44
Copy link
Member

Description

Hey !

I just noticed that when filtering by a group name, tests that are not in a group are also executed.

Exemple :

import { test } from '@japa/runner'

test.group('Maths.add', () => {
  test('hey', ({ assert }) => assert.isTrue(true))
})

test('root', () => console.log('Hey'))

When executing npm run test --groups Maths.add, the test root is also executed

Is this the desired behavior? It seems a bit weird to me, and I don't see anything related to it in the documentation
( By the way it would be awesome if we could have an Algolia search 😋 )

Package version

@japa/runner 2.0.8


If you confirm that this is not the desired behavior, I can take care of it and suggest a PR 👍

@thetutlage
Copy link
Collaborator

Is it not working with standalone Japa or was related to this adonisjs/assembler#51?

@Julien-R44
Copy link
Member Author

Yep, it's not related to this PR
I have the same behavior with standalone Japa

@thetutlage
Copy link
Collaborator

Ohh. I just noticed one thing. The command should be

npm run test -- --groups Maths.add

The additional -- forwards the flags to the underlying command. Otherwise the flags are meant for the npm cli.

@Julien-R44
Copy link
Member Author

Oh yes sorry, I know that. I just made a mistake: I use pnpm, and pnpm forwards the arguments well this way ( no need for -- )

I'll give you another example to make it clearer:

import { test } from '@japa/runner'

test.group('GroupOne', (group) => {
  test('My Test', ({ assert }) => {
    assert.isTrue(true)
  })
})

test.group('GroupTwo', (group) => {
  test('My Test', ({ assert }) => {
    assert.isTrue(true)
  })
})

test('Root', () => console.log('hey'))

npx ts-node test/index.ts --groups "GroupOne" executes "My test" and "Root" tests. So the "GroupTwo" is ignored, but not the "root" test that is not inside a group

@thetutlage
Copy link
Collaborator

Cool. Just wanted to make sure before giving it a go

@thetutlage thetutlage transferred this issue from japa/runner Sep 2, 2022
@thetutlage thetutlage self-assigned this Sep 2, 2022
@thetutlage thetutlage added the Type: Bug The issue has indentified a bug label Sep 2, 2022
thetutlage added a commit to japa/runner that referenced this issue Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue has indentified a bug
Projects
None yet
Development

No branches or pull requests

2 participants