Skip to content

Respect nested only tests #9021

@jwerre

Description

@jwerre

Clear and concise description of the problem

Currently if you have an test.only inside a description.only all the tests under the description run. For example:

import { describe, it, expect } from 'vitest';

describe('My Component', () => {
	describe.only('Only run this suite of tests', () => {
		test.only('should be the only test that runs', () => {
			expect(true).toBe(true);
		});

		test('should not run because the previous test has an only', () => {
			throw new Error('This test should not run');
		});
	});

	describe('This suite of tests should never run and, correctly, do not', () => {
		test('...', () => {});
		test('...', () => {});
		test('...', () => {});
	});
});

Suggested solution

Tests with only should be the only test to run. This is the way Mocha works and is very useful when developing and debugging complex test suites.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions