import { test, expect, afterEach, afterAll } from 'vitest'
const rows = []
let release = () => {}
const row = (stage, value = {}) => rows.push({ stage, ...value })
afterEach(({ task }) => { row('afterEach', { errors: (task.result?.errors ?? []).map(error => error?.message ?? String(error)) }); release() })
afterAll(() => console.log('TASK_QUEUE_CONSUMER:' + JSON.stringify(rows)))
test('actual body throw bypasses the public queue', ({ task }) => {
  Object.defineProperty(task, 'promises', { configurable: true, get() { row('unexpected-queue-get'); throw new Error('queue must not be read') } })
  row('body-throw')
  const reason = new Error('actual body failure'); reason.stack = ''; throw reason
})
