Skip to content

Commit

Permalink
fix(runner): mark tests of describe.todo as 'todo' (#7171)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Jan 4, 2025
1 parent 1dbf514 commit 1d45895
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
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

0 comments on commit 1d45895

Please sign in to comment.