From 9cbb683dcb10411d4aa37339b861061ce5f6ba49 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 5 Jul 2021 18:55:43 +0100 Subject: [PATCH] Spec: Define "error" event for global failures Ref https://github.com/qunitjs/qunit/issues/1633. --- spec/cri-draft.adoc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/cri-draft.adoc b/spec/cri-draft.adoc index 1e44007..6911a7d 100644 --- a/spec/cri-draft.adoc +++ b/spec/cri-draft.adoc @@ -189,6 +189,26 @@ Callback parameters: producer.on('testEnd', (testEnd) => { … }); ---- +=== `error` event + +The **error** event indicates a global failure. It may be emitted at any time, including before a <> or <>. + +Reporters must interpret error events as the <> having failed. Reporters should not wait for or expect other events to be emitted afterwards. For example, any pending <> or <> might not be delivered. If other events do get emitted after this, reporters should doubt their accuracy and may also ignore the event entirely. For example, if a <> is emitted _after_ an error event and the <> reports no failures, then reporters must still consider the <> as having failed. + +Callback parameters: + +* <> **error**. + +[source,javascript] +---- +producer.on('error', (error) => { … }); +---- + +[TIP] +===== +The "error" event is analogous to "Bail out!" lines as defined in https://testanything.org/tap-version-13-specification.html#directives[TAP specification]. +===== + == Event data The following data structures must be implemented as objects that have the specified fields as own properties. The objects are not required to be an instance of any specific class. They may be null-inherited objects, plain objects, or an instance of any public or private class. @@ -286,6 +306,16 @@ Producers may set additional (non-standard) properties on `Assertion` objects. The properties of the Assertion object was decided in https://github.com/js-reporters/js-reporters/issues/79[issue #79], and later revised by https://github.com/js-reporters/js-reporters/issues/105[issue #105]. ===== +=== Error + +The **Error** object may be an instance of the [ECMAScript Error Constructor](https://github.com/js-reporters/js-reporters/issues/123) (or a subclass of that). It may also be a plain object with the following properties: + +`Error` object: + +* `string` **name**: Error class name, or other prefix. +* `string` **message**: Error message. +* `string|undefined|null` **stack**: Optional stack trace. + == Producer API The object on which the Producer API is implemented does not need to be exclusive or otherwise limited to the Producer API. Producers are encouraged to implement the API as transparently as possible.