UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

30 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Discardable = void 0; /** * An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to free up * the resources it uses, e.g. disconnect from a database. * * This [`Discardable.discard`](https://serenity-js.org/api/core/class/Discardable/#discard) method is invoked directly by the [actor](https://serenity-js.org/api/core/class/Actor/), and indirectly by the [stage](https://serenity-js.org/api/core/class/Stage/): * - when [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/), for actors instantiated after [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. within a test scenario or in a "before each" hook * - when [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/), for actors instantiated before [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. in a "before all" hook * * Note that events such as [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/) and [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/) are emitted by Serenity/JS test runner adapters, * such as `@serenity-js/cucumber`, `@serenity-js/mocha`, `@serenity-js/jasmine`, and so on. * Consult their respective readmes to learn how to register them with your test runner of choice. * * ## Learn more * - [`Ability`](https://serenity-js.org/api/core/class/Ability/) * - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType) * - [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/) * * @group Abilities */ class Discardable { static isDiscardable(value) { return typeof (value['discard']) === 'function' && value['discard'].length === 0; } } exports.Discardable = Discardable; //# sourceMappingURL=Discardable.js.map