Skip to content

Commit 1d45895

Browse files
authored
fix(runner): mark tests of describe.todo as 'todo' (#7171)
1 parent 1dbf514 commit 1d45895

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

packages/runner/src/utils/collect.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export function interpretTaskModes(
6565
if (t.mode === 'skip') {
6666
skipAllTasks(t)
6767
}
68+
else if (t.mode === 'todo') {
69+
todoAllTasks(t)
70+
}
6871
else {
6972
traverseSuite(t, includeTask, hasLocationMatch)
7073
}
@@ -123,6 +126,16 @@ function skipAllTasks(suite: Suite) {
123126
}
124127
})
125128
}
129+
function todoAllTasks(suite: Suite) {
130+
suite.tasks.forEach((t) => {
131+
if (t.mode === 'run' || t.mode === 'queued') {
132+
t.mode = 'todo'
133+
if (t.type === 'suite') {
134+
todoAllTasks(t)
135+
}
136+
}
137+
})
138+
}
126139

127140
function checkAllowOnly(task: TaskBase, allowOnly?: boolean) {
128141
if (allowOnly) {

test/cli/fixtures/reported-tasks/1_first.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ describe('a group', () => {
6161
})
6262
})
6363

64+
describe.todo('todo group', () => {
65+
it('test inside todo group', () => {})
66+
})
67+
68+
describe.skip('skipped group', () => {
69+
it('test inside skipped group', () => {})
70+
})
71+
6472
describe.shuffle('shuffled group', () => {
6573
it('runs a test in a shuffled group', () => {
6674
expect(1).toBe(1)

test/cli/test/reported-tasks.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ it('correctly reports a file', () => {
5656
expect(testModule.location).toBeUndefined()
5757
expect(testModule.moduleId).toBe(resolve(root, './1_first.test.ts'))
5858
expect(testModule.project).toBe(project)
59-
expect(testModule.children.size).toBe(14)
59+
expect(testModule.children.size).toBe(16)
6060

6161
const tests = [...testModule.children.tests()]
6262
expect(tests).toHaveLength(11)
6363
const deepTests = [...testModule.children.allTests()]
64-
expect(deepTests).toHaveLength(19)
64+
expect(deepTests).toHaveLength(21)
6565

66-
expect([...testModule.children.allTests('skipped')]).toHaveLength(5)
67-
expect([...testModule.children.allTests('passed')]).toHaveLength(9)
68-
expect([...testModule.children.allTests('failed')]).toHaveLength(5)
69-
expect([...testModule.children.allTests('running')]).toHaveLength(0)
66+
expect.soft([...testModule.children.allTests('skipped')]).toHaveLength(7)
67+
expect.soft([...testModule.children.allTests('passed')]).toHaveLength(9)
68+
expect.soft([...testModule.children.allTests('failed')]).toHaveLength(5)
69+
expect.soft([...testModule.children.allTests('running')]).toHaveLength(0)
7070

7171
const suites = [...testModule.children.suites()]
72-
expect(suites).toHaveLength(3)
72+
expect(suites).toHaveLength(5)
7373
const deepSuites = [...testModule.children.allSuites()]
74-
expect(deepSuites).toHaveLength(4)
74+
expect(deepSuites).toHaveLength(6)
7575

7676
const diagnostic = testModule.diagnostic()
7777
expect(diagnostic).toBeDefined()
@@ -187,6 +187,12 @@ it('correctly reports test assigned options', () => {
187187
expect(testOptionTodo.options.mode).toBe('todo')
188188
const testModifierTodo = findTest(testModule.children, 'todos a .modifier test')
189189
expect(testModifierTodo.options.mode).toBe('todo')
190+
191+
const testInsideTodoDescribe = findTest(testModule.children, 'test inside todo group')
192+
expect(testInsideTodoDescribe.options.mode).toBe('todo')
193+
194+
const testInsideSkippedDescribe = findTest(testModule.children, 'test inside skipped group')
195+
expect(testInsideSkippedDescribe.options.mode).toBe('skip')
190196
})
191197

192198
it('correctly reports retried tests', () => {

0 commit comments

Comments
 (0)