@loopback/testlab 3.1.3 → 3.1.7
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 +32 -0
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/expect.js +1 -0
- package/dist/expect.js.map +1 -1
- package/dist/http-error-logger.js +1 -0
- package/dist/http-error-logger.js.map +1 -1
- package/dist/http-server-config.d.ts +5 -2
- package/dist/http-server-config.js +37 -12
- package/dist/http-server-config.js.map +1 -1
- package/dist/request.js +1 -0
- package/dist/request.js.map +1 -1
- package/dist/shot.js +1 -0
- package/dist/shot.js.map +1 -1
- package/dist/sinon.js +1 -0
- package/dist/sinon.js.map +1 -1
- package/dist/skip.js +1 -0
- package/dist/skip.js.map +1 -1
- package/dist/test-sandbox.js +1 -0
- package/dist/test-sandbox.js.map +1 -1
- package/dist/to-json.js +1 -0
- package/dist/to-json.js.map +1 -1
- package/dist/validate-api-spec.js +1 -0
- package/dist/validate-api-spec.js.map +1 -1
- package/package.json +14 -11
- package/src/http-server-config.ts +44 -13
- package/index.d.ts +0 -6
- package/index.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.1.7](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@3.1.6...@loopback/testlab@3.1.7) (2020-06-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/testlab
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.1.6](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@3.1.5...@loopback/testlab@3.1.6) (2020-05-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @loopback/testlab
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [3.1.5](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@3.1.4...@loopback/testlab@3.1.5) (2020-05-20)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @loopback/testlab
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [3.1.4](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@3.1.3...@loopback/testlab@3.1.4) (2020-05-19)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @loopback/testlab
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [3.1.3](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@3.1.2...@loopback/testlab@3.1.3) (2020-05-07)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @loopback/testlab
|
package/dist/client.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createRestAppClient = exports.createClientForHandler = exports.supertest = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
/*
|
|
9
10
|
* HTTP client utilities
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE;;GAEG;AAEH,wDAAwB;AACxB,uCAAwC;AAEhC,8BAAS;AAIjB;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,OAAsE;IAEtE,MAAM,MAAM,GAAG,cAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AALD,wDAKC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,GAAwB;;IAC1D,MAAM,GAAG,SAAG,GAAG,CAAC,UAAU,CAAC,OAAO,mCAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CACb,4BAA4B,GAAG,CAAC,WAAW,CAAC,IAAI,wBAAwB,CACzE,CAAC;KACH;IACD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AARD,kDAQC"}
|
package/dist/expect.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.expect = void 0;
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
8
9
|
/// <reference path="../should-as-function.d.ts" />
|
|
9
10
|
const shouldAsFunction = require('should/as-function');
|
package/dist/expect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../src/expect.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../src/expect.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,qEAAqE;AACrE,mDAAmD;AAEnD,MAAM,gBAAgB,GAAa,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEjE,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;IACzC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEU,QAAA,MAAM,GAAG,gBAAgB,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createUnexpectedHttpErrorLogger = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* Creates a Logger that logs an Error if the HTTP status code is not expected
|
|
9
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error-logger.js","sourceRoot":"","sources":["../src/http-error-logger.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"http-error-logger.js","sourceRoot":"","sources":["../src/http-error-logger.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAKhE;;;;GAIG;AACH,SAAgB,+BAA+B,CAC7C,kBAA2B;IAE3B,OAAO,SAAS,sBAAsB,CACpC,GAAU,EACV,UAAkB,EAClB,GAAoB;;QAEpB,IAAI,UAAU,KAAK,kBAAkB;YAAE,OAAO;QAE9C,0BAA0B;QAC1B,OAAO,CAAC,KAAK,CACX,iCAAiC,EACjC,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,GAAG,EACP,UAAU,QACV,GAAG,CAAC,KAAK,mCAAI,GAAG,CACjB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAnBD,0EAmBC"}
|
|
@@ -7,10 +7,13 @@ export interface HttpOptions extends ListenOptions {
|
|
|
7
7
|
export interface HttpsOptions extends ListenOptions, HttpsServerOptions {
|
|
8
8
|
protocol: 'https';
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* An object that requires host and port properties
|
|
12
|
+
*/
|
|
13
|
+
export interface HostPort {
|
|
11
14
|
host: string;
|
|
12
15
|
port: number;
|
|
13
|
-
}
|
|
16
|
+
}
|
|
14
17
|
/**
|
|
15
18
|
* Create an HTTP-server configuration that works well in test environments.
|
|
16
19
|
* - Ask the operating system to assign a free (ephemeral) port.
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.givenHttpServerConfig = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
9
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
8
10
|
const fs_1 = require("fs");
|
|
9
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
12
|
const FIXTURES = path_1.default.resolve(__dirname, '../fixtures');
|
|
@@ -12,6 +14,14 @@ const DUMMY_TLS_CONFIG = {
|
|
|
12
14
|
key: fs_1.readFileSync(path_1.default.join(FIXTURES, 'key.pem')),
|
|
13
15
|
cert: fs_1.readFileSync(path_1.default.join(FIXTURES, 'cert.pem')),
|
|
14
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Assertion type guard for TypeScript to ensure `host` and `port` are set
|
|
19
|
+
* @param config - Host/port configuration
|
|
20
|
+
*/
|
|
21
|
+
function assertHostPort(config) {
|
|
22
|
+
assert_1.default(config.host != null, 'host is not set');
|
|
23
|
+
assert_1.default(config.port != null, 'port is not set');
|
|
24
|
+
}
|
|
15
25
|
/**
|
|
16
26
|
* Create an HTTP-server configuration that works well in test environments.
|
|
17
27
|
* - Ask the operating system to assign a free (ephemeral) port.
|
|
@@ -22,19 +32,24 @@ const DUMMY_TLS_CONFIG = {
|
|
|
22
32
|
* @param customConfig - Additional configuration options to apply.
|
|
23
33
|
*/
|
|
24
34
|
function givenHttpServerConfig(customConfig) {
|
|
25
|
-
const defaults = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
config.host = defaults.host;
|
|
33
|
-
if (config.port === undefined)
|
|
34
|
-
config.port = defaults.port;
|
|
35
|
-
if (isHttpsConfig(config)) {
|
|
35
|
+
const defaults = { host: '127.0.0.1', port: 0 };
|
|
36
|
+
if (isHttpsConfig(customConfig)) {
|
|
37
|
+
const config = { ...customConfig };
|
|
38
|
+
if (config.host == null)
|
|
39
|
+
config.host = defaults.host;
|
|
40
|
+
if (config.port == null)
|
|
41
|
+
config.port = defaults.port;
|
|
36
42
|
setupTlsConfig(config);
|
|
43
|
+
assertHostPort(config);
|
|
44
|
+
return config;
|
|
37
45
|
}
|
|
46
|
+
assertHttpConfig(customConfig);
|
|
47
|
+
const config = { ...customConfig };
|
|
48
|
+
if (config.host == null)
|
|
49
|
+
config.host = defaults.host;
|
|
50
|
+
if (config.port == null)
|
|
51
|
+
config.port = defaults.port;
|
|
52
|
+
assertHostPort(config);
|
|
38
53
|
return config;
|
|
39
54
|
}
|
|
40
55
|
exports.givenHttpServerConfig = givenHttpServerConfig;
|
|
@@ -45,7 +60,17 @@ function setupTlsConfig(config) {
|
|
|
45
60
|
return;
|
|
46
61
|
Object.assign(config, DUMMY_TLS_CONFIG);
|
|
47
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if the parameter is `HttpsOptions`
|
|
65
|
+
*/
|
|
48
66
|
function isHttpsConfig(config) {
|
|
49
|
-
return config
|
|
67
|
+
return (config === null || config === void 0 ? void 0 : config.protocol) === 'https';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Type guard to assert the parameter is `HttpOptions`
|
|
71
|
+
* @param config - Http config
|
|
72
|
+
*/
|
|
73
|
+
function assertHttpConfig(config) {
|
|
74
|
+
assert_1.default((config === null || config === void 0 ? void 0 : config.protocol) == null || (config === null || config === void 0 ? void 0 : config.protocol) === 'http');
|
|
50
75
|
}
|
|
51
76
|
//# sourceMappingURL=http-server-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server-config.js","sourceRoot":"","sources":["../src/http-server-config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"http-server-config.js","sourceRoot":"","sources":["../src/http-server-config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,4DAA4B;AAC5B,2BAAgC;AAGhC,wDAAwB;AAExB,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACxD,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE,iBAAY,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,EAAE,iBAAY,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CACpD,CAAC;AAkBF;;;GAGG;AACH,SAAS,cAAc,CAAC,MAAyB;IAC/C,gBAAM,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC/C,gBAAM,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,iBAAiB,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,YAAgB;IAEhB,MAAM,QAAQ,GAAa,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC;IAExD,IAAI,aAAa,CAAC,YAAY,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAM,EAAC,GAAG,YAAY,EAAC,CAAC;QACpC,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;Q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
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.httpsGetAsync = exports.httpGetAsync = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const http_1 = tslib_1.__importDefault(require("http"));
|
|
9
10
|
const https_1 = tslib_1.__importDefault(require("https"));
|
package/dist/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,wDAA2C;AAC3C,0DAA0B;AAC1B,sDAAsB;AAEtB;;;GAGG;AACH,SAAgB,YAAY,CAC1B,SAAiB,EACjB,KAAkB;IAElB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,EAAC,KAAK,EAAE,GAAG,UAAU,EAAC,CAAC;QACvC,cAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AATD,oCASC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAC3B,SAAiB,EACjB,KAAmB;IAEnB,KAAK,GACH,KAAK,aAAL,KAAK,cAAL,KAAK,GACL,IAAI,eAAK,CAAC,KAAK,CAAC;QACd,kBAAkB,EAAE,KAAK;KAC1B,CAAC,CAAC;IAEL,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,EAAC,KAAK,EAAE,GAAG,UAAU,EAAC,CAAC;IAEvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,eAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAhBD,sCAgBC"}
|
package/dist/shot.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.stubExpressContext = exports.stubHandlerContext = exports.stubServerResponse = exports.stubServerRequest = exports.inject = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
/*
|
|
9
10
|
* HTTP Request/Response mocks
|
package/dist/shot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shot.js","sourceRoot":"","sources":["../src/shot.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"shot.js","sourceRoot":"","sources":["../src/shot.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE;;;GAGG;AAEH,uDAAuD;AAEvD,8DAA8B;AAO9B,wDAAwB;AAExB,MAAM,MAAM,GAGmB,OAAO,CAAC,YAAY,CAAC,CAAC;AAG7C,wBAAM;AAEd,MAAM,WAAW,GAAoB,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAGvE,SAAgB,iBAAiB,CAC/B,OAA2B;IAE3B,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,oCAAoC;IACpC,0EAA0E;IAC1E,kEA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AChD,0EAA0E;IAC1E,+EAA+E;IAC9E,iBAAe,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,0BAA0B,CACjC,OAA2B,EAC3B,cAAkC;IAElC,4EAA4E;IAC5E,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,IAAS,EAAE,EAAE,CAC/C,cAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAErC,mBAAmB,CACjB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,6BAA6B,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAC1E,CAAC;IAEF,mBAAmB,CACjB,OAAO,CAAC,QAAQ,EAChB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACd,0CAA0C,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CACxE,CAAC;IAEF,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QACvC,mBAAmB,CACjB,CAAC,EACD,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACd,8CAA8C,WAAW,CACvD,KAAK,EACL,IAAI,CACL,GAAG,CACP,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAC1B,GAAQ,EACR,SAA2C;IAE3C,GAAG,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AACvC,CAAC"}
|
package/dist/sinon.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createStubInstance = exports.sinon = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
9
10
|
exports.sinon = sinon_1.default;
|
package/dist/sinon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sinon.js","sourceRoot":"","sources":["../src/sinon.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"sinon.js","sourceRoot":"","sources":["../src/sinon.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,0DAAsC;AAE9B,gBAFD,eAAK,CAEC;AAMb;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,kBAAkB,CAChC,WAAuC;IAEvC,MAAM,IAAI,GAAG,eAAK,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;AACrD,CAAC;AALD,gDAKC"}
|
package/dist/skip.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.skipOnTravis = exports.skipIf = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* Helper function for skipping tests when a certain condition is met.
|
|
9
10
|
*
|
package/dist/skip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../src/skip.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../src/skip.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAUhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,MAAM,CACpB,IAAa,EACb,IAAyE,EACzE,IAAY,EACZ,GAAG,IAAU;IAEb,IAAI,IAAI,EAAE;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;KAChD;SAAM;QACL,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;KAC5B;AACH,CAAC;AAXD,wBAWC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,YAAY,CAC1B,IAAyE,EACzE,IAAY,EACZ,GAAG,IAAU;IAEb,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;KAC1D;SAAM;QACL,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;KAC5B;AACH,CAAC;AAVD,oCAUC"}
|
package/dist/test-sandbox.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TestSandbox = void 0;
|
|
7
8
|
const fs_extra_1 = require("fs-extra");
|
|
8
9
|
const path_1 = require("path");
|
|
9
10
|
/**
|
package/dist/test-sandbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-sandbox.js","sourceRoot":"","sources":["../src/test-sandbox.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"test-sandbox.js","sourceRoot":"","sources":["../src/test-sandbox.ts"],"names":[],"mappings":";AAAA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;IAC5C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,IAAY;QAC5C,IAAI,GAAG,cAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,YAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;QAChC,MAAM,oBAAS,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,oBAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;IACpD,CAAC;CACF;AArID,kCAqIC"}
|
package/dist/to-json.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.toJSON = void 0;
|
|
7
8
|
function toJSON(value) {
|
|
8
9
|
return JSON.parse(JSON.stringify({ value })).value;
|
|
9
10
|
}
|
package/dist/to-json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-json.js","sourceRoot":"","sources":["../src/to-json.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"to-json.js","sourceRoot":"","sources":["../src/to-json.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAgDhE,SAAgB,MAAM,CAAI,KAAQ;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC;AAFD,wBAEC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validateApiSpec = void 0;
|
|
7
8
|
const validator = require('oas-validator');
|
|
8
9
|
const util_1 = require("util");
|
|
9
10
|
const validateAsync = util_1.promisify(validator.validate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-api-spec.js","sourceRoot":"","sources":["../src/validate-api-spec.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"validate-api-spec.js","sourceRoot":"","sources":["../src/validate-api-spec.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3C,+BAA+B;AAE/B,MAAM,aAAa,GAAG,gBAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEpD,8DAA8D;AACvD,KAAK,UAAU,eAAe,CAAC,IAAS;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC;IAEhB,IAAI;QACF,MAAM,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KACjC;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AARD,0CAQC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/testlab",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.7",
|
|
4
4
|
"description": "A collection of test utilities we use to write LoopBack tests.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
5
7
|
"engines": {
|
|
6
8
|
"node": ">=10"
|
|
7
9
|
},
|
|
@@ -15,30 +17,31 @@
|
|
|
15
17
|
"author": "IBM Corp.",
|
|
16
18
|
"copyright.owner": "IBM Corp.",
|
|
17
19
|
"license": "MIT",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
18
23
|
"dependencies": {
|
|
19
24
|
"@hapi/shot": "^4.1.2",
|
|
20
25
|
"@types/express": "^4.17.6",
|
|
21
|
-
"@types/fs-extra": "^
|
|
26
|
+
"@types/fs-extra": "^9.0.1",
|
|
22
27
|
"@types/shot": "^4.0.0",
|
|
23
|
-
"@types/sinon": "^9.0.
|
|
28
|
+
"@types/sinon": "^9.0.4",
|
|
24
29
|
"@types/supertest": "^2.0.9",
|
|
25
30
|
"express": "^4.17.1",
|
|
26
|
-
"fs-extra": "^9.0.
|
|
31
|
+
"fs-extra": "^9.0.1",
|
|
27
32
|
"oas-validator": "^4.0.3",
|
|
28
33
|
"should": "^13.2.3",
|
|
29
34
|
"sinon": "^9.0.2",
|
|
30
35
|
"supertest": "^4.0.2",
|
|
31
|
-
"tslib": "^
|
|
36
|
+
"tslib": "^2.0.0"
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
34
|
-
"@loopback/build": "^5.3
|
|
35
|
-
"@loopback/eslint-config": "^
|
|
36
|
-
"@types/node": "^10.17.
|
|
39
|
+
"@loopback/build": "^5.4.3",
|
|
40
|
+
"@loopback/eslint-config": "^8.0.1",
|
|
41
|
+
"@types/node": "^10.17.26"
|
|
37
42
|
},
|
|
38
43
|
"files": [
|
|
39
44
|
"README.md",
|
|
40
|
-
"index.js",
|
|
41
|
-
"index.d.ts",
|
|
42
45
|
"dist",
|
|
43
46
|
"fixtures",
|
|
44
47
|
"should-as-function.d.ts",
|
|
@@ -50,5 +53,5 @@
|
|
|
50
53
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
51
54
|
"directory": "packages/testlab"
|
|
52
55
|
},
|
|
53
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "f31b7e6de5a405a015cdd774f63d699b35d943cc"
|
|
54
57
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
|
+
import assert from 'assert';
|
|
6
7
|
import {readFileSync} from 'fs';
|
|
7
8
|
import {ServerOptions as HttpsServerOptions} from 'https';
|
|
8
9
|
import {ListenOptions} from 'net';
|
|
@@ -22,10 +23,22 @@ export interface HttpsOptions extends ListenOptions, HttpsServerOptions {
|
|
|
22
23
|
protocol: 'https';
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* An object that requires host and port properties
|
|
28
|
+
*/
|
|
29
|
+
export interface HostPort {
|
|
26
30
|
host: string;
|
|
27
31
|
port: number;
|
|
28
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Assertion type guard for TypeScript to ensure `host` and `port` are set
|
|
36
|
+
* @param config - Host/port configuration
|
|
37
|
+
*/
|
|
38
|
+
function assertHostPort(config: Partial<HostPort>): asserts config is HostPort {
|
|
39
|
+
assert(config.host != null, 'host is not set');
|
|
40
|
+
assert(config.port != null, 'port is not set');
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* Create an HTTP-server configuration that works well in test environments.
|
|
@@ -39,17 +52,22 @@ export type HostPort = {
|
|
|
39
52
|
export function givenHttpServerConfig<T extends HttpOptions | HttpsOptions>(
|
|
40
53
|
customConfig?: T,
|
|
41
54
|
): HostPort & T {
|
|
42
|
-
const defaults = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (config.host === undefined) config.host = defaults.host;
|
|
49
|
-
if (config.port === undefined) config.port = defaults.port;
|
|
50
|
-
if (isHttpsConfig(config)) {
|
|
55
|
+
const defaults: HostPort = {host: '127.0.0.1', port: 0};
|
|
56
|
+
|
|
57
|
+
if (isHttpsConfig(customConfig)) {
|
|
58
|
+
const config: T = {...customConfig};
|
|
59
|
+
if (config.host == null) config.host = defaults.host;
|
|
60
|
+
if (config.port == null) config.port = defaults.port;
|
|
51
61
|
setupTlsConfig(config);
|
|
62
|
+
assertHostPort(config);
|
|
63
|
+
return config;
|
|
52
64
|
}
|
|
65
|
+
|
|
66
|
+
assertHttpConfig(customConfig);
|
|
67
|
+
const config: T = {...customConfig};
|
|
68
|
+
if (config.host == null) config.host = defaults.host;
|
|
69
|
+
if (config.port == null) config.port = defaults.port;
|
|
70
|
+
assertHostPort(config);
|
|
53
71
|
return config;
|
|
54
72
|
}
|
|
55
73
|
|
|
@@ -59,8 +77,21 @@ function setupTlsConfig(config: HttpsServerOptions) {
|
|
|
59
77
|
Object.assign(config, DUMMY_TLS_CONFIG);
|
|
60
78
|
}
|
|
61
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if the parameter is `HttpsOptions`
|
|
82
|
+
*/
|
|
62
83
|
function isHttpsConfig(
|
|
63
|
-
config
|
|
84
|
+
config?: HttpOptions | HttpsOptions,
|
|
64
85
|
): config is HttpsOptions {
|
|
65
|
-
return config
|
|
86
|
+
return config?.protocol === 'https';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Type guard to assert the parameter is `HttpOptions`
|
|
91
|
+
* @param config - Http config
|
|
92
|
+
*/
|
|
93
|
+
function assertHttpConfig(
|
|
94
|
+
config?: HttpOptions | HttpsOptions,
|
|
95
|
+
): asserts config is HttpOptions {
|
|
96
|
+
assert(config?.protocol == null || config?.protocol === 'http');
|
|
66
97
|
}
|
package/index.d.ts
DELETED
package/index.js
DELETED