holepunchto / brittle

Brittle TAP test framework
Apache License 2.0
81 stars 9 forks source link

serial makes all tests timeout when one does it #9

Closed mafintosh closed 3 years ago

mafintosh commented 3 years ago
const test = require('brittle')

// timeout here doesn't matter, just to speed up the test case
test.configure({ serial: true, timeout: 1000 })

test('a', async function (t) {
  await new Promise((resolve) => {
    setTimeout(resolve, 5000)
  })
  t.pass('a')
})

test('b', async function (t) {
  t.pass('b')
})

test('c', async function (t) {
  t.pass('c')
})

Running this resolves in all tests failing instead of just the first one:

TAP version 13
# a
    not ok 0 - test timed out after 1000ms
      ---
      actual:
        !error
        name: Error
        message: test timed out after 1000ms
        stack: |-
          Error: test timed out after 1000ms
              at listOnTimeout (node:internal/timers:557:17)
              at processTimers (node:internal/timers:500:7)
        code: ERR_TIMEOUT
        test: a
        plan: 0
        count: 0
        ended: false
      expected: null
      operator: execution
      ...

not ok 1 - a # time=1018.982875ms

# b
    not ok 0 - test timed out after 1000ms
      ---
      actual:
        !error
        name: Error
        message: test timed out after 1000ms
        stack: |-
          Error: test timed out after 1000ms
              at listOnTimeout (node:internal/timers:557:17)
              at processTimers (node:internal/timers:500:7)
        code: ERR_TIMEOUT
        test: b
        plan: 0
        count: 0
        ended: false
      expected: null
      operator: execution
      ...

not ok 2 - b # time=1020.934458ms

# c
    not ok 0 - test timed out after 1000ms
      ---
      actual:
        !error
        name: Error
        message: test timed out after 1000ms
        stack: |-
          Error: test timed out after 1000ms
              at listOnTimeout (node:internal/timers:557:17)
              at processTimers (node:internal/timers:500:7)
        code: ERR_TIMEOUT
        test: c
        plan: 0
        count: 0
        ended: false
      expected: null
      operator: execution
      ...

not ok 3 - c # time=1022.618125ms

1..3
# time=5008.828917ms
# failing=3