markwylde / assert-plan

The node assert library but with a plan method to check a certain amount of assertions are raised.
1 stars 0 forks source link

timeout isn't ideal #1

Open markwylde opened 2 years ago

markwylde commented 2 years ago

The node test runtime comes with it's own timeout.

But unfortunately I can't find a way of letting assertPlan know once the timeout has occurred, or even what the timeout specified was.

So in the end we kinda have to do something like this. IE specify a timeout on the actual test, and one slightly lower on the assertPlan.

test('test 2 assertions will timeout', { timeout: 2000 }, async t => {
  const assert = assertPlan(2, { timeout: 1500});

  assert.strictEqual(1, 1);

  await assert.wait();
});

Not sure the best solution.

markwylde commented 2 years ago

Hopefully there is a hook/feature I'm not aware of we can use: https://github.com/nodejs/node/issues/44125