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

test_runner: only not working properly in subtests #49015

Closed
mcollina opened this issue Aug 4, 2023 · 1 comment
Closed

test_runner: only not working properly in subtests #49015

mcollina opened this issue Aug 4, 2023 · 1 comment

Comments

@mcollina
Copy link
Member

mcollina commented Aug 4, 2023

It seems there is some odd behavior with only and subtests, because I expected the following to pass:

const test = require('node:test')

test('this should be run', { only: true }, (t) => {
  t.test('this should be run', { only: true }, (t) => {
  })

  t.test('this should not be run', (t) => {
  })
})

But it's failing with an odd error

▶ this should be run
  ✔ this should be run (0.320833ms)
  ✖ this should not be run (0.216167ms)
    'test did not finish before its parent and was cancelled'

▶ this should be run (1.850417ms)

ℹ tests 3
ℹ suites 0
ℹ pass 1
ℹ fail 1
ℹ cancelled 1
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 0.11275

✖ failing tests:

✖ this should not be run (0.216167ms)
  'test did not finish before its parent and was cancelled'
@cjihrig
Copy link
Contributor

cjihrig commented Aug 4, 2023

This is working as documented:

When a test with the only option set is run, all subtests are also run. The test context's runOnly() method can be used to implement the same behavior at the subtest level.

@MoLow is already looking at improving this experience in #48932, so I'll close this issue.

@cjihrig cjihrig closed this as completed Aug 4, 2023
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

No branches or pull requests

2 participants