@serenity-js/local-server 3.41.2 → 3.42.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.
- package/CHANGELOG.md +12 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -0
- package/esm/screenplay/abilities/ManageALocalServer.d.ts +113 -0
- package/esm/screenplay/abilities/ManageALocalServer.d.ts.map +1 -0
- package/esm/screenplay/abilities/ManageALocalServer.js +132 -0
- package/esm/screenplay/abilities/ManageALocalServer.js.map +1 -0
- package/esm/screenplay/abilities/index.d.ts +2 -0
- package/esm/screenplay/abilities/index.d.ts.map +1 -0
- package/esm/screenplay/abilities/index.js +2 -0
- package/esm/screenplay/abilities/index.js.map +1 -0
- package/esm/screenplay/index.d.ts +4 -0
- package/esm/screenplay/index.d.ts.map +1 -0
- package/esm/screenplay/index.js +4 -0
- package/esm/screenplay/index.js.map +1 -0
- package/esm/screenplay/interactions/StartLocalServer.d.ts +32 -0
- package/esm/screenplay/interactions/StartLocalServer.d.ts.map +1 -0
- package/esm/screenplay/interactions/StartLocalServer.js +80 -0
- package/esm/screenplay/interactions/StartLocalServer.js.map +1 -0
- package/esm/screenplay/interactions/StopLocalServer.d.ts +19 -0
- package/esm/screenplay/interactions/StopLocalServer.d.ts.map +1 -0
- package/esm/screenplay/interactions/StopLocalServer.js +30 -0
- package/esm/screenplay/interactions/StopLocalServer.js.map +1 -0
- package/esm/screenplay/interactions/index.d.ts +3 -0
- package/esm/screenplay/interactions/index.d.ts.map +1 -0
- package/esm/screenplay/interactions/index.js +3 -0
- package/esm/screenplay/interactions/index.js.map +1 -0
- package/esm/screenplay/questions/LocalServer.d.ts +17 -0
- package/esm/screenplay/questions/LocalServer.d.ts.map +1 -0
- package/esm/screenplay/questions/LocalServer.js +53 -0
- package/esm/screenplay/questions/LocalServer.js.map +1 -0
- package/esm/screenplay/questions/index.d.ts +2 -0
- package/esm/screenplay/questions/index.d.ts.map +1 -0
- package/esm/screenplay/questions/index.js +2 -0
- package/esm/screenplay/questions/index.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -0
- package/lib/screenplay/abilities/ManageALocalServer.js +5 -2
- package/lib/screenplay/abilities/ManageALocalServer.js.map +1 -1
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.d.ts.map +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +3 -3
- package/lib/screenplay/index.d.ts.map +1 -1
- package/lib/screenplay/index.js +3 -3
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/StartLocalServer.js +4 -4
- package/lib/screenplay/interactions/StartLocalServer.js.map +1 -1
- package/lib/screenplay/interactions/StopLocalServer.js +2 -2
- package/lib/screenplay/interactions/StopLocalServer.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +2 -2
- package/lib/screenplay/interactions/index.d.ts.map +1 -1
- package/lib/screenplay/interactions/index.js +2 -2
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/questions/LocalServer.js +2 -2
- package/lib/screenplay/questions/LocalServer.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +1 -1
- package/lib/screenplay/questions/index.d.ts.map +1 -1
- package/lib/screenplay/questions/index.js +1 -1
- package/lib/screenplay/questions/index.js.map +1 -1
- package/package.json +32 -10
- package/src/index.ts +1 -1
- package/src/screenplay/abilities/ManageALocalServer.ts +1 -1
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +3 -3
- package/src/screenplay/interactions/StartLocalServer.ts +1 -1
- package/src/screenplay/interactions/StopLocalServer.ts +1 -1
- package/src/screenplay/interactions/index.ts +2 -2
- package/src/screenplay/questions/LocalServer.ts +1 -1
- package/src/screenplay/questions/index.ts +1 -1
- package/tsconfig-cjs.build.json +18 -0
- package/tsconfig-esm.build.json +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.42.0](https://github.com/serenity-js/serenity-js/compare/v3.41.2...v3.42.0) (2026-03-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** add dual ESM/CJS build support for Wave 2 packages ([0e2631c](https://github.com/serenity-js/serenity-js/commit/0e2631ca7cdbe68da7feec343eaf4f7fe9bb64d6))
|
|
12
|
+
* **core:** add ESM/CJS dual build support for web packages ([94c5a64](https://github.com/serenity-js/serenity-js/commit/94c5a6423dc369477bbabbacee5a54f8fca20209))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [3.41.2](https://github.com/serenity-js/serenity-js/compare/v3.41.1...v3.41.2) (2026-03-05)
|
|
7
19
|
|
|
8
20
|
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Ability } from '@serenity-js/core';
|
|
2
|
+
import * as http from 'http';
|
|
3
|
+
import * as https from 'https';
|
|
4
|
+
import type * as net from 'net';
|
|
5
|
+
/**
|
|
6
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) that enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
7
|
+
* to manage a local [Node.js](https://nodejs.org/) server.
|
|
8
|
+
*
|
|
9
|
+
* ## Managing a raw Node.js server
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
13
|
+
* import { CallAnApi, GetRequest, Send } from '@serenity-js/rest'
|
|
14
|
+
* import { ManageALocalServer, LocalTestServer, StartLocalServer, StopLocalServer } from '@serenity-js/local-server'
|
|
15
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
16
|
+
*
|
|
17
|
+
* import * as axios from 'axios'
|
|
18
|
+
* import * as http from 'http'
|
|
19
|
+
*
|
|
20
|
+
* const server = http.createServer(function (request, response) {
|
|
21
|
+
* response.setHeader('Connection', 'close');
|
|
22
|
+
* response.end('Hello!');
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* await actorCalled('Apisit')
|
|
26
|
+
* .whoCan(
|
|
27
|
+
* ManageALocalServer.runningAHttpListener(server),
|
|
28
|
+
* CallAnApi.using(axios.create()),
|
|
29
|
+
* )
|
|
30
|
+
* .attemptsTo(
|
|
31
|
+
* StartLocalServer.onRandomPort(),
|
|
32
|
+
* Send.a(GetRequest.to(LocalServer.url())),
|
|
33
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
34
|
+
* Ensure.that(LastResponse.body<string>(), equals('Hello!')),
|
|
35
|
+
* StopLocalServer.ifRunning(),
|
|
36
|
+
* )
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ## Learn more
|
|
40
|
+
* - [Anatomy of an HTTP transaction](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/)
|
|
41
|
+
* - [Node.js HTTP server](https://nodejs.org/api/http.html#http_class_http_server)
|
|
42
|
+
*
|
|
43
|
+
* @group Abilities
|
|
44
|
+
*/
|
|
45
|
+
export declare class ManageALocalServer extends Ability {
|
|
46
|
+
private readonly protocol;
|
|
47
|
+
private readonly server;
|
|
48
|
+
/**
|
|
49
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) to manage a Node.js HTTP server using the provided `requestListener`.
|
|
50
|
+
*
|
|
51
|
+
* @param listener
|
|
52
|
+
*/
|
|
53
|
+
static runningAHttpListener(listener: RequestListener | net.Server): ManageALocalServer;
|
|
54
|
+
/**
|
|
55
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) to manage a Node.js HTTPS server
|
|
56
|
+
* using the provided [`requestListener`](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
|
|
57
|
+
*
|
|
58
|
+
* @param listener
|
|
59
|
+
* @param options
|
|
60
|
+
* Accepts an options object from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
|
|
61
|
+
*/
|
|
62
|
+
static runningAHttpsListener(listener: RequestListener | https.Server, options?: https.ServerOptions): ManageALocalServer;
|
|
63
|
+
/**
|
|
64
|
+
* @param protocol
|
|
65
|
+
* Protocol to be used when communicating with the running server; `http` or `https`
|
|
66
|
+
*
|
|
67
|
+
* @param server
|
|
68
|
+
* A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
|
|
69
|
+
*/
|
|
70
|
+
constructor(protocol: SupportedProtocols, server: net.Server);
|
|
71
|
+
/**
|
|
72
|
+
* Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
|
|
73
|
+
*
|
|
74
|
+
* @param [preferredPort=8000]
|
|
75
|
+
* Lower bound of the preferred port range
|
|
76
|
+
*
|
|
77
|
+
* @param [highestPort=65535] highestPort
|
|
78
|
+
* Upper bound of the preferred port range
|
|
79
|
+
*/
|
|
80
|
+
listen(preferredPort?: number, highestPort?: number): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Provides access to the server `requestListener`
|
|
83
|
+
*
|
|
84
|
+
* @param {function(server: ServerWithShutdown, protocol?: SupportedProtocols): T} fn
|
|
85
|
+
*/
|
|
86
|
+
mapInstance<T>(fn: (server: ServerWithShutdown, protocol?: SupportedProtocols) => T): T;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A `requestListener` function accepted by Node's
|
|
90
|
+
* [`http.createServer`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener)
|
|
91
|
+
* or [`https.createServer`](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
|
|
92
|
+
*/
|
|
93
|
+
export type RequestListener = (request: http.IncomingMessage, response: http.ServerResponse) => void;
|
|
94
|
+
/**
|
|
95
|
+
* A [`net.Server`](https://nodejs.org/api/net.html#class-netserver) with
|
|
96
|
+
* an additional [`shutdown`](https://www.npmjs.com/package/http-shutdown) method.
|
|
97
|
+
*/
|
|
98
|
+
export type ServerWithShutdown = net.Server & {
|
|
99
|
+
shutdown: (callback: (error?: Error) => void) => void;
|
|
100
|
+
forceShutdown: (callback: (error?: Error) => void) => void;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The protocol supported by the instance of the [`ServerWithShutdown`](https://serenity-js.org/api/local-server/#ServerWithShutdown),
|
|
104
|
+
* wrapped by the [ability](https://serenity-js.org/api/core/class/Ability/)
|
|
105
|
+
* to [`ManageALocalServer`](https://serenity-js.org/api/local-server/class/ManageALocalServer/).
|
|
106
|
+
*
|
|
107
|
+
* @group Models
|
|
108
|
+
*/
|
|
109
|
+
export declare enum SupportedProtocols {
|
|
110
|
+
HTTP = "http",
|
|
111
|
+
HTTPS = "https"
|
|
112
|
+
}
|
|
113
|
+
//# 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,KAA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AMG;AACH,oBAAY,kBAAkB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;CAClB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Ability, ConfigurationError } from '@serenity-js/core';
|
|
2
|
+
import * as http from 'http';
|
|
3
|
+
import withShutdownSupport from 'http-shutdown';
|
|
4
|
+
import * as https from 'https';
|
|
5
|
+
import { getPortPromise } from 'portfinder';
|
|
6
|
+
/**
|
|
7
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) that enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
8
|
+
* to manage a local [Node.js](https://nodejs.org/) server.
|
|
9
|
+
*
|
|
10
|
+
* ## Managing a raw Node.js server
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
14
|
+
* import { CallAnApi, GetRequest, Send } from '@serenity-js/rest'
|
|
15
|
+
* import { ManageALocalServer, LocalTestServer, StartLocalServer, StopLocalServer } from '@serenity-js/local-server'
|
|
16
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
17
|
+
*
|
|
18
|
+
* import * as axios from 'axios'
|
|
19
|
+
* import * as http from 'http'
|
|
20
|
+
*
|
|
21
|
+
* const server = http.createServer(function (request, response) {
|
|
22
|
+
* response.setHeader('Connection', 'close');
|
|
23
|
+
* response.end('Hello!');
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* await actorCalled('Apisit')
|
|
27
|
+
* .whoCan(
|
|
28
|
+
* ManageALocalServer.runningAHttpListener(server),
|
|
29
|
+
* CallAnApi.using(axios.create()),
|
|
30
|
+
* )
|
|
31
|
+
* .attemptsTo(
|
|
32
|
+
* StartLocalServer.onRandomPort(),
|
|
33
|
+
* Send.a(GetRequest.to(LocalServer.url())),
|
|
34
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
35
|
+
* Ensure.that(LastResponse.body<string>(), equals('Hello!')),
|
|
36
|
+
* StopLocalServer.ifRunning(),
|
|
37
|
+
* )
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* ## Learn more
|
|
41
|
+
* - [Anatomy of an HTTP transaction](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/)
|
|
42
|
+
* - [Node.js HTTP server](https://nodejs.org/api/http.html#http_class_http_server)
|
|
43
|
+
*
|
|
44
|
+
* @group Abilities
|
|
45
|
+
*/
|
|
46
|
+
export class ManageALocalServer extends Ability {
|
|
47
|
+
protocol;
|
|
48
|
+
server;
|
|
49
|
+
/**
|
|
50
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) to manage a Node.js HTTP server using the provided `requestListener`.
|
|
51
|
+
*
|
|
52
|
+
* @param listener
|
|
53
|
+
*/
|
|
54
|
+
static runningAHttpListener(listener) {
|
|
55
|
+
const server = typeof listener === 'function'
|
|
56
|
+
? http.createServer(listener)
|
|
57
|
+
: listener;
|
|
58
|
+
return new ManageALocalServer(SupportedProtocols.HTTP, server);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) to manage a Node.js HTTPS server
|
|
62
|
+
* using the provided [`requestListener`](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
|
|
63
|
+
*
|
|
64
|
+
* @param listener
|
|
65
|
+
* @param options
|
|
66
|
+
* Accepts an options object from `tls.createServer()`, `tls.createSecureContext()` and `http.createServer()`.
|
|
67
|
+
*/
|
|
68
|
+
static runningAHttpsListener(listener, options = {}) {
|
|
69
|
+
const server = typeof listener === 'function'
|
|
70
|
+
? https.createServer(options, listener)
|
|
71
|
+
: listener;
|
|
72
|
+
return new ManageALocalServer(SupportedProtocols.HTTPS, server);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @param protocol
|
|
76
|
+
* Protocol to be used when communicating with the running server; `http` or `https`
|
|
77
|
+
*
|
|
78
|
+
* @param server
|
|
79
|
+
* A Node.js server requestListener, with support for [server shutdown](https://www.npmjs.com/package/http-shutdown).
|
|
80
|
+
*/
|
|
81
|
+
constructor(protocol, server) {
|
|
82
|
+
super();
|
|
83
|
+
this.protocol = protocol;
|
|
84
|
+
this.server = withShutdownSupport(server);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
|
|
88
|
+
*
|
|
89
|
+
* @param [preferredPort=8000]
|
|
90
|
+
* Lower bound of the preferred port range
|
|
91
|
+
*
|
|
92
|
+
* @param [highestPort=65535] highestPort
|
|
93
|
+
* Upper bound of the preferred port range
|
|
94
|
+
*/
|
|
95
|
+
listen(preferredPort = 8000, highestPort = 65535) {
|
|
96
|
+
return getPortPromise({ port: preferredPort, stopPort: highestPort })
|
|
97
|
+
.then(port => new Promise((resolve, reject) => {
|
|
98
|
+
function errorHandler(error) {
|
|
99
|
+
if (error.code === 'EADDRINUSE') {
|
|
100
|
+
return reject(new ConfigurationError(`Server address is in use. Is there another server running on port ${port}?`, error));
|
|
101
|
+
}
|
|
102
|
+
return reject(error);
|
|
103
|
+
}
|
|
104
|
+
this.server.once('error', errorHandler);
|
|
105
|
+
this.server.listen(port, '127.0.0.1', () => {
|
|
106
|
+
this.server.removeListener('error', errorHandler);
|
|
107
|
+
resolve();
|
|
108
|
+
});
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Provides access to the server `requestListener`
|
|
113
|
+
*
|
|
114
|
+
* @param {function(server: ServerWithShutdown, protocol?: SupportedProtocols): T} fn
|
|
115
|
+
*/
|
|
116
|
+
mapInstance(fn) {
|
|
117
|
+
return fn(this.server, this.protocol);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The protocol supported by the instance of the [`ServerWithShutdown`](https://serenity-js.org/api/local-server/#ServerWithShutdown),
|
|
122
|
+
* wrapped by the [ability](https://serenity-js.org/api/core/class/Ability/)
|
|
123
|
+
* to [`ManageALocalServer`](https://serenity-js.org/api/local-server/class/ManageALocalServer/).
|
|
124
|
+
*
|
|
125
|
+
* @group Models
|
|
126
|
+
*/
|
|
127
|
+
export var SupportedProtocols;
|
|
128
|
+
(function (SupportedProtocols) {
|
|
129
|
+
SupportedProtocols["HTTP"] = "http";
|
|
130
|
+
SupportedProtocols["HTTPS"] = "https";
|
|
131
|
+
})(SupportedProtocols || (SupportedProtocols = {}));
|
|
132
|
+
//# sourceMappingURL=ManageALocalServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManageALocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/ManageALocalServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,mBAAmB,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAO,kBAAmB,SAAQ,OAAO;IAwCd;IAtCZ,MAAM,CAAqB;IAE5C;;;;OAIG;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,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAwC,EAAE,UAA+B,EAAE;QACpG,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,UAAU;YACzC,CAAC,CAAC,KAAK,CAAC,YAAY,C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C,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACJ;AAkBD;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,qCAAe,CAAA;AACnB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Answerable } from '@serenity-js/core';
|
|
2
|
+
import { Interaction } from '@serenity-js/core';
|
|
3
|
+
/**
|
|
4
|
+
* Starts local server so that a test can interact with it.
|
|
5
|
+
*
|
|
6
|
+
* @group Activities
|
|
7
|
+
*/
|
|
8
|
+
export declare class StartLocalServer {
|
|
9
|
+
/**
|
|
10
|
+
* Starts local test server on a random available ports.
|
|
11
|
+
*/
|
|
12
|
+
static onRandomPort(): Interaction;
|
|
13
|
+
/**
|
|
14
|
+
* Instructs the [`Actor`](https://serenity-js.org/api/core/class/Actor/) to start a local test server on a `preferredPort`,
|
|
15
|
+
* or a random one if that's not available.
|
|
16
|
+
*
|
|
17
|
+
* @param preferredPort
|
|
18
|
+
*/
|
|
19
|
+
static onPort(preferredPort: Answerable<number>): Interaction;
|
|
20
|
+
/**
|
|
21
|
+
* Instructs the [`Actor`](https://serenity-js.org/api/core/class/Actor/) to start a local test server on a random port
|
|
22
|
+
* between `lowestPort` and `highestPort`, inclusive.
|
|
23
|
+
*
|
|
24
|
+
* @param {Answerable<number>} lowestPort
|
|
25
|
+
* Lower bound of the preferred port range
|
|
26
|
+
*
|
|
27
|
+
* @param {Answerable<number>} highestPort
|
|
28
|
+
* Upper bound of the preferred port range
|
|
29
|
+
*/
|
|
30
|
+
static onRandomPortBetween(lowestPort: Answerable<number>, highestPort: Answerable<number>): Interaction;
|
|
31
|
+
}
|
|
32
|
+
//# 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,KAAK,EAAE,UAAU,EAAsD,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;;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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Interaction } from '@serenity-js/core';
|
|
2
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Starts local server so that a test can interact with it.
|
|
5
|
+
*
|
|
6
|
+
* @group Activities
|
|
7
|
+
*/
|
|
8
|
+
export class StartLocalServer {
|
|
9
|
+
/**
|
|
10
|
+
* Starts local test server on a random available ports.
|
|
11
|
+
*/
|
|
12
|
+
static onRandomPort() {
|
|
13
|
+
return new StartLocalServerOnRandomPort();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Instructs the [`Actor`](https://serenity-js.org/api/core/class/Actor/) to start a local test server on a `preferredPort`,
|
|
17
|
+
* or a random one if that's not available.
|
|
18
|
+
*
|
|
19
|
+
* @param preferredPort
|
|
20
|
+
*/
|
|
21
|
+
static onPort(preferredPort) {
|
|
22
|
+
return new StartLocalServerOnPort(preferredPort);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Instructs the [`Actor`](https://serenity-js.org/api/core/class/Actor/) to start a local test server on a random port
|
|
26
|
+
* between `lowestPort` and `highestPort`, inclusive.
|
|
27
|
+
*
|
|
28
|
+
* @param {Answerable<number>} lowestPort
|
|
29
|
+
* Lower bound of the preferred port range
|
|
30
|
+
*
|
|
31
|
+
* @param {Answerable<number>} highestPort
|
|
32
|
+
* Upper bound of the preferred port range
|
|
33
|
+
*/
|
|
34
|
+
static onRandomPortBetween(lowestPort, highestPort) {
|
|
35
|
+
return new StartLocalServerOnRandomPortBetween(lowestPort, highestPort);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @package
|
|
40
|
+
*/
|
|
41
|
+
class StartLocalServerOnRandomPort extends Interaction {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(`#actor starts local server on a random port`);
|
|
44
|
+
}
|
|
45
|
+
async performAs(actor) {
|
|
46
|
+
await ManageALocalServer.as(actor).listen();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @package
|
|
51
|
+
*/
|
|
52
|
+
class StartLocalServerOnPort extends Interaction {
|
|
53
|
+
preferredPort;
|
|
54
|
+
constructor(preferredPort) {
|
|
55
|
+
super(`#actor starts local server on port ${preferredPort}`);
|
|
56
|
+
this.preferredPort = preferredPort;
|
|
57
|
+
}
|
|
58
|
+
async performAs(actor) {
|
|
59
|
+
const preferredPort = await actor.answer(this.preferredPort);
|
|
60
|
+
await ManageALocalServer.as(actor).listen(preferredPort);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @package
|
|
65
|
+
*/
|
|
66
|
+
class StartLocalServerOnRandomPortBetween extends Interaction {
|
|
67
|
+
lowestPort;
|
|
68
|
+
highestPort;
|
|
69
|
+
constructor(lowestPort, highestPort) {
|
|
70
|
+
super(`#actor starts local server on port between ${lowestPort} and ${highestPort}`);
|
|
71
|
+
this.lowestPort = lowestPort;
|
|
72
|
+
this.highestPort = highestPort;
|
|
73
|
+
}
|
|
74
|
+
async performAs(actor) {
|
|
75
|
+
const lowestPort = await actor.answer(this.lowestPort);
|
|
76
|
+
const highestPort = await actor.answer(this.highestPort);
|
|
77
|
+
await ManageALocalServer.as(actor).listen(lowestPort, highestPort);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=StartLocalServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StartLocalServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAEzB;;OAEG;IACH,MAAM,CAAC,YAAY;QACf,OAAO,IAAI,4BAA4B,EAAE,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,aAAiC;QAC3C,OAAO,IAAI,sBAAsB,CAAC,aAAa,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AC,CAAC;QAEzD,MAAM,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnswersQuestions, CollectsArtifacts, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { Interaction } from '@serenity-js/core';
|
|
3
|
+
/**
|
|
4
|
+
* Stops the local server. Should be used in `afterEach` block to make sure that the server
|
|
5
|
+
* is correctly shut down even when the test fails.
|
|
6
|
+
*
|
|
7
|
+
* @group Activities
|
|
8
|
+
*/
|
|
9
|
+
export declare class StopLocalServer extends Interaction {
|
|
10
|
+
/**
|
|
11
|
+
* Stops the server if it's running. If the server hasn't been started, this interaction does nothing.
|
|
12
|
+
*/
|
|
13
|
+
static ifRunning(): Interaction;
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=StopLocalServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopLocalServer.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/StopLocalServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAE5C;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,WAAW;IAI/B;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAaxF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Interaction } from '@serenity-js/core';
|
|
2
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stops the local server. Should be used in `afterEach` block to make sure that the server
|
|
5
|
+
* is correctly shut down even when the test fails.
|
|
6
|
+
*
|
|
7
|
+
* @group Activities
|
|
8
|
+
*/
|
|
9
|
+
export class StopLocalServer extends Interaction {
|
|
10
|
+
/**
|
|
11
|
+
* Stops the server if it's running. If the server hasn't been started, this interaction does nothing.
|
|
12
|
+
*/
|
|
13
|
+
static ifRunning() {
|
|
14
|
+
return new StopLocalServer(`#actor stops the local server`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
performAs(actor) {
|
|
20
|
+
return ManageALocalServer.as(actor).mapInstance(server => new Promise((resolve, reject) => {
|
|
21
|
+
if (!server.address()) {
|
|
22
|
+
return resolve();
|
|
23
|
+
}
|
|
24
|
+
server.shutdown((error) => error
|
|
25
|
+
? reject(error)
|
|
26
|
+
: resolve());
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=StopLocalServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StopLocalServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAE5C;;OAEG;IACH,MAAM,CAAC,SAAS;QACZ,OAAO,IAAI,eAAe,CAAC,+BAA+B,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAA2D;QACjE,OAAO,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtF,IAAI,CAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;gBACrB,OAAO,OAAO,EAAE,CAAC;YACrB,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAY,EAAE,EAAE,CAC7B,KAAK;gBACD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBACf,CAAC,CAAC,OAAO,EAAE,CAClB,CAAC;QACN,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { QuestionAdapter } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* @group Questions
|
|
4
|
+
*/
|
|
5
|
+
export declare class LocalServer {
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the URL of the local server started
|
|
8
|
+
* using the [`StartLocalServer`](https://serenity-js.org/api/local-server/class/StartLocalServer/) [interaction](https://serenity-js.org/api/core/class/Interaction/).
|
|
9
|
+
*/
|
|
10
|
+
static url(): QuestionAdapter<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the port number of the local server started
|
|
13
|
+
* using the [`StartLocalServer`](https://serenity-js.org/api/local-server/class/StartLocalServer/) [interaction](https://serenity-js.org/api/core/class/Interaction/).
|
|
14
|
+
*/
|
|
15
|
+
static port(): QuestionAdapter<number>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=LocalServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalServer.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/LocalServer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD;;GAEG;AACH,qBAAa,WAAW;IAEpB;;;OAGG;IACH,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC;IAwBrC;;;OAGG;IACH,MAAM,CAAC,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC;CAOzC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
import { LogicError, Question } from '@serenity-js/core';
|
|
3
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* @group Questions
|
|
6
|
+
*/
|
|
7
|
+
export class LocalServer {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the URL of the local server started
|
|
10
|
+
* using the [`StartLocalServer`](https://serenity-js.org/api/local-server/class/StartLocalServer/) [interaction](https://serenity-js.org/api/core/class/Interaction/).
|
|
11
|
+
*/
|
|
12
|
+
static url() {
|
|
13
|
+
return Question.about('the URL of the local server', actor => {
|
|
14
|
+
return ManageALocalServer.as(actor).mapInstance((server, protocol) => {
|
|
15
|
+
const info = server.address();
|
|
16
|
+
if (!info) {
|
|
17
|
+
throw new LogicError(`The server has not been started yet`);
|
|
18
|
+
}
|
|
19
|
+
if (!isAddressInfo(info)) {
|
|
20
|
+
throw new LogicError(`A pipe or UNIX domain socket server does not have a URL`);
|
|
21
|
+
}
|
|
22
|
+
return [
|
|
23
|
+
protocol,
|
|
24
|
+
'://',
|
|
25
|
+
`${info.family}`.toLowerCase() === 'ipv6' ? `[${info.address}]` : info.address,
|
|
26
|
+
':',
|
|
27
|
+
info.port,
|
|
28
|
+
].join('');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the port number of the local server started
|
|
34
|
+
* using the [`StartLocalServer`](https://serenity-js.org/api/local-server/class/StartLocalServer/) [interaction](https://serenity-js.org/api/core/class/Interaction/).
|
|
35
|
+
*/
|
|
36
|
+
static port() {
|
|
37
|
+
return Question.about(`local server port number`, async (actor) => {
|
|
38
|
+
const url = await actor.answer(LocalServer.url());
|
|
39
|
+
return Number.parseInt(new URL(url).port, 10);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @param maybeAddressInfo
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
function isAddressInfo(maybeAddressInfo) {
|
|
48
|
+
return typeof maybeAddressInfo !== 'string'
|
|
49
|
+
&& !!maybeAddressInfo.address
|
|
50
|
+
&& !!maybeAddressInfo.family
|
|
51
|
+
&& !!maybeAddressInfo.port;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=LocalServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LocalServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,WAAW;IAEpB;;;OAGG;IACH,MAAM,CAAC,GAAG;QACN,OAAO,QAAQ,CAAC,KAAK,CAAS,6BAA6B,EAAE,KAAK,CAAC,EAAE;YACjE,OAAO,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBACjE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;gB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A,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './screenplay';
|
|
1
|
+
export * from './screenplay/index.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./screenplay"), exports);
|
|
17
|
+
__exportStar(require("./screenplay/index.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
|
package/lib/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -32,11 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.SupportedProtocols = exports.ManageALocalServer = void 0;
|
|
37
40
|
const core_1 = require("@serenity-js/core");
|
|
38
41
|
const http = __importStar(require("http"));
|
|
39
|
-
const
|
|
42
|
+
const http_shutdown_1 = __importDefault(require("http-shutdown"));
|
|
40
43
|
const https = __importStar(require("https"));
|
|
41
44
|
const portfinder_1 = require("portfinder");
|
|
42
45
|
/**
|
|
@@ -117,7 +120,7 @@ class ManageALocalServer extends core_1.Ability {
|
|
|
117
120
|
constructor(protocol, server) {
|
|
118
121
|
super();
|
|
119
122
|
this.protocol = protocol;
|
|
120
|
-
this.server =
|
|
123
|
+
this.server = (0, http_shutdown_1.default)(server);
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
123
126
|
* Starts the server on the first free port between `preferredPort` and `highestPort`, inclusive.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManageALocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/ManageALocalServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ManageALocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/ManageALocalServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAgE;AAChE,2CAA6B;AAC7B,kEAAgD;AAChD,6CAA+B;AAE/B,2CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAa,kBAAmB,SAAQ,cAAO;IAwCd;IAtCZ,MAAM,CAAqB;IAE5C;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAsC;QAC9D,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,UAA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AAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAExC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;gBACvC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;gBAElD,OAAO,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAI,EAAoE;QAC/E,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACJ;AAnFD,gDAmFC;AAkBD;;;;;;GAMG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,qCAAe,CAAA;AACnB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ManageALocalServer';
|
|
1
|
+
export * from './ManageALocalServer.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ManageALocalServer"), exports);
|
|
17
|
+
__exportStar(require("./ManageALocalServer.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './abilities';
|
|
2
|
-
export * from './interactions';
|
|
3
|
-
export * from './questions';
|
|
1
|
+
export * from './abilities/index.js';
|
|
2
|
+
export * from './interactions/index.js';
|
|
3
|
+
export * from './questions/index.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
package/lib/screenplay/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./abilities"), exports);
|
|
18
|
-
__exportStar(require("./interactions"), exports);
|
|
19
|
-
__exportStar(require("./questions"), exports);
|
|
17
|
+
__exportStar(require("./abilities/index.js"), exports);
|
|
18
|
+
__exportStar(require("./interactions/index.js"), exports);
|
|
19
|
+
__exportStar(require("./questions/index.js"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,0DAAwC;AACxC,uDAAqC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StartLocalServer = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../abilities/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Starts local server so that a test can interact with it.
|
|
8
8
|
*
|
|
@@ -47,7 +47,7 @@ class StartLocalServerOnRandomPort extends core_1.Interaction {
|
|
|
47
47
|
super(`#actor starts local server on a random port`);
|
|
48
48
|
}
|
|
49
49
|
async performAs(actor) {
|
|
50
|
-
await
|
|
50
|
+
await index_js_1.ManageALocalServer.as(actor).listen();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -61,7 +61,7 @@ class StartLocalServerOnPort extends core_1.Interaction {
|
|
|
61
61
|
}
|
|
62
62
|
async performAs(actor) {
|
|
63
63
|
const preferredPort = await actor.answer(this.preferredPort);
|
|
64
|
-
await
|
|
64
|
+
await index_js_1.ManageALocalServer.as(actor).listen(preferredPort);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -78,7 +78,7 @@ class StartLocalServerOnRandomPortBetween extends core_1.Interaction {
|
|
|
78
78
|
async performAs(actor) {
|
|
79
79
|
const lowestPort = await actor.answer(this.lowestPort);
|
|
80
80
|
const highestPort = await actor.answer(this.highestPort);
|
|
81
|
-
await
|
|
81
|
+
await index_js_1.ManageALocalServer.as(actor).listen(lowestPort, highestPort);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
//# sourceMappingURL=StartLocalServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StartLocalServer.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"StartLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StartLocalServer.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAEhD,oDAA2D;AAE3D;;;;GAIG;AACH,MAAa,gBAAgB;IAEzB;;OAEG;IACH,MAAM,CAAC,YAAY;QACf,OAAO,IAAI,4BAA4B,EAAE,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,aAAiC;QAC3C,OAAO,IAAI,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,mBAAmB,CAAC,UAA8B,EAAE,WAA+B;QACtF,OAAO,IAAI,mCAAmC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;CACJ;AAhCD,4CAgCC;AAED;;GAEG;AACH,MAAM,4BAA6B,SAAQ,kBAAW;IAElD;QACI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAA2D;QACvE,MAAM,6BAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAChD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,sBAAuB,SAAQ,kBAAW;IAEf;IAA7B,YAA6B,aAAiC;QAC1D,KAAK,CAAC,sCAAuC,aAAc,EAAE,CAAC,CAAC;QADtC,kBAAa,GAAb,aAAa,CAAoB;IAE9D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAA2D;QACvE,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE7D,MAAM,6BAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7D,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,mCAAoC,SAAQ,kBAAW;IAGpC;IACA;IAFrB,YACqB,UAA8B,EAC9B,WAA+B;QAEhD,KAAK,CAAC,8CAA+C,UAAW,QAAS,WAAY,EAAE,CAAC,CAAC;QAHxE,eAAU,GAAV,UAAU,CAAoB;QAC9B,gBAAW,GAAX,WAAW,CAAoB;IAGpD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAA2D;QACvE,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvD,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEzD,MAAM,6BAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;CACJ"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StopLocalServer = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../abilities/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Stops the local server. Should be used in `afterEach` block to make sure that the server
|
|
8
8
|
* is correctly shut down even when the test fails.
|
|
@@ -20,7 +20,7 @@ class StopLocalServer extends core_1.Interaction {
|
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
|
22
22
|
performAs(actor) {
|
|
23
|
-
return
|
|
23
|
+
return index_js_1.ManageALocalServer.as(actor).mapInstance(server => new Promise((resolve, reject) => {
|
|
24
24
|
if (!server.address()) {
|
|
25
25
|
return resolve();
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StopLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StopLocalServer.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"StopLocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/StopLocalServer.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAEhD,oDAA2D;AAE3D;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,kBAAW;IAE5C;;OAEG;IACH,MAAM,CAAC,SAAS;QACZ,OAAO,IAAI,eAAe,CAAC,+BAA+B,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAA2D;QACjE,OAAO,6BAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtF,IAAI,CAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;gBACrB,OAAO,OAAO,EAAE,CAAC;YACrB,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAY,EAAE,EAAE,CAC7B,KAAK;gBACD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBACf,CAAC,CAAC,OAAO,EAAE,CAClB,CAAC;QACN,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAzBD,0CAyBC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './StartLocalServer';
|
|
2
|
-
export * from './StopLocalServer';
|
|
1
|
+
export * from './StartLocalServer.js';
|
|
2
|
+
export * from './StopLocalServer.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./StartLocalServer"), exports);
|
|
18
|
-
__exportStar(require("./StopLocalServer"), exports);
|
|
17
|
+
__exportStar(require("./StartLocalServer.js"), exports);
|
|
18
|
+
__exportStar(require("./StopLocalServer.js"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,uDAAqC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LocalServer = void 0;
|
|
4
4
|
const node_url_1 = require("node:url");
|
|
5
5
|
const core_1 = require("@serenity-js/core");
|
|
6
|
-
const
|
|
6
|
+
const index_js_1 = require("../abilities/index.js");
|
|
7
7
|
/**
|
|
8
8
|
* @group Questions
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ class LocalServer {
|
|
|
14
14
|
*/
|
|
15
15
|
static url() {
|
|
16
16
|
return core_1.Question.about('the URL of the local server', actor => {
|
|
17
|
-
return
|
|
17
|
+
return index_js_1.ManageALocalServer.as(actor).mapInstance((server, protocol) => {
|
|
18
18
|
const info = server.address();
|
|
19
19
|
if (!info) {
|
|
20
20
|
throw new core_1.LogicError(`The server has not been started yet`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LocalServer.ts"],"names":[],"mappings":";;;AAAA,uCAA+B;AAG/B,4CAAyD;AAGzD,
|
|
1
|
+
{"version":3,"file":"LocalServer.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LocalServer.ts"],"names":[],"mappings":";;;AAAA,uCAA+B;AAG/B,4CAAyD;AAGzD,oDAA2D;AAE3D;;GAEG;AACH,MAAa,WAAW;IAEpB;;;OAGG;IACH,MAAM,CAAC,GAAG;QACN,OAAO,eAAQ,CAAC,KAAK,CAAS,6BAA6B,EAAE,KAAK,CAAC,EAAE;YACjE,OAAO,6BAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBACjE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;gBAE9B,IAAI,CAAE,IAAI,EAAE,CAAC;oBACT,MAAM,IAAI,iBAAU,CAAC,qCAAqC,CAAC,CAAC;gBAChE,CAAC;gBAED,IAAI,CAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,MAAM,IAAI,iBAAU,CAAC,yDAAyD,CAAC,CAAC;gBACpF,CAAC;gBAED,OAAO;oBACH,QAAQ;oBACR,KAAK;oBACL,GAAI,IAAI,CAAC,MAAO,EAAE,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,IAAK,IAAI,CAAC,OAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;oBAClF,GAAG;oBACH,IAAI,CAAC,IAAI;iBACZ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,eAAQ,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC5D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;YAElD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,cAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAzCD,kCAyCC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,gBAAsC;IACzD,OAAO,OAAO,gBAAgB,KAAK,QAAQ;WACpC,CAAC,CAAE,gBAAgB,CAAC,OAAO;WAC3B,CAAC,CAAE,gBAAgB,CAAC,MAAM;WAC1B,CAAC,CAAE,gBAAgB,CAAC,IAAI,CAAC;AACpC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './LocalServer';
|
|
1
|
+
export * from './LocalServer.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./LocalServer"), exports);
|
|
17
|
+
__exportStar(require("./LocalServer.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/local-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.42.0",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern library for managing local Node.js test servers, including Express, Koa, Hapi, and Restify, to support comprehensive integration testing",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -16,8 +16,25 @@
|
|
|
16
16
|
"access": "public",
|
|
17
17
|
"provenance": true
|
|
18
18
|
},
|
|
19
|
-
"main": "lib/index.js",
|
|
19
|
+
"main": "./lib/index.js",
|
|
20
20
|
"types": "./lib/index.d.ts",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"module": "./esm/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./esm/index.d.ts",
|
|
27
|
+
"default": "./esm/index.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./lib/index.d.ts",
|
|
31
|
+
"default": "./lib/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./lib/*": "./lib/*",
|
|
35
|
+
"./esm/*": "./esm/*.js",
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
21
38
|
"keywords": [
|
|
22
39
|
"automation",
|
|
23
40
|
"e2e",
|
|
@@ -42,8 +59,12 @@
|
|
|
42
59
|
"scripts": {
|
|
43
60
|
"clean": "rimraf target",
|
|
44
61
|
"test": "c8 npm run test:no-coverage",
|
|
45
|
-
"test:no-coverage": "mocha --config
|
|
46
|
-
"compile": "
|
|
62
|
+
"test:no-coverage": "mocha --config .mocharc.yml --spec='spec/**/*.spec.*'",
|
|
63
|
+
"compile": "npm run compile:clean && npm run compile:esm && npm run compile:cjs-package && npm run compile:cjs",
|
|
64
|
+
"compile:clean": "rimraf lib esm",
|
|
65
|
+
"compile:esm": "tsc --project tsconfig-esm.build.json",
|
|
66
|
+
"compile:cjs-package": "node -e \"require('fs').mkdirSync('lib', { recursive: true }); require('fs').writeFileSync('lib/package.json', '{ \\\"type\\\": \\\"commonjs\\\" }')\"",
|
|
67
|
+
"compile:cjs": "tsc --project tsconfig-cjs.build.json"
|
|
47
68
|
},
|
|
48
69
|
"repository": {
|
|
49
70
|
"type": "git",
|
|
@@ -57,12 +78,12 @@
|
|
|
57
78
|
"node": "^20 || ^22 || ^24"
|
|
58
79
|
},
|
|
59
80
|
"dependencies": {
|
|
60
|
-
"@serenity-js/core": "3.
|
|
81
|
+
"@serenity-js/core": "3.42.0",
|
|
61
82
|
"http-shutdown": "1.2.2",
|
|
62
83
|
"portfinder": "1.0.38"
|
|
63
84
|
},
|
|
64
85
|
"peerDependencies": {
|
|
65
|
-
"@hapi/hapi": "^21.4.
|
|
86
|
+
"@hapi/hapi": "^21.4.7",
|
|
66
87
|
"express": "^5.2.1",
|
|
67
88
|
"koa": "^3.1.2",
|
|
68
89
|
"restify": "^11.1.0"
|
|
@@ -82,10 +103,10 @@
|
|
|
82
103
|
}
|
|
83
104
|
},
|
|
84
105
|
"devDependencies": {
|
|
85
|
-
"@hapi/hapi": "21.4.
|
|
106
|
+
"@hapi/hapi": "21.4.7",
|
|
86
107
|
"@integration/testing-tools": "3.0.0",
|
|
87
|
-
"@serenity-js/assertions": "3.
|
|
88
|
-
"@serenity-js/rest": "3.
|
|
108
|
+
"@serenity-js/assertions": "3.42.0",
|
|
109
|
+
"@serenity-js/rest": "3.42.0",
|
|
89
110
|
"@types/chai": "4.3.20",
|
|
90
111
|
"@types/express": "5.0.6",
|
|
91
112
|
"@types/hapi": "18.0.15",
|
|
@@ -100,7 +121,8 @@
|
|
|
100
121
|
"restify": "11.1.0",
|
|
101
122
|
"semver": "7.7.4",
|
|
102
123
|
"ts-node": "10.9.2",
|
|
124
|
+
"tsx": "4.20.3",
|
|
103
125
|
"typescript": "5.9.3"
|
|
104
126
|
},
|
|
105
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "a415b0066807d7bab9f34b1ceef66a26156aafe1"
|
|
106
128
|
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './screenplay';
|
|
1
|
+
export * from './screenplay/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ability, ConfigurationError } from '@serenity-js/core';
|
|
2
2
|
import * as http from 'http';
|
|
3
|
-
import withShutdownSupport
|
|
3
|
+
import withShutdownSupport from 'http-shutdown';
|
|
4
4
|
import * as https from 'https';
|
|
5
5
|
import type * as net from 'net';
|
|
6
6
|
import { getPortPromise } from 'portfinder';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ManageALocalServer';
|
|
1
|
+
export * from './ManageALocalServer.js';
|
package/src/screenplay/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './abilities';
|
|
2
|
-
export * from './interactions';
|
|
3
|
-
export * from './questions';
|
|
1
|
+
export * from './abilities/index.js';
|
|
2
|
+
export * from './interactions/index.js';
|
|
3
|
+
export * from './questions/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Answerable, AnswersQuestions, CollectsArtifacts, UsesAbilities } from '@serenity-js/core';
|
|
2
2
|
import { Interaction } from '@serenity-js/core';
|
|
3
3
|
|
|
4
|
-
import { ManageALocalServer } from '../abilities';
|
|
4
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Starts local server so that a test can interact with it.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnswersQuestions, CollectsArtifacts, UsesAbilities } from '@serenity-js/core';
|
|
2
2
|
import { Interaction } from '@serenity-js/core';
|
|
3
3
|
|
|
4
|
-
import { ManageALocalServer } from '../abilities';
|
|
4
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Stops the local server. Should be used in `afterEach` block to make sure that the server
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './StartLocalServer';
|
|
2
|
-
export * from './StopLocalServer';
|
|
1
|
+
export * from './StartLocalServer.js';
|
|
2
|
+
export * from './StopLocalServer.js';
|
|
@@ -4,7 +4,7 @@ import type { QuestionAdapter } from '@serenity-js/core';
|
|
|
4
4
|
import { LogicError, Question } from '@serenity-js/core';
|
|
5
5
|
import type { AddressInfo } from 'net';
|
|
6
6
|
|
|
7
|
-
import { ManageALocalServer } from '../abilities';
|
|
7
|
+
import { ManageALocalServer } from '../abilities/index.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @group Questions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './LocalServer';
|
|
1
|
+
export * from './LocalServer.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.build.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./lib",
|
|
7
|
+
"module": "CommonJS",
|
|
8
|
+
"moduleResolution": "Node"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.ts"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"spec"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig-esm.options.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./esm",
|
|
7
|
+
"module": "Node20",
|
|
8
|
+
"moduleResolution": "Node16"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.ts"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"spec"
|
|
17
|
+
]
|
|
18
|
+
}
|