@serenity-js/local-server 3.0.0-rc.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +73 -1880
  2. package/README.md +8 -10
  3. package/lib/index.d.ts +1 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +5 -1
  6. package/lib/index.js.map +1 -1
  7. package/lib/screenplay/abilities/ManageALocalServer.d.ts +50 -78
  8. package/lib/screenplay/abilities/ManageALocalServer.d.ts.map +1 -0
  9. package/lib/screenplay/abilities/ManageALocalServer.js +71 -69
  10. package/lib/screenplay/abilities/ManageALocalServer.js.map +1 -1
  11. package/lib/screenplay/abilities/index.d.ts +1 -0
  12. package/lib/screenplay/abilities/index.d.ts.map +1 -0
  13. package/lib/screenplay/abilities/index.js +5 -1
  14. package/lib/screenplay/abilities/index.js.map +1 -1
  15. package/lib/screenplay/index.d.ts +1 -0
  16. package/lib/screenplay/index.d.ts.map +1 -0
  17. package/lib/screenplay/index.js +5 -1
  18. package/lib/screenplay/index.js.map +1 -1
  19. package/lib/screenplay/interactions/StartLocalServer.d.ts +12 -48
  20. package/lib/screenplay/interactions/StartLocalServer.d.ts.map +1 -0
  21. package/lib/screenplay/interactions/StartLocalServer.js +16 -77
  22. package/lib/screenplay/interactions/StartLocalServer.js.map +1 -1
  23. package/lib/screenplay/interactions/StopLocalServer.d.ts +5 -22
  24. package/lib/screenplay/interactions/StopLocalServer.d.ts.map +1 -0
  25. package/lib/screenplay/interactions/StopLocalServer.js +5 -25
  26. package/lib/screenplay/interactions/StopLocalServer.js.map +1 -1
  27. package/lib/screenplay/interactions/index.d.ts +1 -0
  28. package/lib/screenplay/interactions/index.d.ts.map +1 -0
  29. package/lib/screenplay/interactions/index.js +5 -1
  30. package/lib/screenplay/interactions/index.js.map +1 -1
  31. package/lib/screenplay/questions/LocalServer.d.ts +8 -20
  32. package/lib/screenplay/questions/LocalServer.d.ts.map +1 -0
  33. package/lib/screenplay/questions/LocalServer.js +7 -20
  34. package/lib/screenplay/questions/LocalServer.js.map +1 -1
  35. package/lib/screenplay/questions/index.d.ts +1 -0
  36. package/lib/screenplay/questions/index.d.ts.map +1 -0
  37. package/lib/screenplay/questions/index.js +5 -1
  38. package/lib/screenplay/questions/index.js.map +1 -1
  39. package/package.json +29 -52
  40. package/src/screenplay/abilities/ManageALocalServer.ts +46 -79
  41. package/src/screenplay/interactions/StartLocalServer.ts +17 -84
  42. package/src/screenplay/interactions/StopLocalServer.ts +5 -26
  43. package/src/screenplay/questions/LocalServer.ts +7 -20
  44. package/tsconfig.build.json +10 -0
  45. package/tsconfig.eslint.json +0 -10
package/README.md CHANGED
@@ -1,18 +1,16 @@
1
1
  # Serenity/JS
2
2
 
3
- [Serenity/JS](https://serenity-js.org) is a framework designed to make acceptance and regression testing
4
- of modern full-stack applications faster, more collaborative and easier to scale.
3
+ [![Follow Serenity/JS on LinkedIn](https://img.shields.io/badge/Follow-Serenity%2FJS%20-0077B5?logo=linkedin)](https://www.linkedin.com/company/serenity-js)
4
+ [![Watch Serenity/JS on YouTube](https://img.shields.io/badge/Watch-@serenity--js-E62117?logo=youtube)](https://www.youtube.com/@serenity-js)
5
+ [![Join Serenity/JS Community Chat](https://img.shields.io/badge/Chat-Serenity%2FJS%20Community-FBD30B?logo=matrix)](https://matrix.to/#/#serenity-js:gitter.im)
6
+ [![Support Serenity/JS on GitHub](https://img.shields.io/badge/Support-@serenity--js-703EC8?logo=github)](https://matrix.to/#/#serenity-js:gitter.im)
5
7
 
6
- Visit [serenity-js.org](https://serenity-js.org/) for the [latest tutorials](https://serenity-js.org/handbook/)
7
- and [API docs](https://serenity-js.org/modules/), and follow [@SerenityJS](https://twitter.com/SerenityJS) and [@JanMolak](https://twitter.com/JanMolak) on Twitter for project updates.
8
+ [Serenity/JS](https://serenity-js.org) is an innovative framework designed to make acceptance and regression testing
9
+ of complex software systems faster, more collaborative and easier to scale.
8
10
 
9
- ### Learning Serenity/JS
11
+ To get started, check out the comprehensive [Serenity/JS Handbook](https://serenity-js.org/handbook), [API documentation](https://serenity-js.org/api/core), and [Serenity/JS project templates on GitHub](https://serenity-js.org/handbook/getting-started#serenityjs-project-templates).
10
12
 
11
- To learn more about Serenity/JS, check out the video below, read the [tutorial](https://serenity-js.org/handbook/thinking-in-serenity-js/index.html), review the [examples](https://github.com/serenity-js/serenity-js/tree/master/examples), and create your own test suite with [Serenity/JS template projects](https://github.com/serenity-js).
12
-
13
- If you have any questions, join us on [Serenity/JS Community Chat](https://gitter.im/serenity-js/Lobby).
14
-
15
- [![Full-Stack Acceptance Testing with Serenity/JS and the Screenplay Pattern](https://img.youtube.com/vi/djPMf-n93Rw/0.jpg)](https://www.youtube.com/watch?v=djPMf-n93Rw)
13
+ If you have any questions or just want to say hello, join the [Serenity/JS Community Chat](https://matrix.to/#/#serenity-js:gitter.im).
16
14
 
17
15
  ## Serenity/JS Local Server
18
16
 
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './screenplay';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
@@ -1,147 +1,119 @@
1
1
  /// <reference types="node" />
2
- import { Ability, UsesAbilities } from '@serenity-js/core';
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { Ability } from '@serenity-js/core';
3
5
  import * as http from 'http';
4
6
  import * as https from 'https';
5
7
  import * as net from 'net';
6
8
  /**
7
- * @desc
8
- * An {@link @serenity-js/core/lib/screenplay~Ability} that enables the {@link @serenity-js/core/lib/screenplay/actor~Actor}
9
- * to manage a local [Node.js](https://nodejs.org/) server.
9
+ * An {@apilink Ability} that enables an {@apilink Actor}
10
+ * to manage a local [Node.js](https://nodejs.org/) server.
10
11
  *
11
- * @example <caption>Using a raw Node.js server</caption>
12
- * import { Actor } from '@serenity-js/core';
13
- * import { CallAnApi, GetRequest, Send } from '@serenity-js/rest';
12
+ * ## Managing a raw Node.js server
13
+ *
14
+ * ```ts
15
+ * import { actorCalled } from '@serenity-js/core'
16
+ * import { CallAnApi, GetRequest, Send } from '@serenity-js/rest'
14
17
  * import { ManageALocalServer, LocalTestServer, StartLocalTestServer, StopLocalTestServer } from '@serenity-js/local-server'
15
- * import { Ensure, equals } from '@serenity-js/assertions';
18
+ * import { Ensure, equals } from '@serenity-js/assertions'
16
19
  *
17
- * import axios from 'axios';
18
- * import * as http from 'http';
20
+ * import * as axios from 'axios'
21
+ * import * as http from 'http'
19
22
  *
20
23
  * const server = http.createServer(function (request, response) {
21
- * response.setHeader('Connection', 'close');
22
- * response.end('Hello!');
24
+ * response.setHeader('Connection', 'close');
25
+ * response.end('Hello!');
23
26
  * })
24
27
  *
25
- * const actor = Actor.named('Apisit').whoCan(
28
+ * await actorCalled('Apisit')
29
+ * .whoCan(
26
30
  * ManageALocalServer.using(server),
27
31
  * CallAnApi.using(axios.create()),
28
- * );
29
- *
30
- * actor.attemptsTo(
32
+ * )
33
+ * .attemptsTo(
31
34
  * StartLocalTestServer.onRandomPort(),
32
35
  * Send.a(GetRequest.to(LocalServer.url())),
33
36
  * Ensure.that(LastResponse.status(), equals(200)),
34
37
  * Ensure.that(LastResponse.body<string>(), equals('Hello!')),
35
38
  * StopLocalTestServer.ifRunning(),
36
- * );
39
+ * )
40
+ * ```
37
41
  *
38
- * @see https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/
39
- * @see https://nodejs.org/api/http.html#http_class_http_server
42
+ * ## Learn more
43
+ * - [Anatomy of an HTTP transaction](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/)
44
+ * - [Node.js HTTP server](https://nodejs.org/api/http.html#http_class_http_server)
40
45
  *
41
- * @implements {@link @serenity-js/core/lib/screenplay~Ability}
46
+ * @group Abilities
42
47
  */
43
- export declare class ManageALocalServer implements Ability {
48
+ export declare class ManageALocalServer extends Ability {
44
49
  private readonly protocol;
45
50
  private readonly server;
46
51
  /**
47
- * @desc
48
- * {@link @serenity-js/core/lib/screenplay~Ability} to manage a Node.js HTTP server using the provided `requestListener`.
52
+ * An {@apilink Ability} to manage a Node.js HTTP server using the provided `requestListener`.
49
53
  *
50
- * @param {RequestListener | net~Server} listener
51
- * @returns {ManageALocalServer}
54
+ * @param listener
52
55
  */
53
56
  static runningAHttpListener(listener: RequestListener | net.Server): ManageALocalServer;
54
57
  /**
55
- * @desc
56
- * {@link @serenity-js/core/lib/screenplay~Ability} to manage a Node.js HTTPS server using the provided server `requestListener`.
58
+ * An {@apilink Ability} to manage a Node.js HTTPS server using the provided server `requestListener`.
57
59
  *
58
- * @param {RequestListener | https~Server} listener
59
- * @param {https~ServerOptions} options - Accepts options from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
60
- * @returns {ManageALocalServer}
60
+ * @param listener
61
+ * @param options
62
+ * Accepts an options object from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
61
63
  *
62
64
  * @see https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
63
65
  */
64
66
  static runningAHttpsListener(listener: RequestListener | https.Server, options?: https.ServerOptions): ManageALocalServer;
65
67
  /**
66
- * @desc
67
- * Used to access the {@link @serenity-js/core/lib/screenplay/actor~Actor}'s {@link @serenity-js/core/lib/screenplay~Ability} to {@link ManageALocalServer}
68
- * from within the {@link @serenity-js/core/lib/screenplay~Interaction} classes,
69
- * such as {@link StartLocalServer}.
70
- *
71
- * @param {@serenity-js/core/lib/screenplay~UsesAbilities} actor
72
- * @return {ManageALocalServer}
73
- */
74
- static as(actor: UsesAbilities): ManageALocalServer;
75
- /**
76
- * @param {string} protocol - Protocol to be used when communicating with the running server; `http` or `https`
68
+ * @param protocol
69
+ * Protocol to be used when communicating with the running server; `http` or `https`
77
70
  *
78
- * @param {net~Server} server - A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
71
+ * @param server
72
+ * A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
79
73
  *
80
74
  * @see https://www.npmjs.com/package/http-shutdown
81
75
  */
82
76
  constructor(protocol: SupportedProtocols, server: net.Server);
83
77
  /**
84
- * @desc
85
- * Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
78
+ * Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
86
79
  *
87
- * @param {number} [preferredPort=8000]
80
+ * @param [preferredPort=8000]
88
81
  * Lower bound of the preferred port range
89
82
  *
90
- * @param {number} [highestPort=65535] highestPort
83
+ * @param [highestPort=65535] highestPort
91
84
  * Upper bound of the preferred port range
92
- *
93
- * @returns {Promise<void>}
94
85
  */
95
86
  listen(preferredPort?: number, highestPort?: number): Promise<void>;
96
87
  /**
97
- * @desc
98
- * Provides access to the server requestListener
88
+ * Provides access to the server `requestListener`
99
89
  *
100
90
  * @param {function(server: ServerWithShutdown, protocol?: SupportedProtocols): T} fn
101
- * @returns {T}
102
91
  */
103
92
  mapInstance<T>(fn: (server: ServerWithShutdown, protocol?: SupportedProtocols) => T): T;
104
93
  }
105
94
  /**
106
- * @desc
107
- * A `requestListener` function that Node's
108
- * [`http.createServer`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener)
109
- * or [`https.createServer`](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener)
110
- * would accept.
111
- *
112
- * @public
113
- *
114
- * @typedef {function(request: http.IncomingMessage, response: http.ServerResponse): void} RequestListener
95
+ * A `requestListener` function accepted by Node's
96
+ * [`http.createServer`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener)
97
+ * or [`https.createServer`](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
115
98
  */
116
- export declare type RequestListener = (request: http.IncomingMessage, response: http.ServerResponse) => void;
99
+ export type RequestListener = (request: http.IncomingMessage, response: http.ServerResponse) => void;
117
100
  /**
118
- * @desc
119
- * A {@link net~Server} with an added shutdown method.
101
+ * A {@apilink net.Server} with an added shutdown method.
120
102
  *
121
103
  * @see https://www.npmjs.com/package/http-shutdown
122
- *
123
- * @public
124
- *
125
- * @typedef {net~Server & { shutdown: (callback: (error?: Error) => void) => void }} ServerWithShutdown
126
104
  */
127
- export declare type ServerWithShutdown = net.Server & {
105
+ export type ServerWithShutdown = net.Server & {
128
106
  shutdown: (callback: (error?: Error) => void) => void;
129
107
  forceShutdown: (callback: (error?: Error) => void) => void;
130
108
  };
131
109
  /**
132
- * @desc
133
- * The protocol supported by the instance of the {@link ServerWithShutdown},
134
- * wrapped by the {@link ManageALocalServer} {@link @serenity-js/core/lib/screenplay~Ability}.
135
- *
136
- * @see {@link ManageALocalServer#mapInstance}
137
- *
138
- * @public
110
+ * The protocol supported by the instance of the {@apilink ServerWithShutdown},
111
+ * wrapped by the {@apilink Ability|ability} to {@apilink ManageALocalServer}.
139
112
  *
140
- * @typedef {Object} SupportedProtocols
141
- * @property {string} HTTP
142
- * @property {string} HTTPS
113
+ * @group Models
143
114
  */
144
115
  export declare enum SupportedProtocols {
145
116
  HTTP = "http",
146
117
  HTTPS = "https"
147
118
  }
119
+ //# sourceMappingURL=ManageALocalServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ManageALocalServer.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/ManageALocalServer.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IA2C/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAzCrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,GAAG,kBAAkB;IAQvF;;;;;;;;OAQG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,GAAE,KAAK,CAAC,aAAkB,GAAG,kBAAkB;IAQ7H;;;;;;;;OAQG;gBAC0B,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM;IAK7E;;;;;;;;OAQG;IACH,MAAM,CAAC,aAAa,SAAO,EAAE,WAAW,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBhE;;;;OAIG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,kBAAkB,KAAK,CAAC,GAAG,CAAC;CAG1F;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,EAAE,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC;AAErG;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,GAAG;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;IACtD,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,kBAAkB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;CAClB"}
@@ -1,66 +1,79 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.SupportedProtocols = exports.ManageALocalServer = void 0;
4
27
  const core_1 = require("@serenity-js/core");
5
- const http = require("http");
28
+ const http = __importStar(require("http"));
6
29
  const withShutdownSupport = require("http-shutdown");
7
- const https = require("https");
30
+ const https = __importStar(require("https"));
8
31
  const portfinder_1 = require("portfinder");
9
32
  /**
10
- * @desc
11
- * An {@link @serenity-js/core/lib/screenplay~Ability} that enables the {@link @serenity-js/core/lib/screenplay/actor~Actor}
12
- * to manage a local [Node.js](https://nodejs.org/) server.
33
+ * An {@apilink Ability} that enables an {@apilink Actor}
34
+ * to manage a local [Node.js](https://nodejs.org/) server.
35
+ *
36
+ * ## Managing a raw Node.js server
13
37
  *
14
- * @example <caption>Using a raw Node.js server</caption>
15
- * import { Actor } from '@serenity-js/core';
16
- * import { CallAnApi, GetRequest, Send } from '@serenity-js/rest';
38
+ * ```ts
39
+ * import { actorCalled } from '@serenity-js/core'
40
+ * import { CallAnApi, GetRequest, Send } from '@serenity-js/rest'
17
41
  * import { ManageALocalServer, LocalTestServer, StartLocalTestServer, StopLocalTestServer } from '@serenity-js/local-server'
18
- * import { Ensure, equals } from '@serenity-js/assertions';
42
+ * import { Ensure, equals } from '@serenity-js/assertions'
19
43
  *
20
- * import axios from 'axios';
21
- * import * as http from 'http';
44
+ * import * as axios from 'axios'
45
+ * import * as http from 'http'
22
46
  *
23
47
  * const server = http.createServer(function (request, response) {
24
- * response.setHeader('Connection', 'close');
25
- * response.end('Hello!');
48
+ * response.setHeader('Connection', 'close');
49
+ * response.end('Hello!');
26
50
  * })
27
51
  *
28
- * const actor = Actor.named('Apisit').whoCan(
52
+ * await actorCalled('Apisit')
53
+ * .whoCan(
29
54
  * ManageALocalServer.using(server),
30
55
  * CallAnApi.using(axios.create()),
31
- * );
32
- *
33
- * actor.attemptsTo(
56
+ * )
57
+ * .attemptsTo(
34
58
  * StartLocalTestServer.onRandomPort(),
35
59
  * Send.a(GetRequest.to(LocalServer.url())),
36
60
  * Ensure.that(LastResponse.status(), equals(200)),
37
61
  * Ensure.that(LastResponse.body<string>(), equals('Hello!')),
38
62
  * StopLocalTestServer.ifRunning(),
39
- * );
63
+ * )
64
+ * ```
40
65
  *
41
- * @see https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/
42
- * @see https://nodejs.org/api/http.html#http_class_http_server
66
+ * ## Learn more
67
+ * - [Anatomy of an HTTP transaction](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/)
68
+ * - [Node.js HTTP server](https://nodejs.org/api/http.html#http_class_http_server)
43
69
  *
44
- * @implements {@link @serenity-js/core/lib/screenplay~Ability}
70
+ * @group Abilities
45
71
  */
46
- class ManageALocalServer {
47
- /**
48
- * @param {string} protocol - Protocol to be used when communicating with the running server; `http` or `https`
49
- *
50
- * @param {net~Server} server - A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
51
- *
52
- * @see https://www.npmjs.com/package/http-shutdown
53
- */
54
- constructor(protocol, server) {
55
- this.protocol = protocol;
56
- this.server = withShutdownSupport(server);
57
- }
72
+ class ManageALocalServer extends core_1.Ability {
58
73
  /**
59
- * @desc
60
- * {@link @serenity-js/core/lib/screenplay~Ability} to manage a Node.js HTTP server using the provided `requestListener`.
74
+ * An {@apilink Ability} to manage a Node.js HTTP server using the provided `requestListener`.
61
75
  *
62
- * @param {RequestListener | net~Server} listener
63
- * @returns {ManageALocalServer}
76
+ * @param listener
64
77
  */
65
78
  static runningAHttpListener(listener) {
66
79
  const server = typeof listener === 'function'
@@ -69,12 +82,11 @@ class ManageALocalServer {
69
82
  return new ManageALocalServer(SupportedProtocols.HTTP, server);
70
83
  }
71
84
  /**
72
- * @desc
73
- * {@link @serenity-js/core/lib/screenplay~Ability} to manage a Node.js HTTPS server using the provided server `requestListener`.
85
+ * An {@apilink Ability} to manage a Node.js HTTPS server using the provided server `requestListener`.
74
86
  *
75
- * @param {RequestListener | https~Server} listener
76
- * @param {https~ServerOptions} options - Accepts options from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
77
- * @returns {ManageALocalServer}
87
+ * @param listener
88
+ * @param options
89
+ * Accepts an options object from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
78
90
  *
79
91
  * @see https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
80
92
  */
@@ -85,28 +97,27 @@ class ManageALocalServer {
85
97
  return new ManageALocalServer(SupportedProtocols.HTTPS, server);
86
98
  }
87
99
  /**
88
- * @desc
89
- * Used to access the {@link @serenity-js/core/lib/screenplay/actor~Actor}'s {@link @serenity-js/core/lib/screenplay~Ability} to {@link ManageALocalServer}
90
- * from within the {@link @serenity-js/core/lib/screenplay~Interaction} classes,
91
- * such as {@link StartLocalServer}.
100
+ * @param protocol
101
+ * Protocol to be used when communicating with the running server; `http` or `https`
102
+ *
103
+ * @param server
104
+ * A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
92
105
  *
93
- * @param {@serenity-js/core/lib/screenplay~UsesAbilities} actor
94
- * @return {ManageALocalServer}
106
+ * @see https://www.npmjs.com/package/http-shutdown
95
107
  */
96
- static as(actor) {
97
- return actor.abilityTo(ManageALocalServer);
108
+ constructor(protocol, server) {
109
+ super();
110
+ this.protocol = protocol;
111
+ this.server = withShutdownSupport(server);
98
112
  }
99
113
  /**
100
- * @desc
101
- * Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
114
+ * Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
102
115
  *
103
- * @param {number} [preferredPort=8000]
116
+ * @param [preferredPort=8000]
104
117
  * Lower bound of the preferred port range
105
118
  *
106
- * @param {number} [highestPort=65535] highestPort
119
+ * @param [highestPort=65535] highestPort
107
120
  * Upper bound of the preferred port range
108
- *
109
- * @returns {Promise<void>}
110
121
  */
111
122
  listen(preferredPort = 8000, highestPort = 65535) {
112
123
  return (0, portfinder_1.getPortPromise)({ port: preferredPort, stopPort: highestPort })
@@ -125,11 +136,9 @@ class ManageALocalServer {
125
136
  }));
126
137
  }
127
138
  /**
128
- * @desc
129
- * Provides access to the server requestListener
139
+ * Provides access to the server `requestListener`
130
140
  *
131
141
  * @param {function(server: ServerWithShutdown, protocol?: SupportedProtocols): T} fn
132
- * @returns {T}
133
142
  */
134
143
  mapInstance(fn) {
135
144
  return fn(this.server, this.protocol);
@@ -137,17 +146,10 @@ class ManageALocalServer {
137
146
  }
138
147
  exports.ManageALocalServer = ManageALocalServer;
139
148
  /**
140
- * @desc
141
- * The protocol supported by the instance of the {@link ServerWithShutdown},
142
- * wrapped by the {@link ManageALocalServer} {@link @serenity-js/core/lib/screenplay~Ability}.
143
- *
144
- * @see {@link ManageALocalServer#mapInstance}
145
- *
146
- * @public
149
+ * The protocol supported by the instance of the {@apilink ServerWithShutdown},
150
+ * wrapped by the {@apilink Ability|ability} to {@apilink ManageALocalServer}.
147
151
  *
148
- * @typedef {Object} SupportedProtocols
149
- * @property {string} HTTP
150
- * @property {string} HTTPS
152
+ * @group Models
151
153
  */
152
154
  var SupportedProtocols;
153
155
  (function (SupportedProtocols) {
@@ -1 +1 @@
1
- {"version":3,"file":"ManageALocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/ManageALocalServer.ts"],"names":[],"mappings":";;;AAAA,4CAA+E;AAC/E,6BAA6B;AAC7B,qDAAsD;AACtD,+BAA+B;AAE/B,2CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,kBAAkB;IAkD3B;;;;;;OAMG;IACH,YAA6B,QAA4B,EAAE,MAAkB;QAAhD,aAAQ,GAAR,QAAQ,CAAoB;QACrD,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAvDD;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAsC;QAC9D,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,UAAU;YACzC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,QAAQ,CAAC;QAEf,OAAO,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,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G;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,qCAAe,CAAA;AACnB,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B"}
@@ -1 +1,2 @@
1
1
  export * from './ManageALocalServer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
@@ -1,3 +1,4 @@
1
1
  export * from './abilities';
2
2
  export * from './interactions';
3
3
  export * from './questions';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,8CAA4B"}
@@ -1,67 +1,31 @@
1
1
  import { Answerable, Interaction } from '@serenity-js/core';
2
2
  /**
3
- * @desc
4
- * Starts local server so that a test can interact with it.
3
+ * Starts local server so that a test can interact with it.
4
+ *
5
+ * @group Activities
5
6
  */
6
7
  export declare class StartLocalServer {
7
8
  /**
8
- * @desc
9
- * Starts local test server on a random available ports.
10
- *
11
- * @see {@link LocalServer.url}
12
- *
13
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
9
+ * Starts local test server on a random available ports.
14
10
  */
15
11
  static onRandomPort(): Interaction;
16
12
  /**
17
- * @desc
18
- * Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
19
- * to start a local test server on one of the preferred ports.
20
- *
21
- * Please note: this method is kept for backwards compatibility. However, its behaviour has changed
22
- * and is currently identical to calling `StartLocalServer.onPort` with the first of `preferredPorts`
23
- * passed as an argument.
24
- *
25
- * @param {@serenity-js/core/lib/screenplay~Answerable<number[]>} preferredPorts
26
- * A list of preferred ports. Please note that only the first one will be used!
13
+ * Instructs the {@apilink Actor} to start a local test server on a `preferredPort`,
14
+ * or a random one if that's not available.
27
15
  *
28
- * @see {@link LocalServer.url}
29
- * @see {@link StartLocalServer.onPort}
30
- * @see {@link StartLocalServer.onRandomPortBetween}
31
- *
32
- * @deprecated Use `StartLocalServer.onPort` or `StartLocalServer.onRandomPortBetween`
33
- *
34
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
35
- */
36
- static onOneOfThePreferredPorts(preferredPorts: Answerable<number[]>): Interaction;
37
- /**
38
- * @desc
39
- * Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
40
- * to start a local test server on a `preferredPort`, or a random one if that's not available.
41
- *
42
- * @param {@serenity-js/core/lib/screenplay~Answerable<number>} preferredPort
43
- * preferred port
44
- *
45
- * @see {@link LocalServer.url}
46
- * @see {@link @serenity-js/core/lib/screenplay~Answerable}
47
- *
48
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
16
+ * @param preferredPort
49
17
  */
50
18
  static onPort(preferredPort: Answerable<number>): Interaction;
51
19
  /**
52
- * @desc
53
- * Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
54
- * to start a local test server on a random port between `lowestPort` and `highestPort`.
20
+ * Instructs the {@apilink Actor} to start a local test server on a random port
21
+ * between `lowestPort` and `highestPort`, inclusive.
55
22
  *
56
- * @param {@serenity-js/core/lib/screenplay~Answerable<number>} lowestPort
23
+ * @param {Answerable<number>} lowestPort
57
24
  * Lower bound of the preferred port range
58
25
  *
59
- * @param {@serenity-js/core/lib/screenplay~Answerable<number>} highestPort
26
+ * @param {Answerable<number>} highestPort
60
27
  * Upper bound of the preferred port range
61
- *
62
- * @see {@link LocalServer.url}
63
- *
64
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
65
28
  */
66
29
  static onRandomPortBetween(lowestPort: Answerable<number>, highestPort: Answerable<number>): Interaction;
67
30
  }
31
+ //# sourceMappingURL=StartLocalServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartLocalServer.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/StartLocalServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuC,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAIhH;;;;GAIG;AACH,qBAAa,gBAAgB;IAEzB;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,WAAW;IAIlC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAI7D;;;;;;;;;OASG;IACH,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;CAG3G"}