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

fix(runner): mark tests of describe.todo as 'todo' #7171

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/runner/src/utils/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export function interpretTaskModes(
if (t.mode === 'skip') {
skipAllTasks(t)
}
else if (t.mode === 'todo') {
todoAllTasks(t)
}
else {
traverseSuite(t, includeTask, hasLocationMatch)
}
Expand Down Expand Up @@ -123,6 +126,16 @@ function skipAllTasks(suite: Suite) {
}
})
}
function todoAllTasks(suite: Suite) {
suite.tasks.forEach((t) => {
if (t.mode === 'run' || t.mode === 'queued') {
t.mode = 'todo'
if (t.type === 'suite') {
todoAllTasks(t)
}
}
})
}

function checkAllowOnly(task: TaskBase, allowOnly?: boolean) {
if (allowOnly) {
Expand Down
8 changes: 8 additions & 0 deletions test/cli/fixtures/reported-tasks/1_first.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ describe('a group', () => {
})
})

describe.todo('todo group', () => {
it('test inside todo group', () => {})
})

describe.skip('skipped group', () => {
it('test inside skipped group', () => {})
})

describe.shuffle('shuffled group', () => {
it('runs a test in a shuffled group', () => {
expect(1).toBe(1)
Expand Down
22 changes: 14 additions & 8 deletions test/cli/test/reported-tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ it('correctly reports a file', () => {
expect(testModule.location).toBeUndefined()
expect(testModule.moduleId).toBe(resolve(root, './1_first.test.ts'))
expect(testModule.project).toBe(project)
expect(testModule.children.size).toBe(14)
expect(testModule.children.size).toBe(16)

const tests = [...testModule.children.tests()]
expect(tests).toHaveLength(11)
const deepTests = [...testModule.children.allTests()]
expect(deepTests).toHaveLength(19)
expect(deepTests).toHaveLength(21)

expect([...testModule.children.allTests('skipped')]).toHaveLength(5)
expect([...testModule.children.allTests('passed')]).toHaveLength(9)
expect([...testModule.children.allTests('failed')]).toHaveLength(5)
expect([...testModule.children.allTests('running')]).toHaveLength(0)
expect.soft([...testModule.children.allTests('skipped')]).toHaveLength(7)
expect.soft([...testModule.children.allTests('passed')]).toHaveLength(9)
expect.soft([...testModule.children.allTests('failed')]).toHaveLength(5)
expect.soft([...testModule.children.allTests('running')]).toHaveLength(0)

const suites = [...testModule.children.suites()]
expect(suites).toHaveLength(3)
expect(suites).toHaveLength(5)
const deepSuites = [...testModule.children.allSuites()]
expect(deepSuites).toHaveLength(4)
expect(deepSuites).toHaveLength(6)

const diagnostic = testModule.diagnostic()
expect(diagnostic).toBeDefined()
Expand Down Expand Up @@ -187,6 +187,12 @@ it('correctly reports test assigned options', () => {
expect(testOptionTodo.options.mode).toBe('todo')
const testModifierTodo = findTest(testModule.children, 'todos a .modifier test')
expect(testModifierTodo.options.mode).toBe('todo')

const testInsideTodoDescribe = findTest(testModule.children, 'test inside todo group')
expect(testInsideTodoDescribe.options.mode).toBe('todo')

const testInsideSkippedDescribe = findTest(testModule.children, 'test inside skipped group')
expect(testInsideSkippedDescribe.options.mode).toBe('skip')
})

it('correctly reports retried tests', () => {
Expand Down
Loading