I wrote my example with Dessert
to make it generic. I did not find the exact solution, but found a way that will make TS tell me check my test files when some of the types are updated:
import { IsEqual } from 'type-fest'
const negativeStatusCases = ['pending', 'failed', 'cancelled', 'expired', 'in_progress'] as const
negativeStatusCases.forEach((negativeStatus) => {
describe(negativeStatus, () => {
it('shows message with variant of "warning"', async () => {
...
})
})
})
it('covers all non `succeeded` status cases', () => {
type Status = Awaited<ReturnType<typeof api.fetchPaymentStatus>>['status']
type NegativeStatus = Exclude<Status, 'succeeded'>
const allStatusCasesAreCovered: IsEqual<NegativeStatus, (typeof negativeStatusCases)[number]> = true
expect(allStatusCasesAreCovered).toBe(true)
})
hope it helps others