* Test results. * - **pending**: Test was collected, but didn't finish running yet. * - **passed**: Test passed successfully * - **failed**: Test failed to execute * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
()
| 148 | * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`. |
| 149 | */ |
| 150 | public result(): TestResult { |
| 151 | const result = this.task.result |
| 152 | const mode = result?.state || this.task.mode |
| 153 | |
| 154 | if (!result && (mode === 'skip' || mode === 'todo')) { |
| 155 | return { |
| 156 | state: 'skipped', |
| 157 | note: undefined, |
| 158 | errors: undefined, |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (!result || result.state === 'run' || result.state === 'queued') { |
| 163 | return { |
| 164 | state: 'pending', |
| 165 | errors: undefined, |
| 166 | } |
| 167 | } |
| 168 | const state = result.state === 'fail' |
| 169 | ? 'failed' as const |
| 170 | : result.state === 'pass' |
| 171 | ? 'passed' as const |
| 172 | : 'skipped' as const |
| 173 | if (state === 'skipped') { |
| 174 | return { |
| 175 | state, |
| 176 | note: result.note, |
| 177 | errors: undefined, |
| 178 | } satisfies TestResultSkipped |
| 179 | } |
| 180 | if (state === 'passed') { |
| 181 | return { |
| 182 | state, |
| 183 | errors: result.errors as TestError[] | undefined, |
| 184 | } satisfies TestResultPassed |
| 185 | } |
| 186 | return { |
| 187 | state, |
| 188 | errors: (result.errors || []) as TestError[], |
| 189 | } satisfies TestResultFailed |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Test annotations added via the `task.annotate` API during the test execution. |
no outgoing calls