@loopback/testlab 1.9.4 → 1.10.2

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 CHANGED
@@ -3,6 +3,41 @@
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
+ ## [1.10.2](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.10.1...@loopback/testlab@1.10.2) (2020-01-27)
7
+
8
+ **Note:** Version bump only for package @loopback/testlab
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.10.1](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.10.0...@loopback/testlab@1.10.1) (2020-01-07)
15
+
16
+ **Note:** Version bump only for package @loopback/testlab
17
+
18
+
19
+
20
+
21
+
22
+ # [1.10.0](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.9.5...@loopback/testlab@1.10.0) (2019-12-09)
23
+
24
+
25
+ ### Features
26
+
27
+ * **testlab:** allow an optional agent argument for http/https get requests ([d67384b](https://github.com/strongloop/loopback-next/commit/d67384be5806bbcdab4a935d848a9c76da0a354c))
28
+
29
+
30
+
31
+
32
+
33
+ ## [1.9.5](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.9.4...@loopback/testlab@1.9.5) (2019-11-25)
34
+
35
+ **Note:** Version bump only for package @loopback/testlab
36
+
37
+
38
+
39
+
40
+
6
41
  ## [1.9.4](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.9.3...@loopback/testlab@1.9.4) (2019-11-12)
7
42
 
8
43
  **Note:** Version bump only for package @loopback/testlab
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import * as http from 'http';
2
+ import http from 'http';
3
3
  import supertest = require('supertest');
4
4
  export { supertest };
5
5
  export declare type Client = supertest.SuperTest<supertest.Test>;
package/dist/client.js CHANGED
@@ -3,11 +3,14 @@
3
3
  // Node module: @loopback/testlab
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
10
  /*
8
11
  * HTTP client utilities
9
12
  */
10
- const http = require("http");
13
+ const http_1 = __importDefault(require("http"));
11
14
  const supertest = require("supertest");
12
15
  exports.supertest = supertest;
13
16
  /**
@@ -16,7 +19,7 @@ exports.supertest = supertest;
16
19
  * @param handler
17
20
  */
18
21
  function createClientForHandler(handler) {
19
- const server = http.createServer(handler);
22
+ const server = http_1.default.createServer(handler);
20
23
  return supertest(server);
21
24
  }
22
25
  exports.createClientForHandler = createClientForHandler;
@@ -27,7 +30,8 @@ exports.createClientForHandler = createClientForHandler;
27
30
  * @param app - A running (listening) instance of a RestApplication.
28
31
  */
29
32
  function createRestAppClient(app) {
30
- const url = app.restServer.rootUrl || app.restServer.url;
33
+ var _a;
34
+ const url = (_a = app.restServer.rootUrl, (_a !== null && _a !== void 0 ? _a : app.restServer.url));
31
35
  if (!url) {
32
36
  throw new Error(`Cannot create client for ${app.constructor.name}, it is not listening.`);
33
37
  }
@@ -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;;AAEhE;;GAEG;AAEH,6BAA6B;AAC7B,uCAAwC;AAEhC,8BAAS;AAIjB;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,OAAsE;IAEtE,MAAM,MAAM,GAAG,IAAI,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,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI,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"}
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,gDAAwB;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,uCAAI,GAAG,CAAC,UAAU,CAAC,GAAG,EAAA,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"}
@@ -11,10 +11,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  */
12
12
  function createUnexpectedHttpErrorLogger(expectedStatusCode) {
13
13
  return function logUnexpectedHttpError(err, statusCode, req) {
14
+ var _a;
14
15
  if (statusCode === expectedStatusCode)
15
16
  return;
16
17
  /* istanbul ignore next */
17
- console.error('Unhandled error in %s %s: %s %s', req.method, req.url, statusCode, err.stack || err);
18
+ console.error('Unhandled error in %s %s: %s %s', req.method, req.url, statusCode, (_a = err.stack, (_a !== null && _a !== void 0 ? _a : err)));
18
19
  };
19
20
  }
20
21
  exports.createUnexpectedHttpErrorLogger = createUnexpectedHttpErrorLogger;
@@ -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;;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,EACV,GAAG,CAAC,KAAK,IAAI,GAAG,CACjB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAnBD,0EAmBC"}
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,uCAAI,GAAG,GACjB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAnBD,0EAmBC"}
@@ -3,13 +3,16 @@
3
3
  // Node module: @loopback/testlab
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
10
  const fs_1 = require("fs");
8
- const path = require("path");
9
- const FIXTURES = path.resolve(__dirname, '../fixtures');
11
+ const path_1 = __importDefault(require("path"));
12
+ const FIXTURES = path_1.default.resolve(__dirname, '../fixtures');
10
13
  const DUMMY_TLS_CONFIG = {
11
- key: fs_1.readFileSync(path.join(FIXTURES, 'key.pem')),
12
- cert: fs_1.readFileSync(path.join(FIXTURES, 'cert.pem')),
14
+ key: fs_1.readFileSync(path_1.default.join(FIXTURES, 'key.pem')),
15
+ cert: fs_1.readFileSync(path_1.default.join(FIXTURES, 'cert.pem')),
13
16
  };
14
17
  /**
15
18
  * Create an HTTP-server configuration that works well in test environments.
@@ -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;;AAEhE,2BAAgC;AAGhC,6BAA6B;AAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACxD,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE,iBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,EAAE,iBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CACpD,CAAC;AAeF;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,YAAgB;IAEhB,MAAM,QAAQ,GAAG;QACf,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,SAAS;KACpB,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,E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QACf,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,SAAS;KACpB,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3D,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3D,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;QACzB,cAAc,CAAC,MAAM,CAAC,CAAC;KACxB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,sDAeC;AAED,SAAS,cAAc,CAAC,MAA0B;IAChD,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM;QAAE,OAAO;IAChD,IAAI,KAAK,IAAI,MAAM;QAAE,OAAO;IAC5B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CACpB,MAAkC;IAElC,OAAO,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC;AAC/C,CAAC"}
package/dist/request.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
2
+ import http, { IncomingMessage } from 'http';
3
+ import https from 'https';
3
4
  /**
4
5
  * Async wrapper for making HTTP GET requests
5
6
  * @param urlString
6
7
  */
7
- export declare function httpGetAsync(urlString: string): Promise<IncomingMessage>;
8
+ export declare function httpGetAsync(urlString: string, agent?: http.Agent): Promise<IncomingMessage>;
8
9
  /**
9
10
  * Async wrapper for making HTTPS GET requests
10
11
  * @param urlString
11
12
  */
12
- export declare function httpsGetAsync(urlString: string): Promise<IncomingMessage>;
13
+ export declare function httpsGetAsync(urlString: string, agent?: https.Agent): Promise<IncomingMessage>;
package/dist/request.js CHANGED
@@ -3,17 +3,22 @@
3
3
  // Node module: @loopback/testlab
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const http = require("http");
8
- const https = require("https");
9
- const url = require("url");
10
+ const http_1 = __importDefault(require("http"));
11
+ const https_1 = __importDefault(require("https"));
12
+ const url_1 = __importDefault(require("url"));
10
13
  /**
11
14
  * Async wrapper for making HTTP GET requests
12
15
  * @param urlString
13
16
  */
14
- function httpGetAsync(urlString) {
17
+ function httpGetAsync(urlString, agent) {
15
18
  return new Promise((resolve, reject) => {
16
- http.get(urlString, resolve).on('error', reject);
19
+ const urlOptions = url_1.default.parse(urlString);
20
+ const options = Object.assign({ agent }, urlOptions);
21
+ http_1.default.get(options, resolve).on('error', reject);
17
22
  });
18
23
  }
19
24
  exports.httpGetAsync = httpGetAsync;
@@ -21,14 +26,14 @@ exports.httpGetAsync = httpGetAsync;
21
26
  * Async wrapper for making HTTPS GET requests
22
27
  * @param urlString
23
28
  */
24
- function httpsGetAsync(urlString) {
25
- const agent = new https.Agent({
29
+ function httpsGetAsync(urlString, agent) {
30
+ agent = (agent !== null && agent !== void 0 ? agent : new https_1.default.Agent({
26
31
  rejectUnauthorized: false,
27
- });
28
- const urlOptions = url.parse(urlString);
32
+ }));
33
+ const urlOptions = url_1.default.parse(urlString);
29
34
  const options = Object.assign({ agent }, urlOptions);
30
35
  return new Promise((resolve, reject) => {
31
- https.get(options, resolve).on('error', reject);
36
+ https_1.default.get(options, resolve).on('error', reject);
32
37
  });
33
38
  }
34
39
  exports.httpsGetAsync = httpsGetAsync;
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";AAAA,iDAAi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mBAAI,KAAK,IAAK,UAAU,CAAC,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,IACH,KAAK,aAAL,KAAK,cAAL,KAAK,GACL,IAAI,eAAK,CAAC,KAAK,CAAC;QACd,kBAAkB,EAAE,KAAK;KAC1B,CAAC,CAAA,CAAC;IAEL,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,OAAO,mBAAI,KAAK,IAAK,UAAU,CAAC,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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import * as express from 'express';
2
+ import express from 'express';
3
3
  import { IncomingMessage, ServerResponse } from 'http';
4
4
  import { Listener as ShotListener, RequestOptions as ShotRequestOptions, ResponseObject } from 'shot';
5
5
  declare const inject: (dispatchFunc: ShotListener, options: ShotRequestOptions) => Promise<ResponseObject>;
package/dist/shot.js CHANGED
@@ -3,14 +3,17 @@
3
3
  // Node module: @loopback/testlab
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
10
  /*
8
11
  * HTTP Request/Response mocks
9
12
  * https://github.com/hapijs/shot
10
13
  */
11
14
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
- const express = require("express");
13
- const util = require("util");
15
+ const express_1 = __importDefault(require("express"));
16
+ const util_1 = __importDefault(require("util"));
14
17
  const inject = require('@hapi/shot');
15
18
  exports.inject = inject;
16
19
  const ShotRequest = require('@hapi/shot/lib/request');
@@ -47,10 +50,10 @@ function stubHandlerContext(requestOptions = { url: '/' }) {
47
50
  }
48
51
  exports.stubHandlerContext = stubHandlerContext;
49
52
  function stubExpressContext(requestOptions = { url: '/' }) {
50
- const app = express();
53
+ const app = express_1.default();
51
54
  const request = new ShotRequest(requestOptions);
52
55
  // mix in Express Request API
53
- const RequestApi = express.request;
56
+ const RequestApi = express_1.default.request;
54
57
  for (const key of Object.getOwnPropertyNames(RequestApi)) {
55
58
  Object.defineProperty(request, key, Object.getOwnPropertyDescriptor(RequestApi, key));
56
59
  }
@@ -61,8 +64,8 @@ function stubExpressContext(requestOptions = { url: '/' }) {
61
64
  const result = new Promise(resolve => {
62
65
  response = new ShotResponse(request, resolve);
63
66
  // mix in Express Response API
64
- Object.assign(response, express.response);
65
- const ResponseApi = express.response;
67
+ Object.assign(response, express_1.default.response);
68
+ const ResponseApi = express_1.default.response;
66
69
  for (const key of Object.getOwnPropertyNames(ResponseApi)) {
67
70
  Object.defineProperty(response, key, Object.getOwnPropertyDescriptor(ResponseApi, key));
68
71
  }
@@ -83,11 +86,11 @@ function parseQuery(request) {
83
86
  // Use `express.query` to parse the query string
84
87
  // See https://github.com/expressjs/express/blob/master/lib/express.js#L79
85
88
  // See https://github.com/expressjs/express/blob/master/lib/middleware/query.js
86
- express.query()(request, {}, () => { });
89
+ express_1.default.query()(request, {}, () => { });
87
90
  }
88
91
  function defineCustomContextInspect(context, requestOptions) {
89
92
  // Setup custom inspect functions to make test error messages easier to read
90
- const inspectOpts = (depth, opts) => util.inspect(requestOptions, opts);
93
+ const inspectOpts = (depth, opts) => util_1.default.inspect(requestOptions, opts);
91
94
  defineCustomInspect(context.request, (depth, opts) => `[RequestStub with options ${inspectOpts(depth, opts)}]`);
92
95
  defineCustomInspect(context.response, (depth, opts) => `[ResponseStub for request with options ${inspectOpts(depth, opts)}]`);
93
96
  context.result = context.result.then(r => {
@@ -96,6 +99,6 @@ function defineCustomContextInspect(context, requestOptions) {
96
99
  });
97
100
  }
98
101
  function defineCustomInspect(obj, inspectFn) {
99
- obj[util.inspect.custom] = inspectFn;
102
+ obj[util_1.default.inspect.custom] = inspectFn;
100
103
  }
101
104
  //# sourceMappingURL=shot.js.map
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;;AAEhE;;;GAGG;AAEH,uDAAuD;AAEvD,mCAAmC;AAOnC,6BAA6B;AAE7B,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,kEAAkE;IAClE,yCAAyC;IACzC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC;AAVD,8CAUC;AAED,MAAM,YAAY,GAAqB,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAQ1E,SAAgB,kBAAkB,CAChC,OAAwB,EACxB,KAAmB;IAEnB,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,oCAAoC;IACpC,0EAA0E;IAC1E,kEAAkE;IAClE,yCAAyC;IACzC,MAAM,CAA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AA0B,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.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as sinon from 'sinon';
2
- import { SinonSpy } from 'sinon';
1
+ import sinon, { SinonSpy } from 'sinon';
3
2
  export { sinon, SinonSpy };
4
3
  export declare type StubbedInstanceWithSinonAccessor<T> = T & {
5
4
  stubs: sinon.SinonStubbedInstance<T>;
package/dist/sinon.js CHANGED
@@ -3,9 +3,12 @@
3
3
  // Node module: @loopback/testlab
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const sinon = require("sinon");
8
- exports.sinon = sinon;
10
+ const sinon_1 = __importDefault(require("sinon"));
11
+ exports.sinon = sinon_1.default;
9
12
  /**
10
13
  * Creates a new object with the given functions as the prototype and stubs all
11
14
  * implemented functions.
@@ -26,7 +29,7 @@ exports.sinon = sinon;
26
29
  * providing access to stub API for individual methods.
27
30
  */
28
31
  function createStubInstance(constructor) {
29
- const stub = sinon.createStubInstance(constructor);
32
+ const stub = sinon_1.default.createStubInstance(constructor);
30
33
  return Object.assign(stub, { stubs: stub });
31
34
  }
32
35
  exports.createStubInstance = createStubInstance;
package/dist/sinon.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sinon.js","sourceRoot":"","sources":["../src/sinon.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+BAA+B;AAGvB,sBAAK;AAMb;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,kBAAkB,CAChC,WAAuC;IAEvC,MAAM,IAAI,GAAG,KAAK,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"}
1
+ {"version":3,"file":"sinon.js","sourceRoot":"","sources":["../src/sinon.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAsC;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopback/testlab",
3
- "version": "1.9.4",
3
+ "version": "1.10.2",
4
4
  "description": "A collection of test utilities we use to write LoopBack tests.",
5
5
  "engines": {
6
6
  "node": ">=8.9"
@@ -20,19 +20,19 @@
20
20
  "@types/express": "^4.17.2",
21
21
  "@types/fs-extra": "^8.0.1",
22
22
  "@types/shot": "^4.0.0",
23
- "@types/sinon": "^7.5.0",
23
+ "@types/sinon": "^7.5.1",
24
24
  "@types/supertest": "^2.0.8",
25
25
  "express": "^4.17.1",
26
26
  "fs-extra": "^8.1.0",
27
- "oas-validator": "^3.3.1",
27
+ "oas-validator": "^3.3.2",
28
28
  "should": "^13.2.3",
29
- "sinon": "^7.5.0",
29
+ "sinon": "^8.1.1",
30
30
  "supertest": "^4.0.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@loopback/build": "^2.0.16",
34
- "@loopback/eslint-config": "^4.1.4",
35
- "@types/node": "^10.17.5"
33
+ "@loopback/build": "^3.1.0",
34
+ "@loopback/eslint-config": "^5.0.2",
35
+ "@types/node": "^10.17.13"
36
36
  },
37
37
  "files": [
38
38
  "README.md",
@@ -49,5 +49,5 @@
49
49
  "url": "https://github.com/strongloop/loopback-next.git",
50
50
  "directory": "packages/testlab"
51
51
  },
52
- "gitHead": "7f0ae6ec124c19357c3016cd11f9bc9c739dffcb"
52
+ "gitHead": "d08f135a0d1040edc61497739a8d86a866e4e29a"
53
53
  }
package/src/client.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * HTTP client utilities
8
8
  */
9
9
 
10
- import * as http from 'http';
10
+ import http from 'http';
11
11
  import supertest = require('supertest');
12
12
 
13
13
  export {supertest};
@@ -33,7 +33,7 @@ export function createClientForHandler(
33
33
  * @param app - A running (listening) instance of a RestApplication.
34
34
  */
35
35
  export function createRestAppClient(app: RestApplicationLike) {
36
- const url = app.restServer.rootUrl || app.restServer.url;
36
+ const url = app.restServer.rootUrl ?? app.restServer.url;
37
37
  if (!url) {
38
38
  throw new Error(
39
39
  `Cannot create client for ${app.constructor.name}, it is not listening.`,
@@ -27,7 +27,7 @@ export function createUnexpectedHttpErrorLogger(
27
27
  req.method,
28
28
  req.url,
29
29
  statusCode,
30
- err.stack || err,
30
+ err.stack ?? err,
31
31
  );
32
32
  };
33
33
  }
@@ -6,7 +6,7 @@
6
6
  import {readFileSync} from 'fs';
7
7
  import {ServerOptions as HttpsServerOptions} from 'https';
8
8
  import {ListenOptions} from 'net';
9
- import * as path from 'path';
9
+ import path from 'path';
10
10
 
11
11
  const FIXTURES = path.resolve(__dirname, '../fixtures');
12
12
  const DUMMY_TLS_CONFIG = {
package/src/request.ts CHANGED
@@ -3,18 +3,22 @@
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 {IncomingMessage} from 'http';
7
- import * as http from 'http';
8
- import * as https from 'https';
9
- import * as url from 'url';
6
+ import http, {IncomingMessage} from 'http';
7
+ import https from 'https';
8
+ import url from 'url';
10
9
 
11
10
  /**
12
11
  * Async wrapper for making HTTP GET requests
13
12
  * @param urlString
14
13
  */
15
- export function httpGetAsync(urlString: string): Promise<IncomingMessage> {
14
+ export function httpGetAsync(
15
+ urlString: string,
16
+ agent?: http.Agent,
17
+ ): Promise<IncomingMessage> {
16
18
  return new Promise((resolve, reject) => {
17
- http.get(urlString, resolve).on('error', reject);
19
+ const urlOptions = url.parse(urlString);
20
+ const options = {agent, ...urlOptions};
21
+ http.get(options, resolve).on('error', reject);
18
22
  });
19
23
  }
20
24
 
@@ -22,10 +26,15 @@ export function httpGetAsync(urlString: string): Promise<IncomingMessage> {
22
26
  * Async wrapper for making HTTPS GET requests
23
27
  * @param urlString
24
28
  */
25
- export function httpsGetAsync(urlString: string): Promise<IncomingMessage> {
26
- const agent = new https.Agent({
27
- rejectUnauthorized: false,
28
- });
29
+ export function httpsGetAsync(
30
+ urlString: string,
31
+ agent?: https.Agent,
32
+ ): Promise<IncomingMessage> {
33
+ agent =
34
+ agent ??
35
+ new https.Agent({
36
+ rejectUnauthorized: false,
37
+ });
29
38
 
30
39
  const urlOptions = url.parse(urlString);
31
40
  const options = {agent, ...urlOptions};
package/src/shot.ts CHANGED
@@ -10,14 +10,14 @@
10
10
 
11
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
 
13
- import * as express from 'express';
13
+ import express from 'express';
14
14
  import {IncomingMessage, ServerResponse} from 'http';
15
15
  import {
16
16
  Listener as ShotListener,
17
17
  RequestOptions as ShotRequestOptions,
18
18
  ResponseObject,
19
19
  } from 'shot'; // <-- workaround for missing type-defs for @hapi/shot
20
- import * as util from 'util';
20
+ import util from 'util';
21
21
 
22
22
  const inject: (
23
23
  dispatchFunc: ShotListener,
package/src/sinon.ts CHANGED
@@ -3,8 +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 * as sinon from 'sinon';
7
- import {SinonSpy} from 'sinon';
6
+ import sinon, {SinonSpy} from 'sinon';
8
7
 
9
8
  export {sinon, SinonSpy};
10
9