You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
used with (e.g. hapi application, another framework, standalone, ...):
any other relevant information:
What problem are you trying to solve?
Simpler cleanup of failed (or time outed) tests.
Do you have a new or modified API suggestion to solve the problem?
Add an AbortControllersignal property to the flags parameter. This way a test can pass it on, eg.:
it('performs a fetch',async({ signal })=>{constreq=http.request('http://example.org',{ signal });const[res]=awaitEvents.onceee(req,'response');// Crashes since `onceee` does not exist.expect(res.statusCode).to.equal(200);});
Without the signal, the code crashes before any event emitters are added, which obviously causes the test to fail. However, the request continues processing. If it errors at any point, it will cause a process uncaughtException, which will cause whatever subsequent test that is running to fail.
With the signal, which lab should trigger at the same time as calling onCleanup, it will be guaranteed to cause a process uncaughtException, but this time it should be an immediate AbortError which can be ignored, causing no further harm. This is on top of the obvious effect of aborting the no longer relevant request.
Note: This feature overlaps with the existing onCleanup flag. Any code using non-async onCleanup, can assign the logic as an event listener:
it('does something',async({ signal })=>{signal.addEventListener('abort',()=>{/* onCleanup logic goes here */});// or even simplersignal.onabort=()=>{/* onCleanup logic goes here */};});
The text was updated successfully, but these errors were encountered:
Support plan
Context
What problem are you trying to solve?
Simpler cleanup of failed (or time outed) tests.
Do you have a new or modified API suggestion to solve the problem?
Add an
AbortController
signal
property to theflags
parameter. This way a test can pass it on, eg.:Without the
signal
, the code crashes before any event emitters are added, which obviously causes the test to fail. However, the request continues processing. If it errors at any point, it will cause a processuncaughtException
, which will cause whatever subsequent test that is running to fail.With the
signal
, which lab should trigger at the same time as callingonCleanup
, it will be guaranteed to cause a processuncaughtException
, but this time it should be an immediateAbortError
which can be ignored, causing no further harm. This is on top of the obvious effect of aborting the no longer relevant request.Note: This feature overlaps with the existing
onCleanup
flag. Any code using non-asynconCleanup
, can assign the logic as an event listener:The text was updated successfully, but these errors were encountered: